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