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

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

Issue 547393003: Changes ninja generator to only output empty names if not already output (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/ninja/empty-and-non-empty-duplicate-name/gyptest-empty-and-non-empty-duplicate-name.py » ('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 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 2153 # short name of targets that were skipped because they didn't contain anything
2154 # interesting. 2154 # interesting.
2155 empty_target_names = [] 2155 # NOTE: there may be overlap between this an non_empty_target_names.
2156 empty_target_names = set()
2157
2158 # Set of non-empty short target names.
2159 # NOTE: there may be overlap between this an empty_target_names.
2160 non_empty_target_names = set()
2156 2161
2157 for qualified_target in target_list: 2162 for qualified_target in target_list:
2158 # qualified_target is like: third_party/icu/icu.gyp:icui18n#target 2163 # qualified_target is like: third_party/icu/icu.gyp:icui18n#target
2159 build_file, name, toolset = \ 2164 build_file, name, toolset = \
2160 gyp.common.ParseQualifiedTarget(qualified_target) 2165 gyp.common.ParseQualifiedTarget(qualified_target)
2161 2166
2162 this_make_global_settings = data[build_file].get('make_global_settings', []) 2167 this_make_global_settings = data[build_file].get('make_global_settings', [])
2163 assert make_global_settings == this_make_global_settings, ( 2168 assert make_global_settings == this_make_global_settings, (
2164 "make_global_settings needs to be the same for all targets. %s vs. %s" % 2169 "make_global_settings needs to be the same for all targets. %s vs. %s" %
2165 (this_make_global_settings, make_global_settings)) 2170 (this_make_global_settings, make_global_settings))
(...skipping 24 matching lines...) Expand all
2190 ninja_file.write(ninja_output.getvalue()) 2195 ninja_file.write(ninja_output.getvalue())
2191 ninja_output.close() 2196 ninja_output.close()
2192 master_ninja.subninja(output_file) 2197 master_ninja.subninja(output_file)
2193 2198
2194 if target: 2199 if target:
2195 if name != target.FinalOutput() and spec['toolset'] == 'target': 2200 if name != target.FinalOutput() and spec['toolset'] == 'target':
2196 target_short_names.setdefault(name, []).append(target) 2201 target_short_names.setdefault(name, []).append(target)
2197 target_outputs[qualified_target] = target 2202 target_outputs[qualified_target] = target
2198 if qualified_target in all_targets: 2203 if qualified_target in all_targets:
2199 all_outputs.add(target.FinalOutput()) 2204 all_outputs.add(target.FinalOutput())
2205 non_empty_target_names.add(name)
2200 else: 2206 else:
2201 empty_target_names.append(name) 2207 empty_target_names.add(name)
2202 2208
2203 if target_short_names: 2209 if target_short_names:
2204 # Write a short name to build this target. This benefits both the 2210 # Write a short name to build this target. This benefits both the
2205 # "build chrome" case as well as the gyp tests, which expect to be 2211 # "build chrome" case as well as the gyp tests, which expect to be
2206 # able to run actions and build libraries by their short name. 2212 # able to run actions and build libraries by their short name.
2207 master_ninja.newline() 2213 master_ninja.newline()
2208 master_ninja.comment('Short names for targets.') 2214 master_ninja.comment('Short names for targets.')
2209 for short_name in target_short_names: 2215 for short_name in target_short_names:
2210 master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in 2216 master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in
2211 target_short_names[short_name]]) 2217 target_short_names[short_name]])
2212 2218
2219 # Write phony targets for any empty targets that weren't written yet. As
2220 # short names are not necessarily unique only do this for short names that
2221 # haven't already been output for another target.
2222 empty_target_names = empty_target_names - non_empty_target_names
2213 if empty_target_names: 2223 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() 2224 master_ninja.newline()
2218 master_ninja.comment('Empty targets (output for completeness).') 2225 master_ninja.comment('Empty targets (output for completeness).')
2219 for name in sorted(empty_target_names): 2226 for name in sorted(empty_target_names):
2220 master_ninja.build(name, 'phony') 2227 master_ninja.build(name, 'phony')
2221 2228
2222 if all_outputs: 2229 if all_outputs:
2223 master_ninja.newline() 2230 master_ninja.newline()
2224 master_ninja.build('all', 'phony', list(all_outputs)) 2231 master_ninja.build('all', 'phony', list(all_outputs))
2225 master_ninja.default(generator_flags.get('default_target', 'all')) 2232 master_ninja.default(generator_flags.get('default_target', 'all'))
2226 2233
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2269 arglists.append( 2276 arglists.append(
2270 (target_list, target_dicts, data, params, config_name)) 2277 (target_list, target_dicts, data, params, config_name))
2271 pool.map(CallGenerateOutputForConfig, arglists) 2278 pool.map(CallGenerateOutputForConfig, arglists)
2272 except KeyboardInterrupt, e: 2279 except KeyboardInterrupt, e:
2273 pool.terminate() 2280 pool.terminate()
2274 raise e 2281 raise e
2275 else: 2282 else:
2276 for config_name in config_names: 2283 for config_name in config_names:
2277 GenerateOutputForConfig(target_list, target_dicts, data, params, 2284 GenerateOutputForConfig(target_list, target_dicts, data, params,
2278 config_name) 2285 config_name)
OLDNEW
« no previous file with comments | « no previous file | test/ninja/empty-and-non-empty-duplicate-name/gyptest-empty-and-non-empty-duplicate-name.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698