OLD | NEW |
| (Empty) |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 # Provides various information needed for GYP and GN to generate and build | |
6 # files. | |
7 | |
8 import os | |
9 import sys | |
10 | |
11 from declaration import Declaration | |
12 import export_h | |
13 import util | |
14 import view_model | |
15 import web_ui_view | |
16 | |
17 def GetImportDependencies(declaration): | |
18 return set(child.build_target for child in declaration.children.itervalues()) | |
19 | |
20 parser = util.CreateArgumentParser() | |
21 parser.add_argument('--output', | |
22 choices=['view_cc', 'view_h', 'model_cc', 'model_h', | |
23 'export_h', 'dirname', 'target_name', 'imports', | |
24 'impl_macro', 'import_dependencies', | |
25 'list_outputs'], | |
26 required=True, | |
27 help='Type of output') | |
28 parser.add_argument('--gn', action='store_true', | |
29 help='Is called by GN') | |
30 args = parser.parse_args() | |
31 declaration_path = os.path.relpath(args.declaration, args.root) | |
32 os.chdir(args.root) | |
33 try: | |
34 declaration = Declaration(declaration_path) | |
35 except Exception as e: | |
36 print >> sys.stderr, e.message | |
37 sys.exit(1) | |
38 | |
39 if args.output == 'view_cc': | |
40 print declaration.webui_view_cc_name | |
41 elif args.output == 'view_h': | |
42 print declaration.webui_view_h_name | |
43 elif args.output == 'model_cc': | |
44 print declaration.view_model_cc_name | |
45 elif args.output == 'model_h': | |
46 print declaration.view_model_h_name | |
47 elif args.output == 'export_h': | |
48 print declaration.export_h_name | |
49 elif args.output == 'dirname': | |
50 print os.path.dirname(declaration_path) | |
51 elif args.output == 'target_name': | |
52 print declaration.build_target | |
53 elif args.output == 'imports': | |
54 for i in declaration.imports: | |
55 print '//' + i | |
56 elif args.output == 'import_dependencies': | |
57 for d in GetImportDependencies(declaration): | |
58 print (':' if args.gn else '') + d | |
59 elif args.output == 'list_outputs': | |
60 outputs = web_ui_view.ListOutputs(declaration, args.destination) + \ | |
61 view_model.ListOutputs(declaration, args.destination) + \ | |
62 export_h.ListOutputs(declaration, args.destination) | |
63 for output in outputs: | |
64 print output | |
65 elif args.output == 'impl_macro': | |
66 print declaration.component_impl_macro | |
67 else: | |
68 assert False | |
69 | |
OLD | NEW |