From 9eea2be09eff1432da971c9e156ea00a09f94dd9 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Tue, 19 Jul 2016 09:57:27 +1000 Subject: [PATCH] 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. --- ports/geckolib/gecko_bindings/tools/regen.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ports/geckolib/gecko_bindings/tools/regen.py b/ports/geckolib/gecko_bindings/tools/regen.py index a4c2dde4d51..eebe31305fc 100755 --- a/ports/geckolib/gecko_bindings/tools/regen.py +++ b/ports/geckolib/gecko_bindings/tools/regen.py @@ -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)