Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Unified Diff: build/mac/find_sdk.py

Issue 10824055: mac: Let mac_sdk default to the oldest available SDK that's at least 10.6 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bots Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« build/common.gypi ('K') | « build/common.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/mac/find_sdk.py
diff --git a/build/mac/find_sdk.py b/build/mac/find_sdk.py
new file mode 100644
index 0000000000000000000000000000000000000000..45c636507570a0649f0a691f7a37d9fd3b498579
--- /dev/null
+++ b/build/mac/find_sdk.py
@@ -0,0 +1,39 @@
+#!/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 best locally available SDK version to standard output."""
+
+
+def main():
+ job = subprocess.Popen(['xcode-select', '-print-path'],
Mark Mentovai 2012/07/27 03:31:30 Didn’t we find that xcode-select wouldn’t be initi
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ out, err = job.communicate()
+ if job.returncode != 0:
+ print out
Mark Mentovai 2012/07/27 03:31:30 Wouldn’t you especially want to print err (to stde
Nico 2012/07/27 18:01:05 Done.
+ raise Exception('Error %d running xcode-select' % 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)]
Mark Mentovai 2012/07/27 03:31:30 Do you want to anchor the RE at the front and back
Mark Mentovai 2012/07/27 03:31:30 Something in os.listdir(sdk_dir) that doesn’t matc
Nico 2012/07/27 18:01:05 Done.
Nico 2012/07/27 18:01:05 Yes.
+ sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6']
+ sdks = [s for s in sdks if s >= '10.6'] # ['10.5', '10.6'] => ['10.6]
Mark Mentovai 2012/07/27 03:31:30 Missing a ' on ['10.6].
Mark Mentovai 2012/07/27 03:31:30 This isn’t really the greatest version comparison.
Nico 2012/07/27 18:01:05 Done.
Nico 2012/07/27 18:01:05 Done.
+ if not sdks:
+ raise Exception('No 10.6+ SDK found')
+ print sdks[0]
Mark Mentovai 2012/07/27 03:31:30 Is there any guarantee of sortedness of SDKs? I do
Nico 2012/07/27 18:01:05 Done.
+
+
+if __name__ == '__main__':
+ if sys.platform == 'darwin':
Mark Mentovai 2012/07/27 03:31:30 If you’re going to be conditionalizing when you ca
Nico 2012/07/27 18:01:05 I think it's easier this way.
+ main()
« build/common.gypi ('K') | « build/common.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698