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

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

Issue 793153004: Add 'depfile' option to actions. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: Fix copyright year and trailing newline Created 5 years, 11 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/actions-depfile/depfile.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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 all_outputs = [] 592 all_outputs = []
593 for action in actions: 593 for action in actions:
594 # First write out a rule for the action. 594 # First write out a rule for the action.
595 name = '%s_%s' % (action['action_name'], self.hash_for_rules) 595 name = '%s_%s' % (action['action_name'], self.hash_for_rules)
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 depfile = action.get('depfile', None)
603 if depfile:
604 depfile = self.ExpandSpecial(depfile, self.base_to_build)
602 pool = 'console' if int(action.get('ninja_use_console', 0)) else None 605 pool = 'console' if int(action.get('ninja_use_console', 0)) else None
603 rule_name, _ = self.WriteNewNinjaRule(name, args, description, 606 rule_name, _ = self.WriteNewNinjaRule(name, args, description,
604 is_cygwin, env, pool) 607 is_cygwin, env, pool,
608 depfile=depfile)
605 609
606 inputs = [self.GypPathToNinja(i, env) for i in action['inputs']] 610 inputs = [self.GypPathToNinja(i, env) for i in action['inputs']]
607 if int(action.get('process_outputs_as_sources', False)): 611 if int(action.get('process_outputs_as_sources', False)):
608 extra_sources += action['outputs'] 612 extra_sources += action['outputs']
609 if int(action.get('process_outputs_as_mac_bundle_resources', False)): 613 if int(action.get('process_outputs_as_mac_bundle_resources', False)):
610 extra_mac_bundle_resources += action['outputs'] 614 extra_mac_bundle_resources += action['outputs']
611 outputs = [self.GypPathToNinja(o, env) for o in action['outputs']] 615 outputs = [self.GypPathToNinja(o, env) for o in action['outputs']]
612 616
613 # Then write out an edge using the rule. 617 # Then write out an edge using the rule.
614 self.ninja.build(outputs, rule_name, inputs, 618 self.ninja.build(outputs, rule_name, inputs,
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 return os.path.join(libdir, filename) 1503 return os.path.join(libdir, filename)
1500 else: 1504 else:
1501 return self.GypPathToUniqueOutput(filename, qualified=False) 1505 return self.GypPathToUniqueOutput(filename, qualified=False)
1502 1506
1503 def WriteVariableList(self, ninja_file, var, values): 1507 def WriteVariableList(self, ninja_file, var, values):
1504 assert not isinstance(values, str) 1508 assert not isinstance(values, str)
1505 if values is None: 1509 if values is None:
1506 values = [] 1510 values = []
1507 ninja_file.variable(var, ' '.join(values)) 1511 ninja_file.variable(var, ' '.join(values))
1508 1512
1509 def WriteNewNinjaRule(self, name, args, description, is_cygwin, env, pool): 1513 def WriteNewNinjaRule(self, name, args, description, is_cygwin, env, pool,
1514 depfile=None):
1510 """Write out a new ninja "rule" statement for a given command. 1515 """Write out a new ninja "rule" statement for a given command.
1511 1516
1512 Returns the name of the new rule, and a copy of |args| with variables 1517 Returns the name of the new rule, and a copy of |args| with variables
1513 expanded.""" 1518 expanded."""
1514 1519
1515 if self.flavor == 'win': 1520 if self.flavor == 'win':
1516 args = [self.msvs_settings.ConvertVSMacros( 1521 args = [self.msvs_settings.ConvertVSMacros(
1517 arg, self.base_to_build, config=self.config_name) 1522 arg, self.base_to_build, config=self.config_name)
1518 for arg in args] 1523 for arg in args]
1519 description = self.msvs_settings.ConvertVSMacros( 1524 description = self.msvs_settings.ConvertVSMacros(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 command = ('%s gyp-win-tool action-wrapper $arch ' % sys.executable + 1562 command = ('%s gyp-win-tool action-wrapper $arch ' % sys.executable +
1558 rspfile + run_in) 1563 rspfile + run_in)
1559 else: 1564 else:
1560 env = self.ComputeExportEnvString(env) 1565 env = self.ComputeExportEnvString(env)
1561 command = gyp.common.EncodePOSIXShellList(args) 1566 command = gyp.common.EncodePOSIXShellList(args)
1562 command = 'cd %s; ' % self.build_to_base + env + command 1567 command = 'cd %s; ' % self.build_to_base + env + command
1563 1568
1564 # GYP rules/actions express being no-ops by not touching their outputs. 1569 # GYP rules/actions express being no-ops by not touching their outputs.
1565 # Avoid executing downstream dependencies in this case by specifying 1570 # Avoid executing downstream dependencies in this case by specifying
1566 # restat=1 to ninja. 1571 # restat=1 to ninja.
1567 self.ninja.rule(rule_name, command, description, restat=True, pool=pool, 1572 self.ninja.rule(rule_name, command, description, depfile=depfile,
1573 restat=True, pool=pool,
1568 rspfile=rspfile, rspfile_content=rspfile_content) 1574 rspfile=rspfile, rspfile_content=rspfile_content)
1569 self.ninja.newline() 1575 self.ninja.newline()
1570 1576
1571 return rule_name, args 1577 return rule_name, args
1572 1578
1573 1579
1574 def CalculateVariables(default_variables, params): 1580 def CalculateVariables(default_variables, params):
1575 """Calculate additional variables for use in the build (called by gyp).""" 1581 """Calculate additional variables for use in the build (called by gyp)."""
1576 global generator_additional_non_configuration_keys 1582 global generator_additional_non_configuration_keys
1577 global generator_additional_path_sections 1583 global generator_additional_path_sections
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 arglists.append( 2380 arglists.append(
2375 (target_list, target_dicts, data, params, config_name)) 2381 (target_list, target_dicts, data, params, config_name))
2376 pool.map(CallGenerateOutputForConfig, arglists) 2382 pool.map(CallGenerateOutputForConfig, arglists)
2377 except KeyboardInterrupt, e: 2383 except KeyboardInterrupt, e:
2378 pool.terminate() 2384 pool.terminate()
2379 raise e 2385 raise e
2380 else: 2386 else:
2381 for config_name in config_names: 2387 for config_name in config_names:
2382 GenerateOutputForConfig(target_list, target_dicts, data, params, 2388 GenerateOutputForConfig(target_list, target_dicts, data, params,
2383 config_name) 2389 config_name)
OLDNEW
« no previous file with comments | « no previous file | test/actions-depfile/depfile.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698