Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2014 Google Inc. All rights reserved. | 1 # Copyright (c) 2014 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 """ | 5 """ |
| 6 This script is intended for use as a GYP_GENERATOR. It takes as input (by way of | 6 This script is intended for use as a GYP_GENERATOR. It takes as input (by way of |
| 7 the generator flag config_path) the path of a json file that dictates the files | 7 the generator flag config_path) the path of a json file that dictates the files |
| 8 and targets to search for. The following keys are supported: | 8 and targets to search for. The following keys are supported: |
| 9 files: list of paths (relative) of the files to search for. | 9 files: list of paths (relative) of the files to search for. |
| 10 targets: list of targets to search for. The target names are unqualified. | 10 targets: list of targets to search for. The target names are unqualified. |
| 11 | 11 |
| 12 The following is output: | 12 The following is output: |
| 13 error: only supplied if there is an error. | 13 error: only supplied if there is an error. |
| 14 warning: only supplied if there is a warning. | 14 warning: only supplied if there is a warning. |
|
scottmg
2014/10/24 16:27:58
delete this
sky
2014/10/24 16:30:12
Done.
| |
| 15 targets: the set of targets passed in via targets that either directly or | 15 targets: the set of targets passed in via targets that either directly or |
| 16 indirectly depend upon the set of paths supplied in files. | 16 indirectly depend upon the set of paths supplied in files. |
| 17 build_targets: minimal set of targets that directly depend on the changed | 17 build_targets: minimal set of targets that directly depend on the changed |
| 18 files and need to be built. The expectation is this set of targets is passed | 18 files and need to be built. The expectation is this set of targets is passed |
| 19 into a build step. | 19 into a build step. |
| 20 status: outputs one of three values: none of the supplied files were found, | 20 status: outputs one of three values: none of the supplied files were found, |
| 21 one of the include files changed so that it should be assumed everything | 21 one of the include files changed so that it should be assumed everything |
| 22 changed (in this case targets and build_targets are not output) or at | 22 changed (in this case targets and build_targets are not output) or at |
| 23 least one file was found. | 23 least one file was found. |
| 24 invalid_targets: list of supplied targets thare were not found. | |
| 24 | 25 |
| 25 If the generator flag analyzer_output_path is specified, output is written | 26 If the generator flag analyzer_output_path is specified, output is written |
| 26 there. Otherwise output is written to stdout. | 27 there. Otherwise output is written to stdout. |
| 27 """ | 28 """ |
| 28 | 29 |
| 29 import gyp.common | 30 import gyp.common |
| 30 import gyp.ninja_syntax as ninja_syntax | 31 import gyp.ninja_syntax as ninja_syntax |
| 31 import json | 32 import json |
| 32 import os | 33 import os |
| 33 import posixpath | 34 import posixpath |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 """Writes the output, either to stdout or a file is specified.""" | 438 """Writes the output, either to stdout or a file is specified.""" |
| 438 if 'error' in values: | 439 if 'error' in values: |
| 439 print 'Error:', values['error'] | 440 print 'Error:', values['error'] |
| 440 if 'status' in values: | 441 if 'status' in values: |
| 441 print values['status'] | 442 print values['status'] |
| 442 if 'targets' in values: | 443 if 'targets' in values: |
| 443 values['targets'].sort() | 444 values['targets'].sort() |
| 444 print 'Supplied targets that depend on changed files:' | 445 print 'Supplied targets that depend on changed files:' |
| 445 for target in values['targets']: | 446 for target in values['targets']: |
| 446 print '\t', target | 447 print '\t', target |
| 448 if 'invalid_targets' in values: | |
| 449 values['invalid_targets'].sort() | |
| 450 print 'The following targets were not found:' | |
| 451 for target in values['invalid_targets']: | |
| 452 print '\t', target | |
| 447 if 'build_targets' in values: | 453 if 'build_targets' in values: |
| 448 values['build_targets'].sort() | 454 values['build_targets'].sort() |
| 449 print 'Targets that require a build:' | 455 print 'Targets that require a build:' |
| 450 for target in values['build_targets']: | 456 for target in values['build_targets']: |
| 451 print '\t', target | 457 print '\t', target |
| 452 | 458 |
| 453 output_path = params.get('generator_flags', {}).get( | 459 output_path = params.get('generator_flags', {}).get( |
| 454 'analyzer_output_path', None) | 460 'analyzer_output_path', None) |
| 455 if not output_path: | 461 if not output_path: |
| 456 print json.dumps(values) | 462 print json.dumps(values) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 if _WasGypIncludeFileModified(params, config.files): | 530 if _WasGypIncludeFileModified(params, config.files): |
| 525 result_dict = { 'status': all_changed_string, | 531 result_dict = { 'status': all_changed_string, |
| 526 'targets': list(config.targets) } | 532 'targets': list(config.targets) } |
| 527 _WriteOutput(params, **result_dict) | 533 _WriteOutput(params, **result_dict) |
| 528 return | 534 return |
| 529 | 535 |
| 530 all_targets, matching_targets, roots = _GenerateTargets( | 536 all_targets, matching_targets, roots = _GenerateTargets( |
| 531 data, target_list, target_dicts, toplevel_dir, frozenset(config.files), | 537 data, target_list, target_dicts, toplevel_dir, frozenset(config.files), |
| 532 params['build_files']) | 538 params['build_files']) |
| 533 | 539 |
| 534 warning = None | |
| 535 unqualified_mapping = _GetUnqualifiedToTargetMapping(all_targets, | 540 unqualified_mapping = _GetUnqualifiedToTargetMapping(all_targets, |
| 536 config.targets) | 541 config.targets) |
| 542 invalid_targets = None | |
| 537 if len(unqualified_mapping) != len(config.targets): | 543 if len(unqualified_mapping) != len(config.targets): |
| 538 not_found = _NamesNotIn(config.targets, unqualified_mapping) | 544 invalid_targets = _NamesNotIn(config.targets, unqualified_mapping) |
| 539 warning = 'Unable to find all targets: ' + str(not_found) | |
| 540 | 545 |
| 541 if matching_targets: | 546 if matching_targets: |
| 542 search_targets = _LookupTargets(config.targets, unqualified_mapping) | 547 search_targets = _LookupTargets(config.targets, unqualified_mapping) |
| 543 matched_search_targets = _GetTargetsDependingOn(search_targets) | 548 matched_search_targets = _GetTargetsDependingOn(search_targets) |
| 544 # Reset the visited status for _GetBuildTargets. | 549 # Reset the visited status for _GetBuildTargets. |
| 545 for target in all_targets.itervalues(): | 550 for target in all_targets.itervalues(): |
| 546 target.visited = False | 551 target.visited = False |
| 547 build_targets = _GetBuildTargets(matching_targets, roots) | 552 build_targets = _GetBuildTargets(matching_targets, roots) |
| 548 matched_search_targets = [gyp.common.ParseQualifiedTarget(target.name)[1] | 553 matched_search_targets = [gyp.common.ParseQualifiedTarget(target.name)[1] |
| 549 for target in matched_search_targets] | 554 for target in matched_search_targets] |
| 550 build_targets = [gyp.common.ParseQualifiedTarget(target.name)[1] | 555 build_targets = [gyp.common.ParseQualifiedTarget(target.name)[1] |
| 551 for target in build_targets] | 556 for target in build_targets] |
| 552 else: | 557 else: |
| 553 matched_search_targets = [] | 558 matched_search_targets = [] |
| 554 build_targets = [] | 559 build_targets = [] |
| 555 | 560 |
| 556 result_dict = { 'targets': matched_search_targets, | 561 result_dict = { 'targets': matched_search_targets, |
| 557 'status': found_dependency_string if matching_targets else | 562 'status': found_dependency_string if matching_targets else |
| 558 no_dependency_string, | 563 no_dependency_string, |
| 559 'build_targets': build_targets} | 564 'build_targets': build_targets} |
| 560 if warning: | 565 if invalid_targets: |
| 561 result_dict['warning'] = warning | 566 result_dict['invalid_targets'] = invalid_targets |
| 562 _WriteOutput(params, **result_dict) | 567 _WriteOutput(params, **result_dict) |
| 563 | 568 |
| 564 except Exception as e: | 569 except Exception as e: |
| 565 _WriteOutput(params, error=str(e)) | 570 _WriteOutput(params, error=str(e)) |
| OLD | NEW |