Bug 1366564 - Validate Xcode installation state in configure; r?rillian draft
authorGregory Szorc <gps@mozilla.com>
Tue, 26 Sep 2017 19:56:38 +0200
changeset 670698 081a2deadc8216a4fae501fdb7592dfd22cd41f0
parent 670404 bc56729898954e32d3a3731d03d178ed78924c33
child 733281 8875ebea7b281f97320a9426ea5d9fe1d8c01a90
push id81680
push usergszorc@mozilla.com
push dateTue, 26 Sep 2017 17:57:27 +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,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,