OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 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 copy | 6 import copy |
6 import ntpath | 7 import ntpath |
7 import os | 8 import os |
8 import posixpath | 9 import posixpath |
9 import re | 10 import re |
10 import subprocess | 11 import subprocess |
11 import sys | 12 import sys |
12 | 13 |
13 import gyp.common | 14 import gyp.common |
14 import gyp.easy_xml as easy_xml | 15 import gyp.easy_xml as easy_xml |
15 import gyp.generator.ninja as ninja_generator | 16 import gyp.generator.ninja as ninja_generator |
16 import gyp.MSVSNew as MSVSNew | 17 import gyp.MSVSNew as MSVSNew |
17 import gyp.MSVSProject as MSVSProject | 18 import gyp.MSVSProject as MSVSProject |
18 import gyp.MSVSSettings as MSVSSettings | 19 import gyp.MSVSSettings as MSVSSettings |
19 import gyp.MSVSToolFile as MSVSToolFile | 20 import gyp.MSVSToolFile as MSVSToolFile |
20 import gyp.MSVSUserFile as MSVSUserFile | 21 import gyp.MSVSUserFile as MSVSUserFile |
21 import gyp.MSVSUtil as MSVSUtil | 22 import gyp.MSVSUtil as MSVSUtil |
22 import gyp.MSVSVersion as MSVSVersion | 23 import gyp.MSVSVersion as MSVSVersion |
23 from gyp.common import GypError | 24 from gyp.common import GypError |
24 from gyp.common import OrderedSet | 25 from gyp.common import OrderedSet |
25 | 26 |
26 # TODO: Remove once bots are on 2.7, http://crbug.com/241769 | |
27 def _import_OrderedDict(): | |
28 import collections | |
29 try: | |
30 return collections.OrderedDict | |
31 except AttributeError: | |
32 import gyp.ordered_dict | |
33 return gyp.ordered_dict.OrderedDict | |
34 OrderedDict = _import_OrderedDict() | |
35 | |
36 | 27 |
37 # Regular expression for validating Visual Studio GUIDs. If the GUID | 28 # Regular expression for validating Visual Studio GUIDs. If the GUID |
38 # contains lowercase hex letters, MSVS will be fine. However, | 29 # contains lowercase hex letters, MSVS will be fine. However, |
39 # IncrediBuild BuildConsole will parse the solution file, but then | 30 # IncrediBuild BuildConsole will parse the solution file, but then |
40 # silently skip building the target causing hard to track down errors. | 31 # silently skip building the target causing hard to track down errors. |
41 # Note that this only happens with the BuildConsole, and does not occur | 32 # Note that this only happens with the BuildConsole, and does not occur |
42 # if IncrediBuild is executed from inside Visual Studio. This regex | 33 # if IncrediBuild is executed from inside Visual Studio. This regex |
43 # validates that the string looks like a GUID with all uppercase hex | 34 # validates that the string looks like a GUID with all uppercase hex |
44 # letters. | 35 # letters. |
45 VALID_MSVS_GUID_CHARS = re.compile(r'^[A-F0-9\-]+$') | 36 VALID_MSVS_GUID_CHARS = re.compile(r'^[A-F0-9\-]+$') |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 For example: | 184 For example: |
194 _ConvertSourcesToFilterHierarchy([['a', 'bob1.c'], ['b', 'bob2.c']], | 185 _ConvertSourcesToFilterHierarchy([['a', 'bob1.c'], ['b', 'bob2.c']], |
195 prefix=['joe']) | 186 prefix=['joe']) |
196 --> | 187 --> |
197 [MSVSProject.Filter('a', contents=['joe\\a\\bob1.c']), | 188 [MSVSProject.Filter('a', contents=['joe\\a\\bob1.c']), |
198 MSVSProject.Filter('b', contents=['joe\\b\\bob2.c'])] | 189 MSVSProject.Filter('b', contents=['joe\\b\\bob2.c'])] |
199 """ | 190 """ |
200 if not prefix: prefix = [] | 191 if not prefix: prefix = [] |
201 result = [] | 192 result = [] |
202 excluded_result = [] | 193 excluded_result = [] |
203 folders = OrderedDict() | 194 folders = collections.OrderedDict() |
204 # Gather files into the final result, excluded, or folders. | 195 # Gather files into the final result, excluded, or folders. |
205 for s in sources: | 196 for s in sources: |
206 if len(s) == 1: | 197 if len(s) == 1: |
207 filename = _NormalizedSource('\\'.join(prefix + s)) | 198 filename = _NormalizedSource('\\'.join(prefix + s)) |
208 if filename in excluded: | 199 if filename in excluded: |
209 excluded_result.append(filename) | 200 excluded_result.append(filename) |
210 else: | 201 else: |
211 result.append(filename) | 202 result.append(filename) |
212 elif msvs_version and not msvs_version.UsesVcxproj(): | 203 elif msvs_version and not msvs_version.UsesVcxproj(): |
213 # For MSVS 2008 and earlier, we need to process all files before walking | 204 # For MSVS 2008 and earlier, we need to process all files before walking |
(...skipping 3244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3458 action_spec.extend( | 3449 action_spec.extend( |
3459 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3450 # TODO(jeanluc) 'Document' for all or just if as_sources? |
3460 [['FileType', 'Document'], | 3451 [['FileType', 'Document'], |
3461 ['Command', command], | 3452 ['Command', command], |
3462 ['Message', description], | 3453 ['Message', description], |
3463 ['Outputs', outputs] | 3454 ['Outputs', outputs] |
3464 ]) | 3455 ]) |
3465 if additional_inputs: | 3456 if additional_inputs: |
3466 action_spec.append(['AdditionalInputs', additional_inputs]) | 3457 action_spec.append(['AdditionalInputs', additional_inputs]) |
3467 actions_spec.append(action_spec) | 3458 actions_spec.append(action_spec) |
OLD | NEW |