Bug 1368083 - Pass -isysroot to bindgen. r?ted draft
authorRalph Giles <giles@mozilla.com>
Thu, 06 Jul 2017 11:34:03 -0700
changeset 604934 fb6ebaac8581c78f4dc2463aa70c64293e3a88b1
parent 604923 d373f8a1ba8f36a26498fc9d221f7a32d9931dc8
child 604935 063447b50997584df5483906f03c9aca90e472ee
push id67241
push userbmo:giles@thaumas.net
push dateThu, 06 Jul 2017 18:45:34 +0000
reviewersted
bugs1368083
milestone56.0a1
Bug 1368083 - Pass -isysroot to bindgen. r?ted When cross-compiling, rust-bindgen needs the -isysroot flag we pass to the C++ compiler to find the correct headers. Extract this from the compiler command line and add it to an override file read by build_gecko.rs. This is a bit hacky, as configure has to format the argument list as a string to use the configure template substitution method, but without a more sophisticated interface between moz.build and bindgen this is the simplest approach. MozReview-Commit-ID: 7wabObiFtVb
build/moz.configure/toolchain.configure
layout/style/bindgen.toml.in
layout/style/moz.build
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -892,16 +892,29 @@ include('compile-checks.configure')
 @depends(have_64_bit,
          try_compile(body='static_assert(sizeof(void *) == 8, "")',
                      check_msg='for 64-bit OS'))
 def check_have_64_bit(have_64_bit, compiler_have_64_bit):
     if have_64_bit != compiler_have_64_bit:
         configure_error('The target compiler does not agree with configure '
                         'about the target bitness.')
 
+@depends(cxx_compiler)
+@checking('bindgen flags')
+def bindgen_flags(compiler):
+    # Export relevant CXX flags so we can pass them to bindgen.
+    args = compiler.flags
+    try:
+        index = args.index(u'-isysroot')
+        return '"%s", "%s",' % (args[index], args[index + 1])
+    except:
+        log.warning('sysroot not found!')
+        return ''
+
+set_config('BINDGEN_FLAGS', bindgen_flags)
 
 @depends(c_compiler)
 def default_debug_flags(compiler_info):
     # Debug info is ON by default.
     if compiler_info.type in ('msvc', 'clang-cl'):
         return '-Zi'
     return '-g'
 
new file mode 100644
--- /dev/null
+++ b/layout/style/bindgen.toml.in
@@ -0,0 +1,4 @@
+[build]
+args = [
+    @BINDGEN_FLAGS@
+]
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -310,8 +310,12 @@ if CONFIG['COMPILE_ENVIRONMENT']:
         'nsCSSPropsGenerated.inc',
     ]
     css_props = GENERATED_FILES['nsCSSPropsGenerated.inc']
     css_props.script = 'GenerateCSSPropsGenerated.py:generate'
     css_props.inputs = [
         'nsCSSPropsGenerated.inc.in',
         'PythonCSSProps.h',
     ]
+
+    CONFIGURE_SUBST_FILES += [
+        'bindgen.toml',
+    ]