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

Side by Side Diff: pylib/gyp/generator/ninja.py

Issue 543743003: Changes the ninja generator to output phony targets for uninteresting targets (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 3 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 | test/empty-target/empty-target.gyp » ('j') | 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) 2013 Google Inc. All rights reserved. 1 # Copyright (c) 2013 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 collections 5 import collections
6 import copy 6 import copy
7 import hashlib 7 import hashlib
8 import json 8 import json
9 import multiprocessing 9 import multiprocessing
10 import os.path 10 import os.path
(...skipping 2132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 os.path.normpath(build_file)): 2143 os.path.normpath(build_file)):
2144 all_targets.add(target) 2144 all_targets.add(target)
2145 all_outputs = set() 2145 all_outputs = set()
2146 2146
2147 # target_outputs is a map from qualified target name to a Target object. 2147 # target_outputs is a map from qualified target name to a Target object.
2148 target_outputs = {} 2148 target_outputs = {}
2149 # target_short_names is a map from target short name to a list of Target 2149 # target_short_names is a map from target short name to a list of Target
2150 # objects. 2150 # objects.
2151 target_short_names = {} 2151 target_short_names = {}
2152 2152
2153 # short name of targets that were skipped because they didn't contain anything
2154 # interesting.
2155 empty_target_names = []
2156
2153 for qualified_target in target_list: 2157 for qualified_target in target_list:
2154 # qualified_target is like: third_party/icu/icu.gyp:icui18n#target 2158 # qualified_target is like: third_party/icu/icu.gyp:icui18n#target
2155 build_file, name, toolset = \ 2159 build_file, name, toolset = \
2156 gyp.common.ParseQualifiedTarget(qualified_target) 2160 gyp.common.ParseQualifiedTarget(qualified_target)
2157 2161
2158 this_make_global_settings = data[build_file].get('make_global_settings', []) 2162 this_make_global_settings = data[build_file].get('make_global_settings', [])
2159 assert make_global_settings == this_make_global_settings, ( 2163 assert make_global_settings == this_make_global_settings, (
2160 "make_global_settings needs to be the same for all targets. %s vs. %s" % 2164 "make_global_settings needs to be the same for all targets. %s vs. %s" %
2161 (this_make_global_settings, make_global_settings)) 2165 (this_make_global_settings, make_global_settings))
2162 2166
(...skipping 23 matching lines...) Expand all
2186 ninja_file.write(ninja_output.getvalue()) 2190 ninja_file.write(ninja_output.getvalue())
2187 ninja_output.close() 2191 ninja_output.close()
2188 master_ninja.subninja(output_file) 2192 master_ninja.subninja(output_file)
2189 2193
2190 if target: 2194 if target:
2191 if name != target.FinalOutput() and spec['toolset'] == 'target': 2195 if name != target.FinalOutput() and spec['toolset'] == 'target':
2192 target_short_names.setdefault(name, []).append(target) 2196 target_short_names.setdefault(name, []).append(target)
2193 target_outputs[qualified_target] = target 2197 target_outputs[qualified_target] = target
2194 if qualified_target in all_targets: 2198 if qualified_target in all_targets:
2195 all_outputs.add(target.FinalOutput()) 2199 all_outputs.add(target.FinalOutput())
2200 else:
2201 empty_target_names.append(name)
2196 2202
2197 if target_short_names: 2203 if target_short_names:
2198 # Write a short name to build this target. This benefits both the 2204 # Write a short name to build this target. This benefits both the
2199 # "build chrome" case as well as the gyp tests, which expect to be 2205 # "build chrome" case as well as the gyp tests, which expect to be
2200 # able to run actions and build libraries by their short name. 2206 # able to run actions and build libraries by their short name.
2201 master_ninja.newline() 2207 master_ninja.newline()
2202 master_ninja.comment('Short names for targets.') 2208 master_ninja.comment('Short names for targets.')
2203 for short_name in target_short_names: 2209 for short_name in target_short_names:
2204 master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in 2210 master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in
2205 target_short_names[short_name]]) 2211 target_short_names[short_name]])
2206 2212
2213 if empty_target_names:
2214 # Write out any targets that were skipped because they didn't contain
2215 # anything interesting. This way the targets can still be built without
2216 # causing build errors.
2217 master_ninja.newline()
2218 master_ninja.comment('Empty targets (output for completeness).')
2219 for name in sorted(empty_target_names):
2220 master_ninja.build(name, 'phony')
2221
2207 if all_outputs: 2222 if all_outputs:
2208 master_ninja.newline() 2223 master_ninja.newline()
2209 master_ninja.build('all', 'phony', list(all_outputs)) 2224 master_ninja.build('all', 'phony', list(all_outputs))
2210 master_ninja.default(generator_flags.get('default_target', 'all')) 2225 master_ninja.default(generator_flags.get('default_target', 'all'))
2211 2226
2212 master_ninja_file.close() 2227 master_ninja_file.close()
2213 2228
2214 2229
2215 def PerformBuild(data, configurations, params): 2230 def PerformBuild(data, configurations, params):
2216 options = params['options'] 2231 options = params['options']
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 arglists.append( 2269 arglists.append(
2255 (target_list, target_dicts, data, params, config_name)) 2270 (target_list, target_dicts, data, params, config_name))
2256 pool.map(CallGenerateOutputForConfig, arglists) 2271 pool.map(CallGenerateOutputForConfig, arglists)
2257 except KeyboardInterrupt, e: 2272 except KeyboardInterrupt, e:
2258 pool.terminate() 2273 pool.terminate()
2259 raise e 2274 raise e
2260 else: 2275 else:
2261 for config_name in config_names: 2276 for config_name in config_names:
2262 GenerateOutputForConfig(target_list, target_dicts, data, params, 2277 GenerateOutputForConfig(target_list, target_dicts, data, params,
2263 config_name) 2278 config_name)
OLDNEW
« no previous file with comments | « no previous file | test/empty-target/empty-target.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698