Bug 1366564 - Validate Xcode installation state in configure; r?rillian draft
authorGregory Szorc <gps@mozilla.com>
Tue, 26 Sep 2017 18:05:20 +0200
changeset 670545 5e8d1d984013ceab7e2a93837aa43166e81b488d
parent 670404 bc56729898954e32d3a3731d03d178ed78924c33
child 733266 2ca5c6eb95129b814c056c5a7ad24df1e2ba0dd4
push id81665
push usergszorc@mozilla.com
push dateTue, 26 Sep 2017 16:05:50 +0000
reviewersrillian
bugs1366564
milestone58.0a1
Bug 1366564 - Validate Xcode installation state in configure; r?rillian MozReview-Commit-ID: 9dNuGqaqZyU
build/moz.configure/toolchain.configure
--- 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,