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

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

Issue 412283002: ninja: Add support for 'ninja_use_console' in actions/rules (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: address nits in #11 Created 6 years, 4 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/use-console/foo.bar » ('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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 for action in actions: 592 for action in actions:
593 # First write out a rule for the action. 593 # First write out a rule for the action.
594 name = '%s_%s' % (action['action_name'], 594 name = '%s_%s' % (action['action_name'],
595 hashlib.md5(self.qualified_target).hexdigest()) 595 hashlib.md5(self.qualified_target).hexdigest())
596 description = self.GenerateDescription('ACTION', 596 description = self.GenerateDescription('ACTION',
597 action.get('message', None), 597 action.get('message', None),
598 name) 598 name)
599 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action) 599 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action)
600 if self.flavor == 'win' else False) 600 if self.flavor == 'win' else False)
601 args = action['action'] 601 args = action['action']
602 pool = 'console' if int(action.get('ninja_use_console', 0)) else None
602 rule_name, _ = self.WriteNewNinjaRule(name, args, description, 603 rule_name, _ = self.WriteNewNinjaRule(name, args, description,
603 is_cygwin, env=env) 604 is_cygwin, env, pool)
604 605
605 inputs = [self.GypPathToNinja(i, env) for i in action['inputs']] 606 inputs = [self.GypPathToNinja(i, env) for i in action['inputs']]
606 if int(action.get('process_outputs_as_sources', False)): 607 if int(action.get('process_outputs_as_sources', False)):
607 extra_sources += action['outputs'] 608 extra_sources += action['outputs']
608 if int(action.get('process_outputs_as_mac_bundle_resources', False)): 609 if int(action.get('process_outputs_as_mac_bundle_resources', False)):
609 extra_mac_bundle_resources += action['outputs'] 610 extra_mac_bundle_resources += action['outputs']
610 outputs = [self.GypPathToNinja(o, env) for o in action['outputs']] 611 outputs = [self.GypPathToNinja(o, env) for o in action['outputs']]
611 612
612 # Then write out an edge using the rule. 613 # Then write out an edge using the rule.
613 self.ninja.build(outputs, rule_name, inputs, 614 self.ninja.build(outputs, rule_name, inputs,
(...skipping 17 matching lines...) Expand all
631 name = '%s_%s' % (rule['rule_name'], 632 name = '%s_%s' % (rule['rule_name'],
632 hashlib.md5(self.qualified_target).hexdigest()) 633 hashlib.md5(self.qualified_target).hexdigest())
633 634
634 args = rule['action'] 635 args = rule['action']
635 description = self.GenerateDescription( 636 description = self.GenerateDescription(
636 'RULE', 637 'RULE',
637 rule.get('message', None), 638 rule.get('message', None),
638 ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name) 639 ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name)
639 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule) 640 is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule)
640 if self.flavor == 'win' else False) 641 if self.flavor == 'win' else False)
642 pool = 'console' if int(rule.get('ninja_use_console', 0)) else None
641 rule_name, args = self.WriteNewNinjaRule( 643 rule_name, args = self.WriteNewNinjaRule(
642 name, args, description, is_cygwin, env=env) 644 name, args, description, is_cygwin, env, pool)
643 645
644 # TODO: if the command references the outputs directly, we should 646 # TODO: if the command references the outputs directly, we should
645 # simplify it to just use $out. 647 # simplify it to just use $out.
646 648
647 # Rules can potentially make use of some special variables which 649 # Rules can potentially make use of some special variables which
648 # must vary per source file. 650 # must vary per source file.
649 # Compute the list of variables we'll need to provide. 651 # Compute the list of variables we'll need to provide.
650 special_locals = ('source', 'root', 'dirname', 'ext', 'name') 652 special_locals = ('source', 'root', 'dirname', 'ext', 'name')
651 needed_variables = set(['source']) 653 needed_variables = set(['source'])
652 for argument in args: 654 for argument in args:
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 return os.path.join(libdir, filename) 1422 return os.path.join(libdir, filename)
1421 else: 1423 else:
1422 return self.GypPathToUniqueOutput(filename, qualified=False) 1424 return self.GypPathToUniqueOutput(filename, qualified=False)
1423 1425
1424 def WriteVariableList(self, ninja_file, var, values): 1426 def WriteVariableList(self, ninja_file, var, values):
1425 assert not isinstance(values, str) 1427 assert not isinstance(values, str)
1426 if values is None: 1428 if values is None:
1427 values = [] 1429 values = []
1428 ninja_file.variable(var, ' '.join(values)) 1430 ninja_file.variable(var, ' '.join(values))
1429 1431
1430 def WriteNewNinjaRule(self, name, args, description, is_cygwin, env): 1432 def WriteNewNinjaRule(self, name, args, description, is_cygwin, env, pool):
1431 """Write out a new ninja "rule" statement for a given command. 1433 """Write out a new ninja "rule" statement for a given command.
1432 1434
1433 Returns the name of the new rule, and a copy of |args| with variables 1435 Returns the name of the new rule, and a copy of |args| with variables
1434 expanded.""" 1436 expanded."""
1435 1437
1436 if self.flavor == 'win': 1438 if self.flavor == 'win':
1437 args = [self.msvs_settings.ConvertVSMacros( 1439 args = [self.msvs_settings.ConvertVSMacros(
1438 arg, self.base_to_build, config=self.config_name) 1440 arg, self.base_to_build, config=self.config_name)
1439 for arg in args] 1441 for arg in args]
1440 description = self.msvs_settings.ConvertVSMacros( 1442 description = self.msvs_settings.ConvertVSMacros(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 command = ('%s gyp-win-tool action-wrapper $arch ' % sys.executable + 1480 command = ('%s gyp-win-tool action-wrapper $arch ' % sys.executable +
1479 rspfile + run_in) 1481 rspfile + run_in)
1480 else: 1482 else:
1481 env = self.ComputeExportEnvString(env) 1483 env = self.ComputeExportEnvString(env)
1482 command = gyp.common.EncodePOSIXShellList(args) 1484 command = gyp.common.EncodePOSIXShellList(args)
1483 command = 'cd %s; ' % self.build_to_base + env + command 1485 command = 'cd %s; ' % self.build_to_base + env + command
1484 1486
1485 # GYP rules/actions express being no-ops by not touching their outputs. 1487 # GYP rules/actions express being no-ops by not touching their outputs.
1486 # Avoid executing downstream dependencies in this case by specifying 1488 # Avoid executing downstream dependencies in this case by specifying
1487 # restat=1 to ninja. 1489 # restat=1 to ninja.
1488 self.ninja.rule(rule_name, command, description, restat=True, 1490 self.ninja.rule(rule_name, command, description, restat=True, pool=pool,
1489 rspfile=rspfile, rspfile_content=rspfile_content) 1491 rspfile=rspfile, rspfile_content=rspfile_content)
1490 self.ninja.newline() 1492 self.ninja.newline()
1491 1493
1492 return rule_name, args 1494 return rule_name, args
1493 1495
1494 1496
1495 def CalculateVariables(default_variables, params): 1497 def CalculateVariables(default_variables, params):
1496 """Calculate additional variables for use in the build (called by gyp).""" 1498 """Calculate additional variables for use in the build (called by gyp)."""
1497 global generator_additional_non_configuration_keys 1499 global generator_additional_non_configuration_keys
1498 global generator_additional_path_sections 1500 global generator_additional_path_sections
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 arglists.append( 2230 arglists.append(
2229 (target_list, target_dicts, data, params, config_name)) 2231 (target_list, target_dicts, data, params, config_name))
2230 pool.map(CallGenerateOutputForConfig, arglists) 2232 pool.map(CallGenerateOutputForConfig, arglists)
2231 except KeyboardInterrupt, e: 2233 except KeyboardInterrupt, e:
2232 pool.terminate() 2234 pool.terminate()
2233 raise e 2235 raise e
2234 else: 2236 else:
2235 for config_name in config_names: 2237 for config_name in config_names:
2236 GenerateOutputForConfig(target_list, target_dicts, data, params, 2238 GenerateOutputForConfig(target_list, target_dicts, data, params,
2237 config_name) 2239 config_name)
OLDNEW
« no previous file with comments | « no previous file | test/ninja/use-console/foo.bar » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698