Update regen script to take into account the bindgen docopt upgrade.

This commit is contained in:
Emilio Cobos Álvarez 2016-08-27 01:32:43 -07:00
parent b399fcb54b
commit 0670db3f71
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -23,9 +23,11 @@ COMPILATION_TARGETS = {
# Flags common for all the targets. # Flags common for all the targets.
COMMON_BUILD_KEY: { COMMON_BUILD_KEY: {
"flags": [ "flags": [
"--allow-unknown-types", "--no-unstable-rust",
"--no-type-renaming", "--no-namespaced-constants",
],
"clang_flags": [
"-x", "c++", "-std=c++14", "-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", "-DTRACING=1", "-DIMPL_LIBXUL", "-DMOZ_STYLO_BINDINGS=1",
"-DMOZILLA_INTERNAL_API", "-DRUST_BINDGEN", "-DMOZILLA_INTERNAL_API", "-DRUST_BINDGEN",
], ],
@ -43,8 +45,8 @@ COMPILATION_TARGETS = {
"target_dir": "../gecko_bindings", "target_dir": "../gecko_bindings",
"test": True, "test": True,
"flags": [ "flags": [
"-ignore-functions", "--ignore-functions",
"-ignore-methods", "--ignore-methods",
], ],
"includes": [ "includes": [
"{}/dist/include/nsThemeConstants.h", "{}/dist/include/nsThemeConstants.h",
@ -56,7 +58,7 @@ COMPILATION_TARGETS = {
], ],
"build_kinds": { "build_kinds": {
"debug": { "debug": {
"flags": [ "clang_flags": [
"-DDEBUG=1", "-DDEBUG=1",
"-DJS_DEBUG=1", "-DJS_DEBUG=1",
] ]
@ -115,7 +117,7 @@ COMPILATION_TARGETS = {
"use heapsize::HeapSizeOf;", "use heapsize::HeapSizeOf;",
], ],
"flags": [ "flags": [
"-ignore-methods", "--ignore-methods",
], ],
"match_headers": [ "match_headers": [
"ServoBindingList.h", "ServoBindingList.h",
@ -269,61 +271,67 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
sys.stdout.flush() sys.stdout.flush()
flags = [] flags = []
flags.extend(platform_dependent_defines())
if "flags" in current_target: if "flags" in current_target:
flags.extend(current_target["flags"]) 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: if "raw_lines" in current_target:
for raw_line in current_target["raw_lines"]: for raw_line in current_target["raw_lines"]:
flags.append("-raw-line") flags.append("--raw-line")
flags.append(raw_line) flags.append(raw_line)
if "search_dirs" in current_target: if "search_dirs" in current_target:
for dir_name in current_target["search_dirs"]: for dir_name in current_target["search_dirs"]:
flags.append("-I") clang_flags.append("-I")
flags.append(dir_name.format(objdir)) clang_flags.append(dir_name.format(objdir))
if "includes" in current_target: if "includes" in current_target:
for file_name in current_target["includes"]: for file_name in current_target["includes"]:
flags.append("-include") clang_flags.append("-include")
flags.append(file_name.format(objdir)) clang_flags.append(file_name.format(objdir))
if "match_headers" in current_target: if "match_headers" in current_target:
for header in current_target["match_headers"]: for header in current_target["match_headers"]:
flags.append("-match") flags.append("--match")
flags.append(header.format(objdir)) flags.append(header.format(objdir))
if "blacklist" in current_target: if "blacklist" in current_target:
for ty in current_target["blacklist"]: for ty in current_target["blacklist"]:
flags.append("-blacklist-type") flags.append("--blacklist-type")
flags.append(ty) flags.append(ty)
if "opaque_types" in current_target: if "opaque_types" in current_target:
for ty in current_target["opaque_types"]: for ty in current_target["opaque_types"]:
flags.append("-opaque-type") flags.append("--opaque-type")
flags.append(ty) flags.append(ty)
if "void_types" in current_target: if "void_types" in current_target:
for ty in current_target["void_types"]: for ty in current_target["void_types"]:
flags.append("-raw-line") flags.append("--raw-line")
flags.append("pub enum {} {{}}".format(ty)) flags.append("pub enum {} {{}}".format(ty))
if "servo_arc_types" in current_target: if "servo_arc_types" in current_target:
for ty in current_target["servo_arc_types"]: for ty in current_target["servo_arc_types"]:
flags.append("-blacklist-type") flags.append("--blacklist-type")
flags.append("{}Strong".format(ty)) 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("pub type {0}Strong = ::sugar::refptr::Strong<{0}>;".format(ty))
flags.append("-blacklist-type") flags.append("-blacklist-type")
flags.append("{}Borrowed".format(ty)) 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)) flags.append("pub type {0}Borrowed<'a> = ::sugar::refptr::Borrowed<'a, {0}>;".format(ty))
if "structs_types" in current_target: if "structs_types" in current_target:
for ty in current_target["structs_types"]: for ty in current_target["structs_types"]:
ty_fragments = ty.split("::") ty_fragments = ty.split("::")
mangled_name = ty.replace("::", "_") mangled_name = ty.replace("::", "_")
flags.append("-blacklist-type") flags.append("--blacklist-type")
flags.append(ty_fragments[-1]) flags.append(ty_fragments[-1])
flags.append("-raw-line") flags.append("--raw-line")
if len(ty_fragments) > 1: if len(ty_fragments) > 1:
flags.append("use structs::{} as {};".format(mangled_name, ty_fragments[-1])) flags.append("use structs::{} as {};".format(mangled_name, ty_fragments[-1]))
else: else:
@ -332,11 +340,11 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
# hardcoding everything... # hardcoding everything...
if ty_fragments[-1].startswith("nsStyle"): if ty_fragments[-1].startswith("nsStyle"):
flags.extend([ flags.extend([
"-raw-line", "--raw-line",
"unsafe impl Send for {} {{}}".format(ty_fragments[-1]), "unsafe impl Send for {} {{}}".format(ty_fragments[-1]),
"-raw-line", "--raw-line",
"unsafe impl Sync for {} {{}}".format(ty_fragments[-1]), "unsafe impl Sync for {} {{}}".format(ty_fragments[-1]),
"-raw-line", "--raw-line",
"impl HeapSizeOf for {} {{ fn heap_size_of_children(&self) -> usize {{ 0 }} }}" "impl HeapSizeOf for {} {{ fn heap_size_of_children(&self) -> usize {{ 0 }} }}"
.format(ty_fragments[-1]) .format(ty_fragments[-1])
]) ])
@ -346,9 +354,9 @@ def build(objdir, target_name, debug, debugger, kind_name=None,
# TODO: support more files, that's the whole point of this. # TODO: support more files, that's the whole point of this.
assert len(current_target["files"]) == 1 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 = "" output = ""
try: try: