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

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

Issue 194883010: Fix missing variable MSVS expansion of copies arguments with Ninja. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: fix unittest 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 | test/ninja/normalize-paths-win/gyptest-normalize-paths.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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 if self.toolset != 'target': 576 if self.toolset != 'target':
577 verb += '(%s)' % self.toolset 577 verb += '(%s)' % self.toolset
578 if message: 578 if message:
579 return '%s %s' % (verb, self.ExpandSpecial(message)) 579 return '%s %s' % (verb, self.ExpandSpecial(message))
580 else: 580 else:
581 return '%s %s: %s' % (verb, self.name, fallback) 581 return '%s %s: %s' % (verb, self.name, fallback)
582 582
583 def WriteActions(self, actions, extra_sources, prebuild, 583 def WriteActions(self, actions, extra_sources, prebuild,
584 extra_mac_bundle_resources): 584 extra_mac_bundle_resources):
585 # Actions cd into the base directory. 585 # Actions cd into the base directory.
586 env = self.GetSortedXcodeEnv() 586 env = self.GetSortedToolchainEnv()
587 if self.flavor == 'win':
588 env = self.msvs_settings.GetVSMacroEnv(
589 '$!PRODUCT_DIR', config=self.config_name)
590 all_outputs = [] 587 all_outputs = []
591 for action in actions: 588 for action in actions:
592 # First write out a rule for the action. 589 # First write out a rule for the action.
593 name = '%s_%s' % (action['action_name'], 590 name = '%s_%s' % (action['action_name'],
594 hashlib.md5(self.qualified_target).hexdigest()) 591 hashlib.md5(self.qualified_target).hexdigest())
595 description = self.GenerateDescription('ACTION', 592 description = self.GenerateDescription('ACTION',
596 action.get('message', None), 593 action.get('message', None),
597 name) 594 name)
598 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action) 595 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action)
599 if self.flavor == 'win' else False) 596 if self.flavor == 'win' else False)
(...skipping 12 matching lines...) Expand all
612 self.ninja.build(outputs, rule_name, inputs, 609 self.ninja.build(outputs, rule_name, inputs,
613 order_only=prebuild) 610 order_only=prebuild)
614 all_outputs += outputs 611 all_outputs += outputs
615 612
616 self.ninja.newline() 613 self.ninja.newline()
617 614
618 return all_outputs 615 return all_outputs
619 616
620 def WriteRules(self, rules, extra_sources, prebuild, 617 def WriteRules(self, rules, extra_sources, prebuild,
621 mac_bundle_resources, extra_mac_bundle_resources): 618 mac_bundle_resources, extra_mac_bundle_resources):
622 env = self.GetSortedXcodeEnv() 619 env = self.GetSortedToolchainEnv()
623 all_outputs = [] 620 all_outputs = []
624 for rule in rules: 621 for rule in rules:
625 # First write out a rule for the rule action. 622 # First write out a rule for the rule action.
626 name = '%s_%s' % (rule['rule_name'], 623 name = '%s_%s' % (rule['rule_name'],
627 hashlib.md5(self.qualified_target).hexdigest()) 624 hashlib.md5(self.qualified_target).hexdigest())
628 # Skip a rule with no action and no inputs. 625 # Skip a rule with no action and no inputs.
629 if 'action' not in rule and not rule.get('rule_sources', []): 626 if 'action' not in rule and not rule.get('rule_sources', []):
630 continue 627 continue
631 args = rule['action'] 628 args = rule['action']
632 description = self.GenerateDescription( 629 description = self.GenerateDescription(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 implicit=inputs, 711 implicit=inputs,
715 order_only=prebuild, 712 order_only=prebuild,
716 variables=extra_bindings) 713 variables=extra_bindings)
717 714
718 all_outputs.extend(outputs) 715 all_outputs.extend(outputs)
719 716
720 return all_outputs 717 return all_outputs
721 718
722 def WriteCopies(self, copies, prebuild, mac_bundle_depends): 719 def WriteCopies(self, copies, prebuild, mac_bundle_depends):
723 outputs = [] 720 outputs = []
724 env = self.GetSortedXcodeEnv() 721 env = self.GetSortedToolchainEnv()
725 for copy in copies: 722 for copy in copies:
726 for path in copy['files']: 723 for path in copy['files']:
727 # Normalize the path so trailing slashes don't confuse us. 724 # Normalize the path so trailing slashes don't confuse us.
728 path = os.path.normpath(path) 725 path = os.path.normpath(path)
729 basename = os.path.split(path)[1] 726 basename = os.path.split(path)[1]
730 src = self.GypPathToNinja(path, env) 727 src = self.GypPathToNinja(path, env)
731 dst = self.GypPathToNinja(os.path.join(copy['destination'], basename), 728 dst = self.GypPathToNinja(os.path.join(copy['destination'], basename),
732 env) 729 env)
733 outputs += self.ninja.build(dst, 'copy', src, order_only=prebuild) 730 outputs += self.ninja.build(dst, 'copy', src, order_only=prebuild)
734 if self.is_mac_bundle: 731 if self.is_mac_bundle:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 defines = config.get('defines', []) + extra_defines 843 defines = config.get('defines', []) + extra_defines
847 self.WriteVariableList(ninja_file, 'defines', 844 self.WriteVariableList(ninja_file, 'defines',
848 [Define(d, self.flavor) for d in defines]) 845 [Define(d, self.flavor) for d in defines])
849 if self.flavor == 'win': 846 if self.flavor == 'win':
850 self.WriteVariableList(ninja_file, 'rcflags', 847 self.WriteVariableList(ninja_file, 'rcflags',
851 [QuoteShellArgument(self.ExpandSpecial(f), self.flavor) 848 [QuoteShellArgument(self.ExpandSpecial(f), self.flavor)
852 for f in self.msvs_settings.GetRcflags(config_name, 849 for f in self.msvs_settings.GetRcflags(config_name,
853 self.GypPathToNinja)]) 850 self.GypPathToNinja)])
854 851
855 include_dirs = config.get('include_dirs', []) 852 include_dirs = config.get('include_dirs', [])
856 env = self.GetSortedXcodeEnv() 853 env = self.GetSortedXcodeEnv()
scottmg 2014/03/12 18:19:17 collapse this one too?
etienneb 2014/03/12 20:07:53 Done.
857 if self.flavor == 'win': 854 if self.flavor == 'win':
858 env = self.msvs_settings.GetVSMacroEnv('$!PRODUCT_DIR', 855 env = self.GetSortedToolchainEnv()
859 config=config_name)
860 include_dirs = self.msvs_settings.AdjustIncludeDirs(include_dirs, 856 include_dirs = self.msvs_settings.AdjustIncludeDirs(include_dirs,
861 config_name) 857 config_name)
862 self.WriteVariableList(ninja_file, 'includes', 858 self.WriteVariableList(ninja_file, 'includes',
863 [QuoteShellArgument('-I' + self.GypPathToNinja(i, env), self.flavor) 859 [QuoteShellArgument('-I' + self.GypPathToNinja(i, env), self.flavor)
864 for i in include_dirs]) 860 for i in include_dirs])
865 861
866 pch_commands = precompiled_header.GetPchBuildCommands(arch) 862 pch_commands = precompiled_header.GetPchBuildCommands(arch)
867 if self.flavor == 'mac': 863 if self.flavor == 'mac':
868 # Most targets use no precompiled headers, so only write these if needed. 864 # Most targets use no precompiled headers, so only write these if needed.
869 for ext, var in [('c', 'cflags_pch_c'), ('cc', 'cflags_pch_cc'), 865 for ext, var in [('c', 'cflags_pch_c'), ('cc', 'cflags_pch_cc'),
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 if package_framework and not is_empty: 1188 if package_framework and not is_empty:
1193 variables.append(('version', self.xcode_settings.GetFrameworkVersion())) 1189 variables.append(('version', self.xcode_settings.GetFrameworkVersion()))
1194 self.ninja.build(output, 'package_framework', mac_bundle_depends, 1190 self.ninja.build(output, 'package_framework', mac_bundle_depends,
1195 variables=variables) 1191 variables=variables)
1196 else: 1192 else:
1197 self.ninja.build(output, 'stamp', mac_bundle_depends, 1193 self.ninja.build(output, 'stamp', mac_bundle_depends,
1198 variables=variables) 1194 variables=variables)
1199 self.target.bundle = output 1195 self.target.bundle = output
1200 return output 1196 return output
1201 1197
1198 def GetSortedToolchainEnv(self, additional_settings=None):
1199 """Returns the variables toolchain would set for build steps."""
1200 if self.flavor == 'win':
1201 return self.GetSortedMsvsEnv(additional_settings=additional_settings)
1202 if self.flavor == 'mac':
1203 return self.GetSortedXcodeEnv(additional_settings=additional_settings)
1204 assert false, "Invalid architecture."
scottmg 2014/03/12 18:19:17 I feel like this will probably be called for Linux
etienneb 2014/03/12 20:07:53 I changed it to have the same semantic as before.
1205
1206 def GetSortedMsvsEnv(self, additional_settings=None):
scottmg 2014/03/12 18:19:17 The environment returned here isn't sorted, so I d
etienneb 2014/03/12 20:07:53 Done.
1207 """Returns the variables Visual Studio would set for build steps."""
1208 return self.msvs_settings.GetVSMacroEnv('$!PRODUCT_DIR',
1209 config=self.config_name)
1210
1202 def GetSortedXcodeEnv(self, additional_settings=None): 1211 def GetSortedXcodeEnv(self, additional_settings=None):
1203 """Returns the variables Xcode would set for build steps.""" 1212 """Returns the variables Xcode would set for build steps."""
1204 assert self.abs_build_dir 1213 assert self.abs_build_dir
1205 abs_build_dir = self.abs_build_dir 1214 abs_build_dir = self.abs_build_dir
1206 return gyp.xcode_emulation.GetSortedXcodeEnv( 1215 return gyp.xcode_emulation.GetSortedXcodeEnv(
1207 self.xcode_settings, abs_build_dir, 1216 self.xcode_settings, abs_build_dir,
1208 os.path.join(abs_build_dir, self.build_to_base), self.config_name, 1217 os.path.join(abs_build_dir, self.build_to_base), self.config_name,
1209 additional_settings) 1218 additional_settings)
1210 1219
1211 def GetSortedXcodePostbuildEnv(self): 1220 def GetSortedXcodePostbuildEnv(self):
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 arglists.append( 2160 arglists.append(
2152 (target_list, target_dicts, data, params, config_name)) 2161 (target_list, target_dicts, data, params, config_name))
2153 pool.map(CallGenerateOutputForConfig, arglists) 2162 pool.map(CallGenerateOutputForConfig, arglists)
2154 except KeyboardInterrupt, e: 2163 except KeyboardInterrupt, e:
2155 pool.terminate() 2164 pool.terminate()
2156 raise e 2165 raise e
2157 else: 2166 else:
2158 for config_name in config_names: 2167 for config_name in config_names:
2159 GenerateOutputForConfig(target_list, target_dicts, data, params, 2168 GenerateOutputForConfig(target_list, target_dicts, data, params,
2160 config_name) 2169 config_name)
OLDNEW
« no previous file with comments | « no previous file | test/ninja/normalize-paths-win/gyptest-normalize-paths.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698