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

Side by Side Diff: pylib/gyp/xcode_ninja.py

Issue 1454433002: Python 3 compatibility Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Rebase with master (4ec6c4e3a94bd04a6da2858163d40b2429b8aad1) Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 # Copyright (c) 2014 Google Inc. All rights reserved. 1 # Copyright (c) 2014 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 """Xcode-ninja wrapper project file generator. 5 """Xcode-ninja wrapper project file generator.
6 6
7 This updates the data structures passed to the Xcode gyp generator to build 7 This updates the data structures passed to the Xcode gyp generator to build
8 with ninja instead. The Xcode project itself is transformed into a list of 8 with ninja instead. The Xcode project itself is transformed into a list of
9 executable targets, each with a build step to build with ninja, and a target 9 executable targets, each with a build step to build with ninja, and a target
10 with every source and resource file. This appears to sidestep some of the 10 with every source and resource file. This appears to sidestep some of the
(...skipping 10 matching lines...) Expand all
21 21
22 def _WriteWorkspace(main_gyp, sources_gyp, params): 22 def _WriteWorkspace(main_gyp, sources_gyp, params):
23 """ Create a workspace to wrap main and sources gyp paths. """ 23 """ Create a workspace to wrap main and sources gyp paths. """
24 (build_file_root, build_file_ext) = os.path.splitext(main_gyp) 24 (build_file_root, build_file_ext) = os.path.splitext(main_gyp)
25 workspace_path = build_file_root + '.xcworkspace' 25 workspace_path = build_file_root + '.xcworkspace'
26 options = params['options'] 26 options = params['options']
27 if options.generator_output: 27 if options.generator_output:
28 workspace_path = os.path.join(options.generator_output, workspace_path) 28 workspace_path = os.path.join(options.generator_output, workspace_path)
29 try: 29 try:
30 os.makedirs(workspace_path) 30 os.makedirs(workspace_path)
31 except OSError, e: 31 except OSError as e:
32 if e.errno != errno.EEXIST: 32 if e.errno != errno.EEXIST:
33 raise 33 raise
34 output_string = '<?xml version="1.0" encoding="UTF-8"?>\n' + \ 34 output_string = '<?xml version="1.0" encoding="UTF-8"?>\n' + \
35 '<Workspace version = "1.0">\n' 35 '<Workspace version = "1.0">\n'
36 for gyp_name in [main_gyp, sources_gyp]: 36 for gyp_name in [main_gyp, sources_gyp]:
37 name = os.path.splitext(os.path.basename(gyp_name))[0] + '.xcodeproj' 37 name = os.path.splitext(os.path.basename(gyp_name))[0] + '.xcodeproj'
38 name = xml.sax.saxutils.quoteattr("group:" + name) 38 name = xml.sax.saxutils.quoteattr("group:" + name)
39 output_string += ' <FileRef location = %s></FileRef>\n' % name 39 output_string += ' <FileRef location = %s></FileRef>\n' % name
40 output_string += '</Workspace>\n' 40 output_string += '</Workspace>\n'
41 41
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 ninja_target['default_configuration'] = old_spec.get('default_configuration') 78 ninja_target['default_configuration'] = old_spec.get('default_configuration')
79 ninja_target['configurations'] = {} 79 ninja_target['configurations'] = {}
80 80
81 # Tell Xcode to look in |ninja_toplevel| for build products. 81 # Tell Xcode to look in |ninja_toplevel| for build products.
82 new_xcode_settings = {} 82 new_xcode_settings = {}
83 if ninja_toplevel: 83 if ninja_toplevel:
84 new_xcode_settings['CONFIGURATION_BUILD_DIR'] = \ 84 new_xcode_settings['CONFIGURATION_BUILD_DIR'] = \
85 "%s/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" % ninja_toplevel 85 "%s/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" % ninja_toplevel
86 86
87 if 'configurations' in old_spec: 87 if 'configurations' in old_spec:
88 for config in old_spec['configurations'].iterkeys(): 88 for config in old_spec['configurations'].keys():
89 old_xcode_settings = \ 89 old_xcode_settings = \
90 old_spec['configurations'][config].get('xcode_settings', {}) 90 old_spec['configurations'][config].get('xcode_settings', {})
91 if 'IPHONEOS_DEPLOYMENT_TARGET' in old_xcode_settings: 91 if 'IPHONEOS_DEPLOYMENT_TARGET' in old_xcode_settings:
92 new_xcode_settings['CODE_SIGNING_REQUIRED'] = "NO" 92 new_xcode_settings['CODE_SIGNING_REQUIRED'] = "NO"
93 new_xcode_settings['IPHONEOS_DEPLOYMENT_TARGET'] = \ 93 new_xcode_settings['IPHONEOS_DEPLOYMENT_TARGET'] = \
94 old_xcode_settings['IPHONEOS_DEPLOYMENT_TARGET'] 94 old_xcode_settings['IPHONEOS_DEPLOYMENT_TARGET']
95 for key in ['BUNDLE_LOADER', 'TEST_HOST']: 95 for key in ['BUNDLE_LOADER', 'TEST_HOST']:
96 if key in old_xcode_settings: 96 if key in old_xcode_settings:
97 new_xcode_settings[key] = old_xcode_settings[key] 97 new_xcode_settings[key] = old_xcode_settings[key]
98 98
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 This sets up the necessary variables in the targets to generate Xcode projects 161 This sets up the necessary variables in the targets to generate Xcode projects
162 that use ninja as an external builder. 162 that use ninja as an external builder.
163 Arguments: 163 Arguments:
164 target_list: List of target pairs: 'base/base.gyp:base'. 164 target_list: List of target pairs: 'base/base.gyp:base'.
165 target_dicts: Dict of target properties keyed on target pair. 165 target_dicts: Dict of target properties keyed on target pair.
166 data: Dict of flattened build files keyed on gyp path. 166 data: Dict of flattened build files keyed on gyp path.
167 params: Dict of global options for gyp. 167 params: Dict of global options for gyp.
168 """ 168 """
169 orig_gyp = params['build_files'][0] 169 orig_gyp = params['build_files'][0]
170 for gyp_name, gyp_dict in data.iteritems(): 170 for gyp_name, gyp_dict in data.items():
171 if gyp_name == orig_gyp: 171 if gyp_name == orig_gyp:
172 depth = gyp_dict['_DEPTH'] 172 depth = gyp_dict['_DEPTH']
173 173
174 # Check for custom main gyp name, otherwise use the default CHROMIUM_GYP_FILE 174 # Check for custom main gyp name, otherwise use the default CHROMIUM_GYP_FILE
175 # and prepend .ninja before the .gyp extension. 175 # and prepend .ninja before the .gyp extension.
176 generator_flags = params.get('generator_flags', {}) 176 generator_flags = params.get('generator_flags', {})
177 main_gyp = generator_flags.get('xcode_ninja_main_gyp', None) 177 main_gyp = generator_flags.get('xcode_ninja_main_gyp', None)
178 if main_gyp is None: 178 if main_gyp is None:
179 (build_file_root, build_file_ext) = os.path.splitext(orig_gyp) 179 (build_file_root, build_file_ext) = os.path.splitext(orig_gyp)
180 main_gyp = build_file_root + ".ninja" + build_file_ext 180 main_gyp = build_file_root + ".ninja" + build_file_ext
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 }, None) 231 }, None)
232 232
233 # Tell Xcode to look everywhere for headers. 233 # Tell Xcode to look everywhere for headers.
234 sources_target['configurations'] = {'Default': { 'include_dirs': [ depth ] } } 234 sources_target['configurations'] = {'Default': { 'include_dirs': [ depth ] } }
235 235
236 # Put excluded files into the sources target so they can be opened in Xcode. 236 # Put excluded files into the sources target so they can be opened in Xcode.
237 skip_excluded_files = \ 237 skip_excluded_files = \
238 not generator_flags.get('xcode_ninja_list_excluded_files', True) 238 not generator_flags.get('xcode_ninja_list_excluded_files', True)
239 239
240 sources = [] 240 sources = []
241 for target, target_dict in target_dicts.iteritems(): 241 for target, target_dict in target_dicts.items():
242 base = os.path.dirname(target) 242 base = os.path.dirname(target)
243 files = target_dict.get('sources', []) + \ 243 files = target_dict.get('sources', []) + \
244 target_dict.get('mac_bundle_resources', []) 244 target_dict.get('mac_bundle_resources', [])
245 245
246 if not skip_excluded_files: 246 if not skip_excluded_files:
247 files.extend(target_dict.get('sources_excluded', []) + 247 files.extend(target_dict.get('sources_excluded', []) +
248 target_dict.get('mac_bundle_resources_excluded', [])) 248 target_dict.get('mac_bundle_resources_excluded', []))
249 249
250 for action in target_dict.get('actions', []): 250 for action in target_dict.get('actions', []):
251 files.extend(action.get('inputs', [])) 251 files.extend(action.get('inputs', []))
(...skipping 28 matching lines...) Expand all
280 new_data[sources_gyp] = {} 280 new_data[sources_gyp] = {}
281 new_data[sources_gyp]['targets'] = [] 281 new_data[sources_gyp]['targets'] = []
282 new_data[sources_gyp]['included_files'] = [] 282 new_data[sources_gyp]['included_files'] = []
283 new_data[sources_gyp]['xcode_settings'] = \ 283 new_data[sources_gyp]['xcode_settings'] = \
284 data[orig_gyp].get('xcode_settings', {}) 284 data[orig_gyp].get('xcode_settings', {})
285 new_data[sources_gyp]['targets'].append(new_data_target) 285 new_data[sources_gyp]['targets'].append(new_data_target)
286 286
287 # Write workspace to file. 287 # Write workspace to file.
288 _WriteWorkspace(main_gyp, sources_gyp, params) 288 _WriteWorkspace(main_gyp, sources_gyp, params)
289 return (new_target_list, new_target_dicts, new_data) 289 return (new_target_list, new_target_dicts, new_data)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698