Use Cargo to run bindgen when possible

Cargo would take care of stuff like library injecting, so that it works
cross platform. This is necessary for Windows because Windows doesn't
have things like LD_LIBRARY_PATH env var.
This commit is contained in:
Xidorn Quan 2016-07-19 09:57:27 +10:00
parent 81ccbac103
commit 9eea2be09e

View file

@ -125,9 +125,6 @@ COMPILATION_TARGETS = {
"nsMainThreadPtrHolder", "nscolor", "nsFont", "FontFamilyList",
"FontFamilyType", "nsIAtom",
],
"void_types": [
"nsINode", "nsIDocument", "nsIPrincipal", "nsIURI",
]
}
}
@ -178,7 +175,13 @@ def build(objdir, target_name, kind_name=None,
(kind_name in current_target["build_kinds"]))
if bindgen is None:
bindgen = "{}/rust-bindgen/target/debug/bindgen".format(TOOLS_DIR)
bindgen = os.path.join(TOOLS_DIR, "rust-bindgen")
if os.path.isdir(bindgen):
bindgen = ["cargo", "run", "--manifest-path",
os.path.join(bindgen, "Cargo.toml"), "--"]
else:
bindgen = [bindgen]
if output_filename is None:
filename = "{}.rs".format(target_name)
@ -266,7 +269,7 @@ def build(objdir, target_name, kind_name=None,
assert len(current_target["files"]) == 1
flags.append(current_target["files"][0].format(objdir))
flags.insert(0, bindgen)
flags = bindgen + flags
output = None
try:
output = subprocess.check_output(flags, stderr=subprocess.STDOUT)