Bug 1366564 - Validate Xcode installation state in configure; r?rillian
MozReview-Commit-ID: 9dNuGqaqZyU
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -88,16 +88,58 @@ def macos_target(value, target):
if value and value.origin != 'default':
die('--enable-macos-target cannot be used when targeting %s',
target.os)
set_config('MACOSX_DEPLOYMENT_TARGET', macos_target)
add_old_configure_assignment('MACOSX_DEPLOYMENT_TARGET', macos_target)
+# Xcode state
+# ===========
+
+option('--disable-xcode-checks',
+ help='Do not check that Xcode is installed and properly configured')
+
+@depends(host, '--disable-xcode-checks')
+def xcode_path(host, xcode_checks):
+ if host.kernel != 'Darwin' or not xcode_checks:
+ return
+
+ # xcode-select -p prints the path to the installed Xcode. It
+ # should exit 0 and return non-empty result if Xcode is installed.
+
+ def bad_xcode_select():
+ die('Could not find installed Xcode; install Xcode from the App '
+ 'Store, run it once to perform initial configuration, and then '
+ 'try again; in the rare case you wish to build without Xcode '
+ 'installed, add the --disable-xcode-checks configure flag')
+
+ xcode_path = check_cmd_output('xcode-select', '--print-path',
+ onerror=bad_xcode_select).strip()
+
+ if not xcode_path:
+ bad_xcode_select()
+
+ # Now look for the Command Line Tools.
+ def no_cltools():
+ die('Could not find installed Xcode Command Line Tools; '
+ 'run `xcode-select --install` and follow the instructions '
+ 'to install them then try again; if you wish to build without '
+ 'Xcode Command Line Tools installed, '
+ 'add the --disable-xcode-checks configure flag')
+
+ res = check_cmd_output('pkgutil', '--pkg-info',
+ 'com.apple.pkg.CLTools_Executables',
+ onerror=no_cltools)
+
+ return xcode_path
+
+set_config('XCODE_PATH', xcode_path)
+
# Compiler wrappers
# ==============================================================
# Normally, we'd use js_option and automatically have those variables
# propagated to js/src, but things are complicated by possible additional
# wrappers in CC/CXX, and by other subconfigures that do not handle those
# options and do need CC/CXX altered.
option('--with-compiler-wrapper', env='COMPILER_WRAPPER', nargs=1,