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

Unified Diff: tools/gyp/find_mac_gcc_version.py

Issue 12494015: Automatically determine the gcc compiler to use based on XCode version (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
« no previous file with comments | « tools/gyp/configurations_xcode.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gyp/find_mac_gcc_version.py
diff --git a/tools/gyp/find_mac_gcc_version.py b/tools/gyp/find_mac_gcc_version.py
new file mode 100755
index 0000000000000000000000000000000000000000..7a2221b0e9c489dd1f22ecae82a99c0f0b4013fd
--- /dev/null
+++ b/tools/gyp/find_mac_gcc_version.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+import re
+import subprocess
+import sys
+
+def main():
+ job = subprocess.Popen(['xcodebuild', '-version'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ stdout, stderr = job.communicate()
+ if job.returncode != 0:
+ print >>sys.stderr, stdout
+ print >>sys.stderr, stderr
+ raise Exception('Error %d running xcodebuild!' % job.returncode)
+ matches = re.findall('^Xcode (\d+)\.(\d+)\.(\d+)$', stdout, re.MULTILINE)
+ if len(matches) > 0:
+ major = int(matches[0][0])
+ minor = int(matches[0][1])
+
+ if major >= 4:
+ return 'com.apple.compilers.llvmgcc42'
+ elif major == 3 and minor >= 1:
+ return '4.2'
+ else:
+ raise Exception('Unknown XCode Version "%s"' % version_match)
+ else:
+ raise Exception('Could not parse output of xcodebuild "%s"' % stdout)
+
+if __name__ == '__main__':
+ if sys.platform != 'darwin':
+ raise Exception("This script only runs on Mac")
+ print main()
« no previous file with comments | « tools/gyp/configurations_xcode.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698