OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import argparse | 6 import argparse |
7 import collections | 7 import collections |
8 import fnmatch | 8 import fnmatch |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 # 'KEY' : ( <TYPE>, [Accepted Values], <Required?>) | 22 # 'KEY' : ( <TYPE>, [Accepted Values], <Required?>) |
23 DSC_FORMAT = { | 23 DSC_FORMAT = { |
24 'DISABLE': (bool, [True, False], False), | 24 'DISABLE': (bool, [True, False], False), |
25 'SEL_LDR': (bool, [True, False], False), | 25 'SEL_LDR': (bool, [True, False], False), |
26 # Disable this project from being included in the NaCl packaged app. | 26 # Disable this project from being included in the NaCl packaged app. |
27 'DISABLE_PACKAGE': (bool, [True, False], False), | 27 'DISABLE_PACKAGE': (bool, [True, False], False), |
28 # Don't generate the additional files to allow this project to run as a | 28 # Don't generate the additional files to allow this project to run as a |
29 # packaged app (i.e. manifest.json, background.js, etc.). | 29 # packaged app (i.e. manifest.json, background.js, etc.). |
30 'NO_PACKAGE_FILES': (bool, [True, False], False), | 30 'NO_PACKAGE_FILES': (bool, [True, False], False), |
31 'TOOLS' : (list, VALID_TOOLCHAINS, True), | 31 'TOOLS' : (list, VALID_TOOLCHAINS, False), |
32 'CONFIGS' : (list, ['Debug', 'Release'], False), | 32 'CONFIGS' : (list, ['Debug', 'Release'], False), |
33 'PREREQ' : (list, '', False), | 33 'PREREQ' : (list, '', False), |
34 'TARGETS' : (list, { | 34 'TARGETS' : (list, { |
35 'NAME': (str, '', True), | 35 'NAME': (str, '', True), |
36 # main = nexe target | 36 # main = nexe target |
37 # lib = library target | 37 # lib = library target |
38 # so = shared object target, automatically added to NMF | 38 # so = shared object target, automatically added to NMF |
39 # so-standalone = shared object target, not put into NMF | 39 # so-standalone = shared object target, not put into NMF |
40 'TYPE': (str, ['main', 'lib', 'static-lib', 'so', 'so-standalone'], | 40 'TYPE': (str, ['main', 'lib', 'static-lib', 'so', 'so-standalone'], |
41 True), | 41 True), |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 def LoadProject(filename): | 160 def LoadProject(filename): |
161 with open(filename, 'r') as descfile: | 161 with open(filename, 'r') as descfile: |
162 try: | 162 try: |
163 desc = eval(descfile.read(), {}, {}) | 163 desc = eval(descfile.read(), {}, {}) |
164 except Exception as e: | 164 except Exception as e: |
165 raise ValidationError(e) | 165 raise ValidationError(e) |
166 if desc.get('DISABLE', False): | 166 if desc.get('DISABLE', False): |
167 return None | 167 return None |
168 ValidateFormat(desc, DSC_FORMAT) | 168 ValidateFormat(desc, DSC_FORMAT) |
169 desc['FILEPATH'] = os.path.abspath(filename) | 169 desc['FILEPATH'] = os.path.abspath(filename) |
| 170 desc.setdefault('TOOLS', VALID_TOOLCHAINS) |
170 return desc | 171 return desc |
171 | 172 |
172 | 173 |
173 def LoadProjectTreeUnfiltered(srcpath): | 174 def LoadProjectTreeUnfiltered(srcpath): |
174 # Build the tree | 175 # Build the tree |
175 out = collections.defaultdict(list) | 176 out = collections.defaultdict(list) |
176 for root, _, files in os.walk(srcpath): | 177 for root, _, files in os.walk(srcpath): |
177 for filename in files: | 178 for filename in files: |
178 if fnmatch.fnmatch(filename, '*.dsc'): | 179 if fnmatch.fnmatch(filename, '*.dsc'): |
179 filepath = os.path.join(root, filename) | 180 filepath = os.path.join(root, filename) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 except ValidationError as e: | 268 except ValidationError as e: |
268 sys.stderr.write(str(e) + '\n') | 269 sys.stderr.write(str(e) + '\n') |
269 return 1 | 270 return 1 |
270 | 271 |
271 PrintProjectTree(tree) | 272 PrintProjectTree(tree) |
272 return 0 | 273 return 0 |
273 | 274 |
274 | 275 |
275 if __name__ == '__main__': | 276 if __name__ == '__main__': |
276 sys.exit(main(sys.argv[1:])) | 277 sys.exit(main(sys.argv[1:])) |
OLD | NEW |