Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2010 Google Inc. All rights reserved. | 3 # Copyright (c) 2010 Google Inc. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import filecmp | 7 import filecmp |
| 8 import gyp.common | 8 import gyp.common |
| 9 import gyp.xcodeproj_file | 9 import gyp.xcodeproj_file |
| 10 import errno | 10 import errno |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 'RULE_INPUT_NAME': '$(INPUT_FILE_NAME)', | 52 'RULE_INPUT_NAME': '$(INPUT_FILE_NAME)', |
| 53 'RULE_INPUT_PATH': '$(INPUT_FILE_PATH)', | 53 'RULE_INPUT_PATH': '$(INPUT_FILE_PATH)', |
| 54 'SHARED_INTERMEDIATE_DIR': '$(%s)' % _shared_intermediate_var, | 54 'SHARED_INTERMEDIATE_DIR': '$(%s)' % _shared_intermediate_var, |
| 55 'CONFIGURATION_NAME': '$(CONFIGURATION)', | 55 'CONFIGURATION_NAME': '$(CONFIGURATION)', |
| 56 } | 56 } |
| 57 | 57 |
| 58 # The Xcode-specific sections that hold paths. | 58 # The Xcode-specific sections that hold paths. |
| 59 generator_additional_path_sections = [ | 59 generator_additional_path_sections = [ |
| 60 'mac_bundle_resources', | 60 'mac_bundle_resources', |
| 61 'mac_framework_headers', | 61 'mac_framework_headers', |
| 62 'mac_framework_private_headers', | |
| 62 # 'mac_framework_dirs', input already handles _dirs endings. | 63 # 'mac_framework_dirs', input already handles _dirs endings. |
| 63 ] | 64 ] |
| 64 | 65 |
| 65 # The Xcode-specific keys that exist on targets and aren't moved down to | 66 # The Xcode-specific keys that exist on targets and aren't moved down to |
| 66 # configurations. | 67 # configurations. |
| 67 generator_additional_non_configuration_keys = [ | 68 generator_additional_non_configuration_keys = [ |
| 68 'mac_bundle', | 69 'mac_bundle', |
| 69 'mac_bundle_resources', | 70 'mac_bundle_resources', |
| 70 'mac_framework_headers', | 71 'mac_framework_headers', |
| 72 'mac_framework_private_headers', | |
| 71 'xcode_create_dependents_test_runner', | 73 'xcode_create_dependents_test_runner', |
| 72 ] | 74 ] |
| 73 | 75 |
| 74 # We want to let any rules apply to files that are resources also. | 76 # We want to let any rules apply to files that are resources also. |
| 75 generator_extra_sources_for_rules = [ | 77 generator_extra_sources_for_rules = [ |
| 76 'mac_bundle_resources', | 78 'mac_bundle_resources', |
| 77 'mac_framework_headers', | 79 'mac_framework_headers', |
| 80 'mac_framework_private_headers', | |
| 78 ] | 81 ] |
| 79 | 82 |
| 80 | 83 |
| 81 def CreateXCConfigurationList(configuration_names): | 84 def CreateXCConfigurationList(configuration_names): |
| 82 xccl = gyp.xcodeproj_file.XCConfigurationList({'buildConfigurations': []}) | 85 xccl = gyp.xcodeproj_file.XCConfigurationList({'buildConfigurations': []}) |
| 83 if len(configuration_names) == 0: | 86 if len(configuration_names) == 0: |
| 84 configuration_names = ['Default'] | 87 configuration_names = ['Default'] |
| 85 for configuration_name in configuration_names: | 88 for configuration_name in configuration_names: |
| 86 xcbc = gyp.xcodeproj_file.XCBuildConfiguration({ | 89 xcbc = gyp.xcodeproj_file.XCBuildConfiguration({ |
| 87 'name': configuration_name}) | 90 'name': configuration_name}) |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 xct.FrameworksPhase().AddFile(source) | 528 xct.FrameworksPhase().AddFile(source) |
| 526 else: | 529 else: |
| 527 # Files that aren't added to a sources or frameworks build phase can still | 530 # Files that aren't added to a sources or frameworks build phase can still |
| 528 # go into the project file, just not as part of a build phase. | 531 # go into the project file, just not as part of a build phase. |
| 529 pbxp.AddOrGetFileInRootGroup(source) | 532 pbxp.AddOrGetFileInRootGroup(source) |
| 530 | 533 |
| 531 | 534 |
| 532 def AddResourceToTarget(resource, pbxp, xct): | 535 def AddResourceToTarget(resource, pbxp, xct): |
| 533 # TODO(mark): Combine with AddSourceToTarget above? Or just inline this call | 536 # TODO(mark): Combine with AddSourceToTarget above? Or just inline this call |
| 534 # where it's used. | 537 # where it's used. |
| 535 xct.ResourcesPhase().AddFile(resource) | 538 xct.ResourcesPhase().AddFile(resource, settings) |
|
Mark Mentovai
2011/03/03 16:29:38
This is wrong. What’s settings supposed to be here
abarth-chromium
2011/03/03 16:45:40
This is left-over from a previous approach. How d
| |
| 536 | 539 |
| 537 | 540 |
| 538 def AddHeaderToTarget(header, pbxp, xct): | 541 def AddHeaderToTarget(header, pbxp, xct, settings):» |
|
Mark Mentovai
2011/03/03 16:29:38
There’s a tab on this line.
abarth-chromium
2011/03/03 16:45:40
Done.
| |
| 539 # TODO(mark): Combine with AddSourceToTarget above? Or just inline this call | 542 # TODO(mark): Combine with AddSourceToTarget above? Or just inline this call» |
| 540 # where it's used. | 543 # where it's used.» |
|
Mark Mentovai
2011/03/03 16:29:38
And this one too.
abarth-chromium
2011/03/03 16:45:40
Done.
| |
| 541 xct.HeadersPhase().AddFile(header, '{ATTRIBUTES = (Public, ); }') | 544 xct.HeadersPhase().AddFile(header, settings) |
|
Mark Mentovai
2011/03/03 16:29:38
I think the interface would be easier to use if th
abarth-chromium
2011/03/03 16:45:40
Done.
| |
| 542 | 545 |
| 543 | 546 |
| 544 _xcode_variable_re = re.compile('(\$\((.*?)\))') | 547 _xcode_variable_re = re.compile('(\$\((.*?)\))') |
| 545 def ExpandXcodeVariables(string, expansions): | 548 def ExpandXcodeVariables(string, expansions): |
| 546 """Expands Xcode-style $(VARIABLES) in string per the expansions dict. | 549 """Expands Xcode-style $(VARIABLES) in string per the expansions dict. |
| 547 | 550 |
| 548 In some rare cases, it is appropriate to expand Xcode variables when a | 551 In some rare cases, it is appropriate to expand Xcode variables when a |
| 549 project file is generated. For any substring $(VAR) in string, if VAR is a | 552 project file is generated. For any substring $(VAR) in string, if VAR is a |
| 550 key in the expansions dict, $(VAR) will be replaced with expansions[VAR]. | 553 key in the expansions dict, $(VAR) will be replaced with expansions[VAR]. |
| 551 Any $(VAR) substring in string for which VAR is not a key in the expansions | 554 Any $(VAR) substring in string for which VAR is not a key in the expansions |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1045 # Add "sources". | 1048 # Add "sources". |
| 1046 for source in spec.get('sources', []): | 1049 for source in spec.get('sources', []): |
| 1047 (source_root, source_extension) = posixpath.splitext(source) | 1050 (source_root, source_extension) = posixpath.splitext(source) |
| 1048 if source_extension[1:] not in rules_by_ext: | 1051 if source_extension[1:] not in rules_by_ext: |
| 1049 # AddSourceToTarget will add the file to a root group if it's not | 1052 # AddSourceToTarget will add the file to a root group if it's not |
| 1050 # already there. | 1053 # already there. |
| 1051 AddSourceToTarget(source, pbxp, xct) | 1054 AddSourceToTarget(source, pbxp, xct) |
| 1052 else: | 1055 else: |
| 1053 pbxp.AddOrGetFileInRootGroup(source) | 1056 pbxp.AddOrGetFileInRootGroup(source) |
| 1054 | 1057 |
| 1055 # Add "mac_bundle_resources" and "mac_framework_headers" if it's a bundle | 1058 # Add "mac_bundle_resources", "mac_framework_headers", and |
| 1056 # of any type. | 1059 # "mac_framework_private_headers" if it's a bundle of any type. |
| 1057 if is_bundle: | 1060 if is_bundle: |
| 1058 for resource in tgt_mac_bundle_resources: | 1061 for resource in tgt_mac_bundle_resources: |
| 1059 (resource_root, resource_extension) = posixpath.splitext(resource) | 1062 (resource_root, resource_extension) = posixpath.splitext(resource) |
| 1060 if resource_extension[1:] not in rules_by_ext: | 1063 if resource_extension[1:] not in rules_by_ext: |
| 1061 AddResourceToTarget(resource, pbxp, xct) | 1064 AddResourceToTarget(resource, pbxp, xct) |
| 1062 else: | 1065 else: |
| 1063 pbxp.AddOrGetFileInRootGroup(resource) | 1066 pbxp.AddOrGetFileInRootGroup(resource) |
| 1064 | 1067 |
| 1065 for header in spec.get('mac_framework_headers', []): | 1068 for header in spec.get('mac_framework_headers', []): |
| 1066 AddHeaderToTarget(header, pbxp, xct) | 1069 AddHeaderToTarget(header, pbxp, xct, '{ATTRIBUTES = (Public, ); }') |
| 1070 | |
| 1071 for header in spec.get('mac_framework_private_headers', []): | |
| 1072 AddHeaderToTarget(header, pbxp, xct, '{ATTRIBUTES = (Private, ); }') | |
| 1067 | 1073 |
| 1068 # Add "copies". | 1074 # Add "copies". |
| 1069 for copy_group in spec.get('copies', []): | 1075 for copy_group in spec.get('copies', []): |
| 1070 pbxcp = gyp.xcodeproj_file.PBXCopyFilesBuildPhase({ | 1076 pbxcp = gyp.xcodeproj_file.PBXCopyFilesBuildPhase({ |
| 1071 'name': 'Copy to ' + copy_group['destination'] | 1077 'name': 'Copy to ' + copy_group['destination'] |
| 1072 }, | 1078 }, |
| 1073 parent=xct) | 1079 parent=xct) |
| 1074 dest = copy_group['destination'] | 1080 dest = copy_group['destination'] |
| 1075 if dest[0] not in ('/', '$'): | 1081 if dest[0] not in ('/', '$'): |
| 1076 # Relative paths are relative to $(SRCROOT). | 1082 # Relative paths are relative to $(SRCROOT). |
| 1077 dest = '$(SRCROOT)/' + dest | 1083 dest = '$(SRCROOT)/' + dest |
| 1078 pbxcp.SetDestination(dest) | 1084 pbxcp.SetDestination(dest) |
| 1079 | 1085 |
| 1080 # TODO(mark): The usual comment about this knowing too much about | 1086 # TODO(mark): The usual comment about this knowing too much about |
| 1081 # gyp.xcodeproj_file internals applies. | 1087 # gyp.xcodeproj_file internals applies. |
| 1082 xct._properties['buildPhases'].insert(prebuild_index, pbxcp) | 1088 xct._properties['buildPhases'].insert(prebuild_index, pbxcp) |
| 1083 | 1089 |
| 1084 for file in copy_group['files']: | 1090 for file in copy_group['files']: |
| 1085 pbxcp.AddFile(file) | 1091 pbxcp.AddFile(file) |
| 1086 | 1092 |
| 1087 # Excluded files can also go into the project file. | 1093 # Excluded files can also go into the project file. |
| 1088 if not skip_excluded_files: | 1094 if not skip_excluded_files: |
| 1089 for key in ['sources', 'mac_bundle_resources', 'mac_framework_headers']: | 1095 for key in ['sources', 'mac_bundle_resources', 'mac_framework_headers', |
| 1096 'mac_framework_private_headers']: | |
| 1090 excluded_key = key + '_excluded' | 1097 excluded_key = key + '_excluded' |
| 1091 for item in spec.get(excluded_key, []): | 1098 for item in spec.get(excluded_key, []): |
| 1092 pbxp.AddOrGetFileInRootGroup(item) | 1099 pbxp.AddOrGetFileInRootGroup(item) |
| 1093 | 1100 |
| 1094 # So can "inputs" and "outputs" sections of "actions" groups. | 1101 # So can "inputs" and "outputs" sections of "actions" groups. |
| 1095 groups = ['inputs', 'inputs_excluded', 'outputs', 'outputs_excluded'] | 1102 groups = ['inputs', 'inputs_excluded', 'outputs', 'outputs_excluded'] |
| 1096 if skip_excluded_files: | 1103 if skip_excluded_files: |
| 1097 groups = [x for x in groups if not x.endswith('_excluded')] | 1104 groups = [x for x in groups if not x.endswith('_excluded')] |
| 1098 for action in spec.get('actions', []): | 1105 for action in spec.get('actions', []): |
| 1099 for group in groups: | 1106 for group in groups: |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1180 | 1187 |
| 1181 for build_file in build_files: | 1188 for build_file in build_files: |
| 1182 xcode_projects[build_file].Finalize1(xcode_targets, serialize_all_tests) | 1189 xcode_projects[build_file].Finalize1(xcode_targets, serialize_all_tests) |
| 1183 | 1190 |
| 1184 for build_file in build_files: | 1191 for build_file in build_files: |
| 1185 xcode_projects[build_file].Finalize2(xcode_targets, | 1192 xcode_projects[build_file].Finalize2(xcode_targets, |
| 1186 xcode_target_to_target_dict) | 1193 xcode_target_to_target_dict) |
| 1187 | 1194 |
| 1188 for build_file in build_files: | 1195 for build_file in build_files: |
| 1189 xcode_projects[build_file].Write() | 1196 xcode_projects[build_file].Write() |
| OLD | NEW |