OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import filecmp | 5 import filecmp |
6 import gyp.common | 6 import gyp.common |
7 import gyp.xcodeproj_file | 7 import gyp.xcodeproj_file |
8 import errno | 8 import errno |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 473 |
474 except Exception: | 474 except Exception: |
475 # Don't leave turds behind. In fact, if this code was responsible for | 475 # Don't leave turds behind. In fact, if this code was responsible for |
476 # creating the xcodeproj directory, get rid of that too. | 476 # creating the xcodeproj directory, get rid of that too. |
477 os.unlink(new_pbxproj_path) | 477 os.unlink(new_pbxproj_path) |
478 if self.created_dir: | 478 if self.created_dir: |
479 shutil.rmtree(self.path, True) | 479 shutil.rmtree(self.path, True) |
480 raise | 480 raise |
481 | 481 |
482 | 482 |
483 cached_xcode_version = None | |
484 def InstalledXcodeVersion(): | |
485 """Fetches the installed version of Xcode, returns empty string if it is | |
486 unable to figure it out.""" | |
487 | |
488 global cached_xcode_version | |
489 if not cached_xcode_version is None: | |
490 return cached_xcode_version | |
491 | |
492 # Default to an empty string | |
493 cached_xcode_version = '' | |
494 | |
495 # Collect the xcodebuild's version information. | |
496 try: | |
497 import subprocess | |
498 cmd = ['/usr/bin/xcodebuild', '-version'] | |
499 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) | |
500 xcodebuild_version_info = proc.communicate()[0] | |
501 # Any error, return empty string | |
502 if proc.returncode: | |
503 xcodebuild_version_info = '' | |
504 except OSError: | |
505 # We failed to launch the tool | |
506 xcodebuild_version_info = '' | |
507 | |
508 # Pull out the Xcode version itself. | |
509 match_line = re.search('^Xcode (.*)$', xcodebuild_version_info, re.MULTILINE) | |
510 if match_line: | |
511 cached_xcode_version = match_line.group(1) | |
512 # Done! | |
513 return cached_xcode_version | |
514 | |
515 | |
516 def AddSourceToTarget(source, type, pbxp, xct): | 483 def AddSourceToTarget(source, type, pbxp, xct): |
517 # TODO(mark): Perhaps source_extensions and library_extensions can be made a | 484 # TODO(mark): Perhaps source_extensions and library_extensions can be made a |
518 # little bit fancier. | 485 # little bit fancier. |
519 source_extensions = ['c', 'cc', 'cpp', 'cxx', 'm', 'mm', 's'] | 486 source_extensions = ['c', 'cc', 'cpp', 'cxx', 'm', 'mm', 's'] |
520 | 487 |
521 # .o is conceptually more of a "source" than a "library," but Xcode thinks | 488 # .o is conceptually more of a "source" than a "library," but Xcode thinks |
522 # of "sources" as things to compile and "libraries" (or "frameworks") as | 489 # of "sources" as things to compile and "libraries" (or "frameworks") as |
523 # things to link with. Adding an object file to an Xcode target's frameworks | 490 # things to link with. Adding an object file to an Xcode target's frameworks |
524 # phase works properly. | 491 # phase works properly. |
525 library_extensions = ['a', 'dylib', 'framework', 'o'] | 492 library_extensions = ['a', 'dylib', 'framework', 'o'] |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 | 1203 |
1237 for build_file in build_files: | 1204 for build_file in build_files: |
1238 xcode_projects[build_file].Finalize1(xcode_targets, serialize_all_tests) | 1205 xcode_projects[build_file].Finalize1(xcode_targets, serialize_all_tests) |
1239 | 1206 |
1240 for build_file in build_files: | 1207 for build_file in build_files: |
1241 xcode_projects[build_file].Finalize2(xcode_targets, | 1208 xcode_projects[build_file].Finalize2(xcode_targets, |
1242 xcode_target_to_target_dict) | 1209 xcode_target_to_target_dict) |
1243 | 1210 |
1244 for build_file in build_files: | 1211 for build_file in build_files: |
1245 xcode_projects[build_file].Write() | 1212 xcode_projects[build_file].Write() |
OLD | NEW |