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 670546 195ec9dc9880840133a61ed4dcd0dbff95710da5
parent 670404 bc56729898954e32d3a3731d03d178ed78924c33
child 733267 928abee4244d0cb6abcbc575674cbc70171bfe80
push id81666
push userbmo:giles@thaumas.net
push dateTue, 26 Sep 2017 16:10:41 +0000
reviewersgps
bugs1366564
milestone58.0a1
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. MozReview-Commit-ID: 2epqGWVA3x9
toolkit/moz.configure
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -661,16 +661,36 @@ 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':
+            try:
+                subprocess.check_output(['pkgutil', '--pkg-info', 'com.apple.pkg.CLTools_Executables'])
+            except subprocess.CalledProcessError:
+                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
         output.'''
         lines = check_cmd_output(llvm_config, *options).splitlines()
         return lines[0]
 
     @imports(_from='textwrap', _import='dedent')
     def check_minimum_llvm_config_version(llvm_config):