diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-09-18 12:08:43 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-09-18 12:25:30 -0700 |
commit | 100fc27ebb071b7833e0c6f0c10145206ad257e7 (patch) | |
tree | db435f0eaf81de870ed8af9f602063b0990a2283 /tools/gyp/pylib/gyp/generator/ninja.py | |
parent | f90264d2462e0e24b9a4479b23443c518d24ef0d (diff) | |
download | android-node-v8-100fc27ebb071b7833e0c6f0c10145206ad257e7.tar.gz android-node-v8-100fc27ebb071b7833e0c6f0c10145206ad257e7.tar.bz2 android-node-v8-100fc27ebb071b7833e0c6f0c10145206ad257e7.zip |
Upgrade gyp to r1046
Diffstat (limited to 'tools/gyp/pylib/gyp/generator/ninja.py')
-rw-r--r-- | tools/gyp/pylib/gyp/generator/ninja.py | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/tools/gyp/pylib/gyp/generator/ninja.py b/tools/gyp/pylib/gyp/generator/ninja.py index b63e42cdb0..4e5a12f100 100644 --- a/tools/gyp/pylib/gyp/generator/ninja.py +++ b/tools/gyp/pylib/gyp/generator/ninja.py @@ -41,10 +41,10 @@ generator_default_variables = { # Special variables that may be used by gyp 'rule' targets. # We generate definitions for these variables on the fly when processing a # rule. - 'RULE_INPUT_ROOT': '$root', - 'RULE_INPUT_PATH': '$source', - 'RULE_INPUT_EXT': '$ext', - 'RULE_INPUT_NAME': '$name', + 'RULE_INPUT_ROOT': '${root}', + 'RULE_INPUT_PATH': '${source}', + 'RULE_INPUT_EXT': '${ext}', + 'RULE_INPUT_NAME': '${name}', } # TODO: enable cross compiling once we figure out: @@ -195,12 +195,17 @@ class NinjaWriter: return os.path.normpath(os.path.join(obj, self.base_dir, path_dir, path_basename)) - def StampPath(self, name): - """Return a path for a stamp file with a particular name. + def WriteCollapsedDependencies(self, name, targets): + """Given a list of targets, return a dependency list for a single + file representing the result of building all the targets. - Stamp files are used to collapse a dependency on a bunch of files - into a single file.""" - return self.GypPathToUniqueOutput(name + '.stamp') + Uses a stamp file if necessary.""" + + if len(targets) > 1: + stamp = self.GypPathToUniqueOutput(name + '.stamp') + targets = self.ninja.build(stamp, 'stamp', targets) + self.ninja.newline() + return targets def WriteSpec(self, spec, config): """The main entry point for NinjaWriter: write the build rules for a spec. @@ -220,14 +225,10 @@ class NinjaWriter: # running any of its internal steps. prebuild = [] if 'dependencies' in spec: - prebuild_deps = [] for dep in spec['dependencies']: if dep in self.target_outputs: - prebuild_deps.append(self.target_outputs[dep][0]) - if prebuild_deps: - stamp = self.StampPath('predepends') - prebuild = self.ninja.build(stamp, 'stamp', prebuild_deps) - self.ninja.newline() + prebuild.append(self.target_outputs[dep][0]) + prebuild = self.WriteCollapsedDependencies('predepends', prebuild) # Write out actions, rules, and copies. These must happen before we # compile any sources, so compute a list of predependencies for sources @@ -270,11 +271,7 @@ class NinjaWriter: if 'copies' in spec: outputs += self.WriteCopies(spec['copies'], prebuild) - # To simplify downstream build edges, ensure we generate a single - # stamp file that represents the results of all of the above. - if len(outputs) > 1: - stamp = self.StampPath('actions_rules_copies') - outputs = self.ninja.build(stamp, 'stamp', outputs) + outputs = self.WriteCollapsedDependencies('actions_rules_copies', outputs) return outputs @@ -322,9 +319,10 @@ class NinjaWriter: # First write out a rule for the rule action. name = rule['rule_name'] args = rule['action'] - description = self.GenerateDescription('RULE', - rule.get('message', None), - '%s $source' % name) + description = self.GenerateDescription( + 'RULE', + rule.get('message', None), + ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name) rule_name = self.WriteNewNinjaRule(name, args, description) # TODO: if the command references the outputs directly, we should @@ -337,7 +335,7 @@ class NinjaWriter: needed_variables = set(['source']) for argument in args: for var in special_locals: - if '$' + var in argument: + if ('${%s}' % var) in argument: needed_variables.add(var) # For each source file, write an edge that generates all the outputs. @@ -348,7 +346,8 @@ class NinjaWriter: # Gather the list of outputs, expanding $vars if possible. outputs = [] for output in rule['outputs']: - outputs.append(output.replace('$root', root)) + outputs.append(output.replace( + generator_default_variables['RULE_INPUT_ROOT'], root)) if int(rule.get('process_outputs_as_sources', False)): extra_sources += outputs |