Commit e228b0ee authored by thakis@chromium.org's avatar thakis@chromium.org

mac: Let mac_sdk default to the oldest available SDK that's at least 10.6

Having to manually set mac_sdk was a FAQ when Xcode 4 was released. Now
we're using the 10.6 SDK by default, but Xcode 4.4 ships only with the
10.7 and 10.8 SDKs, so it'll likely become a FAQ again. Automatically
set mac_sdk to something sensible.

(People who explicitly say "mac_sdk=10.6" will have to stop doing so
when they switch to Xcode 4.4.)

BUG=121162
TEST=Build without mac_sdk in GYP_DEFINES. Something useful happens
with Xcode 3.2.6, Xcode 4, Xcode 4.4.


Review URL: https://chromiumcodereview.appspot.com/10824055

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148817 0039d316-1c4b-4281-b951-d872f2087c98
parent 7439a0dd
......@@ -645,7 +645,7 @@
# these defaults. If the SDK is installed someplace that Xcode doesn't
# know about, set mac_sdk_path to the path to the SDK. If set to a
# non-empty string, mac_sdk_path will be used in preference to mac_sdk.
'mac_sdk%': '10.6',
# mac_sdk gets its default value elsewhere in this file.
'mac_sdk_path%': '',
'mac_deployment_target%': '10.5',
......@@ -1020,6 +1020,7 @@
}],
['branding=="Chrome" and buildtype=="Official"', {
'mac_sdk%': '10.6',
# Enable uploading crash dumps.
'mac_breakpad_uploads%': 1,
# Enable dumping symbols at build time for use by Mac Breakpad.
......@@ -1027,6 +1028,7 @@
# Enable Keystone auto-update support.
'mac_keystone%': 1,
}, { # else: branding!="Chrome" or buildtype!="Official"
'mac_sdk%': '<!(python mac/find_sdk.py 10.6)',
'mac_breakpad_uploads%': 0,
'mac_breakpad%': 0,
'mac_keystone%': 0,
......
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import re
import subprocess
import sys
"""Prints the lowest locally available SDK version greater than or equal to a
given minimum sdk version to standard output.
Usage:
python find_sdk.py 10.6 # Ignores SDKs < 10.6
"""
def parse_version(version_str):
"""'10.6' => [10, 6]"""
return map(int, re.findall(r'(\d+)', version_str))
def main(min_sdk_version):
job = subprocess.Popen(['xcode-select', '-print-path'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
out, err = job.communicate()
if job.returncode != 0:
print >>sys.stderr, out
print >>sys.stderr, err
raise Exception(('Error %d running xcode-select, you might have to run '
'|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
'if you are using Xcode 4.') % job.returncode)
# The Developer folder moved in Xcode 4.3.
xcode43_sdk_path = os.path.join(
out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs')
if os.path.isdir(xcode43_sdk_path):
sdk_dir = xcode43_sdk_path
else:
sdk_dir = os.path.join(out.rstrip(), 'SDKs')
sdks = [re.findall('^MacOSX(10\.\d+)\.sdk$', s) for s in os.listdir(sdk_dir)]
sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6']
sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6']
if parse_version(s) >= parse_version(min_sdk_version)]
if not sdks:
raise Exception('No %s+ SDK found' % min_sdk_version)
print sorted(sdks, key=parse_version)[0]
if __name__ == '__main__':
if sys.platform != 'darwin':
raise Exception("This script only runs on Mac")
main(min_sdk_version=sys.argv[1])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment