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

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

Issue 206153004: ninja: Reduce size of individual_generated_bindings by another 45kB / 15%. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 9 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) 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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 inputs = [self.GypPathToNinja(i, env) for i in rule.get('inputs', [])] 659 inputs = [self.GypPathToNinja(i, env) for i in rule.get('inputs', [])]
660 660
661 # If there are n source files matching the rule, and m additional rule 661 # If there are n source files matching the rule, and m additional rule
662 # inputs, then adding 'inputs' to each build edge written below will 662 # inputs, then adding 'inputs' to each build edge written below will
663 # write m * n inputs. Collapsing reduces this to m + n. 663 # write m * n inputs. Collapsing reduces this to m + n.
664 sources = rule.get('rule_sources', []) 664 sources = rule.get('rule_sources', [])
665 num_inputs = len(inputs) 665 num_inputs = len(inputs)
666 if prebuild: 666 if prebuild:
667 num_inputs += 1 667 num_inputs += 1
668 if num_inputs > 2 and len(sources) > 2: 668 if num_inputs > 2 and len(sources) > 2:
669 inputs = [ 669 inputs = [self.WriteCollapsedDependencies(
670 self.WriteCollapsedDependencies(name, inputs, order_only=prebuild)] 670 rule['rule_name'], inputs, order_only=prebuild)]
scottmg 2014/03/20 19:29:50 This tends to have spaces, maybe that'll break som
671 prebuild = [] 671 prebuild = []
672 672
673 # For each source file, write an edge that generates all the outputs. 673 # For each source file, write an edge that generates all the outputs.
674 for source in sources: 674 for source in sources:
675 source = os.path.normpath(source) 675 source = os.path.normpath(source)
676 dirname, basename = os.path.split(source) 676 dirname, basename = os.path.split(source)
677 root, ext = os.path.splitext(basename) 677 root, ext = os.path.splitext(basename)
678 678
679 # Gather the list of inputs and outputs, expanding $vars if possible. 679 # Gather the list of inputs and outputs, expanding $vars if possible.
680 outputs = [self.ExpandRuleVariables(o, root, dirname, 680 outputs = [self.ExpandRuleVariables(o, root, dirname,
(...skipping 30 matching lines...) Expand all
711 source_expanded = self.ExpandSpecial(source, self.base_to_build) 711 source_expanded = self.ExpandSpecial(source, self.base_to_build)
712 extra_bindings.append(('source', cygwin_munge(source_expanded))) 712 extra_bindings.append(('source', cygwin_munge(source_expanded)))
713 elif var == 'ext': 713 elif var == 'ext':
714 extra_bindings.append(('ext', ext)) 714 extra_bindings.append(('ext', ext))
715 elif var == 'name': 715 elif var == 'name':
716 extra_bindings.append(('name', cygwin_munge(basename))) 716 extra_bindings.append(('name', cygwin_munge(basename)))
717 else: 717 else:
718 assert var == None, repr(var) 718 assert var == None, repr(var)
719 719
720 outputs = [self.GypPathToNinja(o, env) for o in outputs] 720 outputs = [self.GypPathToNinja(o, env) for o in outputs]
721 extra_bindings.append(('unique_name', 721 if self.flavor == 'win':
722 hashlib.md5(outputs[0]).hexdigest())) 722 # WriteNewNinjaRule uses unique_name for creating an rsp file on win.
723 extra_bindings.append(('unique_name',
724 hashlib.md5(outputs[0]).hexdigest()))
723 self.ninja.build(outputs, rule_name, self.GypPathToNinja(source), 725 self.ninja.build(outputs, rule_name, self.GypPathToNinja(source),
724 implicit=inputs, 726 implicit=inputs,
725 order_only=prebuild, 727 order_only=prebuild,
726 variables=extra_bindings) 728 variables=extra_bindings)
727 729
728 all_outputs.extend(outputs) 730 all_outputs.extend(outputs)
729 731
730 return all_outputs 732 return all_outputs
731 733
732 def WriteCopies(self, copies, prebuild, mac_bundle_depends): 734 def WriteCopies(self, copies, prebuild, mac_bundle_depends):
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2199 arglists.append( 2201 arglists.append(
2200 (target_list, target_dicts, data, params, config_name)) 2202 (target_list, target_dicts, data, params, config_name))
2201 pool.map(CallGenerateOutputForConfig, arglists) 2203 pool.map(CallGenerateOutputForConfig, arglists)
2202 except KeyboardInterrupt, e: 2204 except KeyboardInterrupt, e:
2203 pool.terminate() 2205 pool.terminate()
2204 raise e 2206 raise e
2205 else: 2207 else:
2206 for config_name in config_names: 2208 for config_name in config_names:
2207 GenerateOutputForConfig(target_list, target_dicts, data, params, 2209 GenerateOutputForConfig(target_list, target_dicts, data, params,
2208 config_name) 2210 config_name)
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