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

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

Issue 234843005: Add xcode_ninja_target_pattern to xcode-ninja generator (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: Grammar Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 new_xcode_settings['CONFIGURATION_BUILD_DIR'], 105 new_xcode_settings['CONFIGURATION_BUILD_DIR'],
106 target_name, 106 target_name,
107 ], 107 ],
108 'message': 'Compile and copy %s via ninja' % target_name, 108 'message': 'Compile and copy %s via ninja' % target_name,
109 }, 109 },
110 ] 110 ]
111 if jobs > 0: 111 if jobs > 0:
112 ninja_target['actions'][0]['action'].extend(('-j', jobs)) 112 ninja_target['actions'][0]['action'].extend(('-j', jobs))
113 return ninja_target 113 return ninja_target
114 114
115 def IsValidTargetForWrapper(target_additions, target_filter, spec):
116 """Limit targets for Xcode wrapper.
117
118 Xcode seems to perform poorly with too many targets, so only included
Mark Mentovai 2014/04/15 16:55:46 included -> include
justincohen 2014/04/15 17:21:05 Done.
119 proper executable targets, with filters to customize.
120 Arguments:
121 target_additions: Regular expression to always add, matching any target.
122 target_filter: Regular expression limiting executable targets.
123 spec: Specifications for target.
124 """
125 target_name = spec.get('target_name')
126 # Always include targets matching target_additions.
127 if target_additions is not None and re.search(target_additions, target_name):
128 return True
129
130 # Otherwise just show executable targets.
131 if spec.get('type', '') == 'executable' and \
132 spec.get('product_extension', '') != 'bundle':
133
134 # If there is a filter and the target does not match, exclude the target.
135 if target_filter is not None:
136 if not re.search(target_filter, target_name):
137 return False;
138 return True;
Mark Mentovai 2014/04/15 16:55:46 No semicolons. Previous and next lines too.
justincohen 2014/04/15 17:21:05 Done.
139 return False;
140
115 def CreateWrapper(target_list, target_dicts, data, params): 141 def CreateWrapper(target_list, target_dicts, data, params):
116 """Initialize targets for the ninja wrapper. 142 """Initialize targets for the ninja wrapper.
117 143
118 This sets up the necessary variables in the targets to generate Xcode projects 144 This sets up the necessary variables in the targets to generate Xcode projects
119 that use ninja as an external builder. 145 that use ninja as an external builder.
120 Arguments: 146 Arguments:
121 target_list: List of target pairs: 'base/base.gyp:base'. 147 target_list: List of target pairs: 'base/base.gyp:base'.
122 target_dicts: Dict of target properties keyed on target pair. 148 target_dicts: Dict of target properties keyed on target pair.
123 data: Dict of flattened build files keyed on gyp path. 149 data: Dict of flattened build files keyed on gyp path.
124 params: Dict of global options for gyp. 150 params: Dict of global options for gyp.
(...skipping 16 matching lines...) Expand all
141 new_target_dicts = {} 167 new_target_dicts = {}
142 new_data = {} 168 new_data = {}
143 169
144 # Set base keys needed for |data|. 170 # Set base keys needed for |data|.
145 new_data[main_gyp] = {} 171 new_data[main_gyp] = {}
146 new_data[main_gyp]['included_files'] = [] 172 new_data[main_gyp]['included_files'] = []
147 new_data[main_gyp]['targets'] = [] 173 new_data[main_gyp]['targets'] = []
148 new_data[main_gyp]['xcode_settings'] = \ 174 new_data[main_gyp]['xcode_settings'] = \
149 data[orig_gyp].get('xcode_settings', {}) 175 data[orig_gyp].get('xcode_settings', {})
150 176
177 target_additions = generator_flags.get('xcode_ninja_target_additions', None)
178 target_filter = generator_flags.get('xcode_ninja_target_filter', None)
Mark Mentovai 2014/04/15 16:55:46 “filter” sounds like something that can filter to
justincohen 2014/04/15 17:21:05 Neither of these patters really mean exclude. One
179
151 for old_qualified_target in target_list: 180 for old_qualified_target in target_list:
152 spec = target_dicts[old_qualified_target] 181 spec = target_dicts[old_qualified_target]
153 if spec.get('type', '') == 'executable' and \ 182 if IsValidTargetForWrapper(target_additions, target_filter, spec):
154 spec.get('product_extension', '') != 'bundle':
155
156 # Add to new_target_list. 183 # Add to new_target_list.
157 target_name = spec.get('target_name') 184 target_name = spec.get('target_name')
158
159 # Filter target names if requested.
160 target_filter = generator_flags.get('xcode_ninja_target_filter', None)
161 if target_filter is not None:
162 if not re.search(target_filter, target_name):
163 continue;
164
165 new_target_name = '%s:%s#target' % (main_gyp, target_name) 185 new_target_name = '%s:%s#target' % (main_gyp, target_name)
166 new_target_list.append(new_target_name) 186 new_target_list.append(new_target_name)
167 187
168 # Add to new_target_dicts. 188 # Add to new_target_dicts.
169 new_target_dicts[new_target_name] = _TargetFromSpec(spec, params) 189 new_target_dicts[new_target_name] = _TargetFromSpec(spec, params)
170 190
171 # Add to new_data. 191 # Add to new_data.
172 for old_target in data[old_qualified_target.split(':')[0]]['targets']: 192 for old_target in data[old_qualified_target.split(':')[0]]['targets']:
173 if old_target['target_name'] == target_name: 193 if old_target['target_name'] == target_name:
174 new_data_target = {} 194 new_data_target = {}
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 new_data[sources_gyp] = {} 241 new_data[sources_gyp] = {}
222 new_data[sources_gyp]['targets'] = [] 242 new_data[sources_gyp]['targets'] = []
223 new_data[sources_gyp]['included_files'] = [] 243 new_data[sources_gyp]['included_files'] = []
224 new_data[sources_gyp]['xcode_settings'] = \ 244 new_data[sources_gyp]['xcode_settings'] = \
225 data[orig_gyp].get('xcode_settings', {}) 245 data[orig_gyp].get('xcode_settings', {})
226 new_data[sources_gyp]['targets'].append(new_data_target) 246 new_data[sources_gyp]['targets'].append(new_data_target)
227 247
228 # Write workspace to file. 248 # Write workspace to file.
229 _WriteWorkspace(main_gyp, sources_gyp) 249 _WriteWorkspace(main_gyp, sources_gyp)
230 return (new_target_list, new_target_dicts, new_data) 250 return (new_target_list, new_target_dicts, new_data)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698