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
--- 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):