Bug 1366564 - Check for Xcode command line tools. r?gps draft
authorRalph Giles <giles@mozilla.com>
Tue, 26 Sep 2017 08:41:18 -0700
changeset 670539 c4bef90386a18f4d59487c78ca6a6619c7209a33
parent 670404 bc56729898954e32d3a3731d03d178ed78924c33
child 733261 de5e09419ee868077ec39116c54314a308c68c83
push id81660
push userbmo:giles@thaumas.net
push dateTue, 26 Sep 2017 15:53:59 +0000
Bug 1366564 - Check for Xcode command line tools. r?gps Bindgen requires the system headers in the standard location in /usr/include while Apple's default Xcode install has clang looking directly in the default SDK. A more standard environment can be provided by running `xcode-select --install`. When running on darwin, ask pkgutil if the command line tools have been installed, and suggest them if they're not. On success, this logs the pkginfo output, which isn't ideal. MozReview-Commit-ID: 2epqGWVA3x9
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -661,16 +661,34 @@ llvm_config = check_prog('LLVM_CONFIG', 
                          what='llvm-config', allow_missing=True)
 with only_when(building_stylo_bindgen):
     option('--with-libclang-path', nargs=1,
            help='Absolute path to a directory containing Clang/LLVM libraries for Stylo (version 3.9.x or above)')
     option('--with-clang-path', nargs=1,
            help='Absolute path to a Clang binary for Stylo bindgen (version 3.9.x or above)')
+    @depends(host)
+    @imports('subprocess')
+    @imports(_from='textwrap', _import='dedent')
+    def system_headers_installed(host):
+        '''Check if Xcode's system headers are installed in /usr/include.'''
+        if host.kernel == 'Darwin':
+            if subprocess.check_call(['pkgutil', '--pkg-info', 'com.apple.pkg.CLTools_Executables']):
+                die(dedent('''\
+                Xcode command line tools aren't installed.
+                This is necessary for bindgen to work properly, in particular
+                to have system headers available in /usr/include. Please make
+                sure your Xcode is up to date, then try running
+                  xcode-select --install
+                to install the command line environment.'''))
     def invoke_llvm_config(llvm_config, *options):
         '''Invoke llvm_config with the given options and return the first line of
         lines = check_cmd_output(llvm_config, *options).splitlines()
         return lines[0]
     @imports(_from='textwrap', _import='dedent')
     def check_minimum_llvm_config_version(llvm_config):