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,56 @@ 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)
+def host_is_mac(host):
+ return host.kernel == 'Darwin'
+
+@depends(host, '--disable-xcode-checks')
+def xcode_command_line_tools(host, xcode_checks):
+ if host.kernel != 'Darwin' or not xcode_checks:
+ return
+
+ def bad_xcode_select():
+ die('Could not find installed Xcode; run Xcode.app to ensure '
+ 'initial Xcode configuration is performed')
+
+ # xcode-select -p prints the path to the installed Xcode. It
+ # should exit 0 and return non-empty result if Xcode is installed.
+ res = check_cmd_output('xcode-select', '--print-path',
+ onerror=bad_xcode_select)
+
+ if not res.strip():
+ 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` to install them')
+
+ res = check_cmd_output('pkgutil', '--pkg-info',
+ 'com.apple.pkg.CLTools_Executables',
+ onerror=no_cltools)
+
+ return res
+
+set_config('XCODE_CLTOOLS_PATH', xcode_command_line_tools)
+
# 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,