servo: Merge #13079 - Update regen script to take into account the bindgen docopt upgrade (from emilio:bindgenup); r=Manishearth
authorEmilio Cobos Álvarez <ecoal95@gmail.com>
Sat, 27 Aug 2016 10:21:44 -0500
changeset 339593 730093b6ccd1a1e3efef005065ec0f20bc7dc73a
parent 339592 aec432f380fc4a340503c9d3d4d4851ad623eef1
child 339594 2ebd2bdeb50654ffd40e02be51e82437bcf0866b
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersManishearth
servo: Merge #13079 - Update regen script to take into account the bindgen docopt upgrade (from emilio:bindgenup); r=Manishearth <!-- Please describe your changes on the following line: --> r? @bholley --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 23b83aaa1e638f9763f29f254e6dfa1f0e3c6067
servo/ports/geckolib/binding_tools/regen.py
--- a/servo/ports/geckolib/binding_tools/regen.py
+++ b/servo/ports/geckolib/binding_tools/regen.py
@@ -18,19 +18,21 @@ import regen_atoms
 DESCRIPTION = 'Regenerate the rust version of the structs or the bindings file.'
 TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
 COMMON_BUILD_KEY = "__common__"
 
 COMPILATION_TARGETS = {
     # Flags common for all the targets.
     COMMON_BUILD_KEY: {
         "flags": [
+            "--allow-unknown-types", "--no-unstable-rust",
+            "--no-type-renaming", "--no-namespaced-constants",
+        ],
+        "clang_flags": [
             "-x", "c++", "-std=c++14",
-            "-allow-unknown-types", "-no-unstable-rust",
-            "-no-type-renaming", "-no-namespaced-constants",
             "-DTRACING=1", "-DIMPL_LIBXUL", "-DMOZ_STYLO_BINDINGS=1",
             "-DMOZILLA_INTERNAL_API", "-DRUST_BINDGEN",
         ],
         "search_dirs": [
             "{}/dist/include",
             "{}/dist/include/nspr",
             "{}/../nsprpub/pr/include"
         ],
@@ -38,30 +40,30 @@ COMPILATION_TARGETS = {
             "{}/mozilla-config.h",
         ],
     },
     # Generation of style structs.
     "structs": {
         "target_dir": "../gecko_bindings",
         "test": True,
         "flags": [
-            "-ignore-functions",
-            "-ignore-methods",
+            "--ignore-functions",
+            "--ignore-methods",
         ],
         "includes": [
             "{}/dist/include/nsThemeConstants.h",
             "{}/dist/include/mozilla/dom/AnimationEffectReadOnlyBinding.h",
             "{}/dist/include/mozilla/ServoElementSnapshot.h",
         ],
         "files": [
             "{}/dist/include/nsStyleStruct.h",
         ],
         "build_kinds": {
             "debug": {
-                "flags": [
+                "clang_flags": [
                     "-DDEBUG=1",
                     "-DJS_DEBUG=1",
                 ]
             },
             "release": {
             }
         },
         "match_headers": [
@@ -110,17 +112,17 @@ COMPILATION_TARGETS = {
     },
     # Generation of the ffi bindings.
     "bindings": {
         "target_dir": "../gecko_bindings",
         "raw_lines": [
             "use heapsize::HeapSizeOf;",
         ],
         "flags": [
-            "-ignore-methods",
+            "--ignore-methods",
         ],
         "match_headers": [
             "ServoBindingList.h",
             "ServoBindings.h",
             "nsStyleStructList.h",
         ],
         "files": [
             "{}/dist/include/mozilla/ServoBindings.h",
@@ -264,96 +266,102 @@ def build(objdir, target_name, debug, de
 
     if target_dir:
         output_filename = "{}/{}".format(target_dir, output_filename)
 
     print("[BINDGEN] {}::{} in \"{}\"... ".format(target_name, kind_name, objdir), end='')
     sys.stdout.flush()
 
     flags = []
-    flags.extend(platform_dependent_defines())
 
     if "flags" in current_target:
         flags.extend(current_target["flags"])
 
+    clang_flags = []
+
+    if "clang_flags" in current_target:
+        clang_flags.extend(current_target["clang_flags"])
+
+    clang_flags.extend(platform_dependent_defines())
+
     if "raw_lines" in current_target:
         for raw_line in current_target["raw_lines"]:
-            flags.append("-raw-line")
+            flags.append("--raw-line")
             flags.append(raw_line)
 
     if "search_dirs" in current_target:
         for dir_name in current_target["search_dirs"]:
-            flags.append("-I")
-            flags.append(dir_name.format(objdir))
+            clang_flags.append("-I")
+            clang_flags.append(dir_name.format(objdir))
 
     if "includes" in current_target:
         for file_name in current_target["includes"]:
-            flags.append("-include")
-            flags.append(file_name.format(objdir))
+            clang_flags.append("-include")
+            clang_flags.append(file_name.format(objdir))
 
     if "match_headers" in current_target:
         for header in current_target["match_headers"]:
-            flags.append("-match")
+            flags.append("--match")
             flags.append(header.format(objdir))
 
     if "blacklist" in current_target:
         for ty in current_target["blacklist"]:
-            flags.append("-blacklist-type")
+            flags.append("--blacklist-type")
             flags.append(ty)
 
     if "opaque_types" in current_target:
         for ty in current_target["opaque_types"]:
-            flags.append("-opaque-type")
+            flags.append("--opaque-type")
             flags.append(ty)
     if "void_types" in current_target:
         for ty in current_target["void_types"]:
-            flags.append("-raw-line")
+            flags.append("--raw-line")
             flags.append("pub enum {} {{}}".format(ty))
     if "servo_arc_types" in current_target:
         for ty in current_target["servo_arc_types"]:
-            flags.append("-blacklist-type")
+            flags.append("--blacklist-type")
             flags.append("{}Strong".format(ty))
-            flags.append("-raw-line")
+            flags.append("--raw-line")
             flags.append("pub type {0}Strong = ::sugar::refptr::Strong<{0}>;".format(ty))
             flags.append("-blacklist-type")
             flags.append("{}Borrowed".format(ty))
-            flags.append("-raw-line")
+            flags.append("--raw-line")
             flags.append("pub type {0}Borrowed<'a> = ::sugar::refptr::Borrowed<'a, {0}>;".format(ty))
     if "structs_types" in current_target:
         for ty in current_target["structs_types"]:
             ty_fragments = ty.split("::")
             mangled_name = ty.replace("::", "_")
-            flags.append("-blacklist-type")
+            flags.append("--blacklist-type")
             flags.append(ty_fragments[-1])
-            flags.append("-raw-line")
+            flags.append("--raw-line")
             if len(ty_fragments) > 1:
                 flags.append("use structs::{} as {};".format(mangled_name, ty_fragments[-1]))
             else:
                 flags.append("use structs::{};".format(mangled_name))
             # TODO: this is hacky, figure out a better way to do it without
             # hardcoding everything...
             if ty_fragments[-1].startswith("nsStyle"):
                 flags.extend([
-                    "-raw-line",
+                    "--raw-line",
                     "unsafe impl Send for {} {{}}".format(ty_fragments[-1]),
-                    "-raw-line",
+                    "--raw-line",
                     "unsafe impl Sync for {} {{}}".format(ty_fragments[-1]),
-                    "-raw-line",
+                    "--raw-line",
                     "impl HeapSizeOf for {} {{ fn heap_size_of_children(&self) -> usize {{ 0 }} }}"
                     .format(ty_fragments[-1])
                 ])
 
     flags.append("-o")
     flags.append(output_filename)
 
     # TODO: support more files, that's the whole point of this.
     assert len(current_target["files"]) == 1
-    flags.append(current_target["files"][0].format(objdir))
+    clang_flags.append(current_target["files"][0].format(objdir))
 
-    flags = bindgen + flags
+    flags = bindgen + flags + ["--"] + clang_flags
 
     output = ""
     try:
         if debug:
             flags = [debugger, "--args"] + flags
             subprocess.check_call(flags)
         else:
             output = subprocess.check_output(flags, stderr=subprocess.STDOUT)