OLD | NEW |
---|---|
1 # This file comes from | 1 # This file comes from |
2 # https://github.com/martine/ninja/blob/master/misc/ninja_syntax.py | 2 # https://github.com/martine/ninja/blob/master/misc/ninja_syntax.py |
3 # Do not edit! Edit the upstream one instead. | 3 # Do not edit! Edit the upstream one instead. |
4 | 4 |
5 """Python module for generating .ninja files. | 5 """Python module for generating .ninja files. |
6 | 6 |
7 Note that this is emphatically not a required piece of Ninja; it's | 7 Note that this is emphatically not a required piece of Ninja; it's |
8 just a helpful utility for build-file-generation systems that already | 8 just a helpful utility for build-file-generation systems that already |
9 use Python. | 9 use Python. |
10 """ | 10 """ |
(...skipping 17 matching lines...) Expand all Loading... | |
28 self.output.write('# ' + line + '\n') | 28 self.output.write('# ' + line + '\n') |
29 | 29 |
30 def variable(self, key, value, indent=0): | 30 def variable(self, key, value, indent=0): |
31 if value is None: | 31 if value is None: |
32 return | 32 return |
33 if isinstance(value, list): | 33 if isinstance(value, list): |
34 value = ' '.join(filter(None, value)) # Filter out empty strings. | 34 value = ' '.join(filter(None, value)) # Filter out empty strings. |
35 self._line('%s = %s' % (key, value), indent) | 35 self._line('%s = %s' % (key, value), indent) |
36 | 36 |
37 def rule(self, name, command, description=None, depfile=None, | 37 def rule(self, name, command, description=None, depfile=None, |
38 generator=False, restat=False): | 38 generator=False, restat=False, deplist=None): |
39 self._line('rule %s' % name) | 39 self._line('rule %s' % name) |
40 self.variable('command', command, indent=1) | 40 self.variable('command', command, indent=1) |
41 if description: | 41 if description: |
42 self.variable('description', description, indent=1) | 42 self.variable('description', description, indent=1) |
43 if depfile: | 43 if depfile: |
44 self.variable('depfile', depfile, indent=1) | 44 self.variable('depfile', depfile, indent=1) |
45 if deplist: | |
46 self.variable('deplist', deplist, indent=1) | |
Evan Martin
2012/02/15 19:53:05
Hm, in theory this file shouldn't diverge from ups
| |
45 if generator: | 47 if generator: |
46 self.variable('generator', '1', indent=1) | 48 self.variable('generator', '1', indent=1) |
47 if restat: | 49 if restat: |
48 self.variable('restat', '1', indent=1) | 50 self.variable('restat', '1', indent=1) |
49 | 51 |
50 def build(self, outputs, rule, inputs=None, implicit=None, order_only=None, | 52 def build(self, outputs, rule, inputs=None, implicit=None, order_only=None, |
51 variables=None): | 53 variables=None): |
52 outputs = self._as_list(outputs) | 54 outputs = self._as_list(outputs) |
53 all_inputs = self._as_list(inputs)[:] | 55 all_inputs = self._as_list(inputs)[:] |
54 out_outputs = map(escape_spaces, outputs) | 56 out_outputs = map(escape_spaces, outputs) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 return input | 136 return input |
135 return [input] | 137 return [input] |
136 | 138 |
137 | 139 |
138 def escape(string): | 140 def escape(string): |
139 """Escape a string such that it can be embedded into a Ninja file without | 141 """Escape a string such that it can be embedded into a Ninja file without |
140 further interpretation.""" | 142 further interpretation.""" |
141 assert '\n' not in string, 'Ninja syntax does not allow newlines' | 143 assert '\n' not in string, 'Ninja syntax does not allow newlines' |
142 # We only have one special metacharacter: '$'. | 144 # We only have one special metacharacter: '$'. |
143 return string.replace('$', '$$') | 145 return string.replace('$', '$$') |
OLD | NEW |