Bug 1368083 - Pass -isysroot to bindgen. r=gps draft
authorRalph Giles <giles@mozilla.com>
Thu, 06 Jul 2017 11:34:03 -0700
changeset 605605 04442951d5c978d95a91b097849d9d8cda335178
parent 605583 06c1a0dc0fd8719ffa2d9aa2de75f32de5657102
child 605628 2d327e6e4db9400da954a6af2323f6307d0cb066
child 605629 b04a2c37e9aebb21bdcc448e35baa858fd657119
push id67468
push userbmo:giles@thaumas.net
push dateSat, 08 Jul 2017 04:06:41 +0000
reviewersgps
bugs1368083
milestone56.0a1
Bug 1368083 - Pass -isysroot to bindgen. r=gps When cross-compiling, rust-bindgen needs the -isysroot flag we pass to the C++ compiler to find the correct headers. Add a new BINDGEN_CFLAGS environment variable for passing this and other relevant options, and reformat its contents in toolchain.configure so we can use autoconf- style template substitution to poke it into a bindgen.toml file to be read by build scripts like build_gecko.rs. Set this variable from the macosx/cross-mozconfig.common to the same extra flags we pass to CXX so automation builds work correctly with --enable-stylo. MozReview-Commit-ID: 7wabObiFtVb
build/macosx/cross-mozconfig.common
build/moz.configure/toolchain.configure
layout/style/bindgen.toml.in
layout/style/moz.build
--- a/build/macosx/cross-mozconfig.common
+++ b/build/macosx/cross-mozconfig.common
@@ -24,16 +24,17 @@ CROSS_SYSROOT=$topsrcdir/MacOSX10.7.sdk
 CROSS_PRIVATE_FRAMEWORKS=$CROSS_SYSROOT/System/Library/PrivateFrameworks
 FLAGS="-target x86_64-apple-darwin11 -B $CROSS_CCTOOLS_PATH/bin -isysroot $CROSS_SYSROOT"
 
 export CC="$topsrcdir/clang/bin/clang $FLAGS"
 export CXX="$topsrcdir/clang/bin/clang++ $FLAGS"
 export CPP="$topsrcdir/clang/bin/clang $FLAGS -E"
 export LLVMCONFIG=$topsrcdir/clang/bin/llvm-config
 export LDFLAGS="-Wl,-syslibroot,$CROSS_SYSROOT -Wl,-dead_strip"
+export BINDGEN_CFLAGS="$FLAGS"
 export TOOLCHAIN_PREFIX=$CROSS_CCTOOLS_PATH/bin/x86_64-apple-darwin11-
 export DSYMUTIL=$topsrcdir/clang/bin/llvm-dsymutil
 export MKFSHFS=$topsrcdir/hfsplus-tools/newfs_hfs
 export DMG_TOOL=$topsrcdir/dmg/dmg
 export HFS_TOOL=$topsrcdir/dmg/hfsplus
 
 export HOST_CC="$topsrcdir/clang/bin/clang"
 export HOST_CXX="$topsrcdir/clang/bin/clang++"
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -892,16 +892,30 @@ 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.')
 
+option(env='BINDGEN_CFLAGS',
+       nargs=1,
+       help='Options bindgen should pass to the C/C++ parser')
+
+@depends('BINDGEN_CFLAGS')
+@checking('bindgen cflags', lambda s: s if s and s.strip() else 'no')
+def bindgen_cflags(value):
+    if value and len(value):
+        # Reformat the env value for substitution into a toml list.
+        flags = value[0].split()
+        return ', '.join('"' + flag + '"' for flag in flags)
+    return ''
+
+set_config('BINDGEN_CFLAGS', bindgen_cflags)
 
 @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_CFLAGS@
+]
--- 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',
+    ]