From 63403bb0dfc6faf14fea35afcd7012a4ded7d443 Mon Sep 17 00:00:00 2001 From: Mike Shal Date: Fri, 12 Apr 2019 19:00:13 +0000 Subject: [PATCH] Bug 1522931 - always check the OSX SDK version; r=firefox-build-system-reviewers,chmanchester Bug 1500504 added a version check for the SDK, but it only does the check if --with-macos-sdk is used. We should also check the version when using the default SDK. Note that this means we now set MACOS_SDK_DIR to be the default SDK even if it wasn't set explicitly from --with-macos-sdk Differential Revision: https://phabricator.services.mozilla.com/D17727 --HG-- extra : moz-landing-system : lando --- build/moz.configure/toolchain.configure | 39 ++++++++++++++++++------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index c26a50e72c82..75aab8989008 100755 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -126,26 +126,45 @@ with only_when(target_is_osx): # MacOS SDK # ========= - option('--with-macos-sdk', env='MACOS_SDK_DIR', nargs=1, - help='Location of platform SDK to use') + js_option('--with-macos-sdk', env='MACOS_SDK_DIR', nargs=1, + help='Location of platform SDK to use') - @depends_if('--with-macos-sdk') + @depends('--with-macos-sdk') @imports(_from='os.path', _import='isdir') - @imports(_from='plistlib', _import='readPlist') + @imports(_from='biplist', _import='readPlist') + @imports('subprocess') + @imports('which') def macos_sdk(value): sdk_min_version = Version('10.11') sdk_max_version = Version('10.13') - if not isdir(value[0]): + sdk_path = None + if value: + sdk_path = value[0] + else: + try: + xcrun = which.which('xcrun') + args = [xcrun, '--sdk', 'macosx', '--show-sdk-path'] + sdk_path = subprocess.check_output(args).strip() + except which.WhichError: + # On a Linux cross-compile, we don't have xcrun, so just leave + # the SDK unset if --with-macos-sdk isn't specified. + pass + + if not sdk_path: + return + + if not isdir(sdk_path): die('SDK not found in %s. When using --with-macos-sdk, you must specify a ' 'valid SDK. SDKs are installed when the optional cross-development ' 'tools are selected during the Xcode/Developer Tools installation.' - % value[0]) - obj = readPlist(os.path.join(value[0], 'SDKSettings.plist')) + % sdk_path) + obj = readPlist(os.path.join(sdk_path, 'SDKSettings.plist')) if not obj: - die('Error parsing SDKSettings.plist in the SDK directory: %s' % value[0]) + die('Error parsing SDKSettings.plist in the SDK directory: %s' % sdk_path) if 'Version' not in obj: - die('Error finding Version information in SDKSettings.plist from the SDK: %s' % value[0]) + die('Error finding Version information in SDKSettings.plist from the ' + 'SDK: %s' % sdk_path) version = Version(obj['Version']) if version < sdk_min_version: die('SDK version "%s" is too old. Please upgrade to at least %s. ' @@ -157,7 +176,7 @@ with only_when(target_is_osx): '%s. You may need to point to it using --with-macos-sdk= in ' 'your mozconfig. Various SDK versions are available from ' 'https://github.com/phracker/MacOSX-SDKs' % (version, sdk_max_version)) - return value[0] + return sdk_path set_config('MACOS_SDK_DIR', macos_sdk)