OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. 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 # Copies the given "win tool" (which the toolchain uses to wrap compiler | 5 # Copies the given "win tool" (which the toolchain uses to wrap compiler |
6 # invocations) and the environment blocks for the 32-bit and 64-bit builds on | 6 # invocations) and the environment blocks for the 32-bit and 64-bit builds on |
7 # Windows to the build directory. | 7 # Windows to the build directory. |
8 # | 8 # |
9 # The arguments are the visual studio install location and the location of the | 9 # The arguments are the visual studio install location and the location of the |
10 # win tool. The script assumes that the root build directory is the current dir | 10 # win tool. The script assumes that the root build directory is the current dir |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 return block | 140 return block |
141 | 141 |
142 | 142 |
143 def _CopyTool(source_path): | 143 def _CopyTool(source_path): |
144 """Copies the given tool to the current directory, including a warning not | 144 """Copies the given tool to the current directory, including a warning not |
145 to edit it.""" | 145 to edit it.""" |
146 with open(source_path) as source_file: | 146 with open(source_path) as source_file: |
147 tool_source = source_file.readlines() | 147 tool_source = source_file.readlines() |
148 | 148 |
149 # Add header and write it out to the current directory (which should be the | 149 # Add header and write it out to the current directory (which should be the |
150 # root build dir). | 150 # root build dir). Don't write the file if a matching file already exists |
151 with open("gyp-win-tool", 'w') as tool_file: | 151 # because that causes a cascade of unnecessary rebuilds. |
152 tool_file.write(''.join([tool_source[0], | 152 match = False |
153 '# Generated by setup_toolchain.py do not edit.\n'] | 153 contents = ''.join([tool_source[0], |
154 + tool_source[1:])) | 154 '# Generated by setup_toolchain.py do not edit.\n'] |
| 155 + tool_source[1:]) |
| 156 out_path = 'gyp-win-tool' |
| 157 try: |
| 158 with open(out_path, 'rb') as read_tool_file: |
| 159 existing_contents = read_tool_file.read() |
| 160 if existing_contents == contents: |
| 161 match = True |
| 162 except: |
| 163 pass |
| 164 if not match: |
| 165 with open(out_path, 'wb') as write_tool_file: |
| 166 write_tool_file.write(contents) |
155 | 167 |
156 | 168 |
157 def main(): | 169 def main(): |
158 if len(sys.argv) != 6: | 170 if len(sys.argv) != 6: |
159 print('Usage setup_toolchain.py ' | 171 print('Usage setup_toolchain.py ' |
160 '<visual studio path> <win tool path> <win sdk path> ' | 172 '<visual studio path> <win tool path> <win sdk path> ' |
161 '<runtime dirs> <target_cpu>') | 173 '<runtime dirs> <target_cpu>') |
162 sys.exit(2) | 174 sys.exit(2) |
163 tool_source = sys.argv[2] | 175 tool_source = sys.argv[2] |
164 win_sdk_path = sys.argv[3] | 176 win_sdk_path = sys.argv[3] |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 env_block = _FormatAsEnvironmentBlock(env) | 209 env_block = _FormatAsEnvironmentBlock(env) |
198 with open('environment.winrt_' + cpu, 'wb') as f: | 210 with open('environment.winrt_' + cpu, 'wb') as f: |
199 f.write(env_block) | 211 f.write(env_block) |
200 | 212 |
201 assert vc_bin_dir | 213 assert vc_bin_dir |
202 print 'vc_bin_dir = "%s"' % vc_bin_dir | 214 print 'vc_bin_dir = "%s"' % vc_bin_dir |
203 | 215 |
204 | 216 |
205 if __name__ == '__main__': | 217 if __name__ == '__main__': |
206 main() | 218 main() |
OLD | NEW |