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 |
| 10 from declaration import Declaration |
| 11 import export_h |
| 12 import view_model |
| 13 import web_ui_view |
| 14 import util |
| 15 |
| 16 def GetImportDependencies(declaration): |
| 17 return set(child.build_target for child in declaration.children.itervalues()) |
| 18 |
| 19 parser = util.CreateArgumentParser() |
| 20 parser.add_argument('--output', |
| 21 choices=['view_cc', 'view_h', 'model_cc', 'model_h', |
| 22 'export_h', 'dirname', 'target_name', 'imports', |
| 23 'impl_macro', 'import_dependencies', |
| 24 'list_outputs'], |
| 25 required=True, |
| 26 help='Type of output') |
| 27 parser.add_argument('--gn', action='store_true', |
| 28 help='Is called by GN') |
| 29 args = parser.parse_args() |
| 30 declaration_path = os.path.relpath(args.declaration, args.root) |
| 31 os.chdir(args.root) |
| 32 declaration = Declaration(declaration_path) |
| 33 |
| 34 if args.output == 'view_cc': |
| 35 print declaration.webui_view_cc_name |
| 36 elif args.output == 'view_h': |
| 37 print declaration.webui_view_h_name |
| 38 elif args.output == 'model_cc': |
| 39 print declaration.view_model_cc_name |
| 40 elif args.output == 'model_h': |
| 41 print declaration.view_model_h_name |
| 42 elif args.output == 'export_h': |
| 43 print declaration.export_h_name |
| 44 elif args.output == 'dirname': |
| 45 print os.path.dirname(declaration_path) |
| 46 elif args.output == 'target_name': |
| 47 print declaration.build_target |
| 48 elif args.output == 'imports': |
| 49 for i in declaration.imports: |
| 50 print '//' + i |
| 51 elif args.output == 'import_dependencies': |
| 52 for d in GetImportDependencies(declaration): |
| 53 print (':' if args.gn else '') + d |
| 54 elif args.output == 'list_outputs': |
| 55 outputs = web_ui_view.ListOutputs(declaration, args.destination) + \ |
| 56 view_model.ListOutputs(declaration, args.destination) + \ |
| 57 export_h.ListOutputs(declaration, args.destination) |
| 58 for output in outputs: |
| 59 print output |
| 60 elif args.output == 'impl_macro': |
| 61 print declaration.component_impl_macro |
| 62 else: |
| 63 assert False |
| 64 |
OLD | NEW |