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 |
Nico
2015/12/09 20:25:00
see this comment
Zachary Forman
2015/12/30 02:18:43
Oops - my bad. Thanks for the heads up :).
| |
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 """ |
11 | 11 |
12 import textwrap | 12 import textwrap |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 if deps: | 60 if deps: |
61 self.variable('deps', deps, indent=1) | 61 self.variable('deps', deps, indent=1) |
62 | 62 |
63 def build(self, outputs, rule, inputs=None, implicit=None, order_only=None, | 63 def build(self, outputs, rule, inputs=None, implicit=None, order_only=None, |
64 variables=None): | 64 variables=None): |
65 outputs = self._as_list(outputs) | 65 outputs = self._as_list(outputs) |
66 all_inputs = self._as_list(inputs)[:] | 66 all_inputs = self._as_list(inputs)[:] |
67 out_outputs = list(map(escape_path, outputs)) | 67 out_outputs = list(map(escape_path, outputs)) |
68 all_inputs = list(map(escape_path, all_inputs)) | 68 all_inputs = list(map(escape_path, all_inputs)) |
69 | 69 |
70 # Sort the inputs so our output is deterministic. | |
71 all_inputs.sort() | |
Nico
2015/12/09 20:25:00
i think callers should do this. this script is jus
Zachary Forman
2015/12/30 02:18:43
I think you're probably right, I've changed this t
| |
72 | |
70 if implicit: | 73 if implicit: |
71 implicit = map(escape_path, self._as_list(implicit)) | 74 implicit = map(escape_path, self._as_list(implicit)) |
72 all_inputs.append('|') | 75 all_inputs.append('|') |
73 all_inputs.extend(implicit) | 76 all_inputs.extend(implicit) |
74 if order_only: | 77 if order_only: |
75 order_only = map(escape_path, self._as_list(order_only)) | 78 order_only = map(escape_path, self._as_list(order_only)) |
76 all_inputs.append('||') | 79 all_inputs.append('||') |
77 all_inputs.extend(order_only) | 80 all_inputs.extend(order_only) |
78 | 81 |
79 self._line('build %s: %s' % (' '.join(out_outputs), | 82 self._line('build %s: %s' % (' '.join(out_outputs), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 return input | 154 return input |
152 return [input] | 155 return [input] |
153 | 156 |
154 | 157 |
155 def escape(string): | 158 def escape(string): |
156 """Escape a string such that it can be embedded into a Ninja file without | 159 """Escape a string such that it can be embedded into a Ninja file without |
157 further interpretation.""" | 160 further interpretation.""" |
158 assert '\n' not in string, 'Ninja syntax does not allow newlines' | 161 assert '\n' not in string, 'Ninja syntax does not allow newlines' |
159 # We only have one special metacharacter: '$'. | 162 # We only have one special metacharacter: '$'. |
160 return string.replace('$', '$$') | 163 return string.replace('$', '$$') |
OLD | NEW |