Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: pylib/gyp/generator/analyzer.py

Issue 671233004: Moves warning about invalid targets into 'invalid_targets' in result (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/analyzer/gyptest-analyzer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
15 targets: the set of targets passed in via targets that either directly or 14 targets: the set of targets passed in via targets that either directly or
16 indirectly depend upon the set of paths supplied in files. 15 indirectly depend upon the set of paths supplied in files.
17 build_targets: minimal set of targets that directly depend on the changed 16 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 17 files and need to be built. The expectation is this set of targets is passed
19 into a build step. 18 into a build step.
20 status: outputs one of three values: none of the supplied files were found, 19 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 20 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 21 changed (in this case targets and build_targets are not output) or at
23 least one file was found. 22 least one file was found.
23 invalid_targets: list of supplied targets thare were not found.
24 24
25 If the generator flag analyzer_output_path is specified, output is written 25 If the generator flag analyzer_output_path is specified, output is written
26 there. Otherwise output is written to stdout. 26 there. Otherwise output is written to stdout.
27 """ 27 """
28 28
29 import gyp.common 29 import gyp.common
30 import gyp.ninja_syntax as ninja_syntax 30 import gyp.ninja_syntax as ninja_syntax
31 import json 31 import json
32 import os 32 import os
33 import posixpath 33 import posixpath
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 """Writes the output, either to stdout or a file is specified.""" 437 """Writes the output, either to stdout or a file is specified."""
438 if 'error' in values: 438 if 'error' in values:
439 print 'Error:', values['error'] 439 print 'Error:', values['error']
440 if 'status' in values: 440 if 'status' in values:
441 print values['status'] 441 print values['status']
442 if 'targets' in values: 442 if 'targets' in values:
443 values['targets'].sort() 443 values['targets'].sort()
444 print 'Supplied targets that depend on changed files:' 444 print 'Supplied targets that depend on changed files:'
445 for target in values['targets']: 445 for target in values['targets']:
446 print '\t', target 446 print '\t', target
447 if 'invalid_targets' in values:
448 values['invalid_targets'].sort()
449 print 'The following targets were not found:'
450 for target in values['invalid_targets']:
451 print '\t', target
447 if 'build_targets' in values: 452 if 'build_targets' in values:
448 values['build_targets'].sort() 453 values['build_targets'].sort()
449 print 'Targets that require a build:' 454 print 'Targets that require a build:'
450 for target in values['build_targets']: 455 for target in values['build_targets']:
451 print '\t', target 456 print '\t', target
452 457
453 output_path = params.get('generator_flags', {}).get( 458 output_path = params.get('generator_flags', {}).get(
454 'analyzer_output_path', None) 459 'analyzer_output_path', None)
455 if not output_path: 460 if not output_path:
456 print json.dumps(values) 461 print json.dumps(values)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 if _WasGypIncludeFileModified(params, config.files): 529 if _WasGypIncludeFileModified(params, config.files):
525 result_dict = { 'status': all_changed_string, 530 result_dict = { 'status': all_changed_string,
526 'targets': list(config.targets) } 531 'targets': list(config.targets) }
527 _WriteOutput(params, **result_dict) 532 _WriteOutput(params, **result_dict)
528 return 533 return
529 534
530 all_targets, matching_targets, roots = _GenerateTargets( 535 all_targets, matching_targets, roots = _GenerateTargets(
531 data, target_list, target_dicts, toplevel_dir, frozenset(config.files), 536 data, target_list, target_dicts, toplevel_dir, frozenset(config.files),
532 params['build_files']) 537 params['build_files'])
533 538
534 warning = None
535 unqualified_mapping = _GetUnqualifiedToTargetMapping(all_targets, 539 unqualified_mapping = _GetUnqualifiedToTargetMapping(all_targets,
536 config.targets) 540 config.targets)
541 invalid_targets = None
537 if len(unqualified_mapping) != len(config.targets): 542 if len(unqualified_mapping) != len(config.targets):
538 not_found = _NamesNotIn(config.targets, unqualified_mapping) 543 invalid_targets = _NamesNotIn(config.targets, unqualified_mapping)
539 warning = 'Unable to find all targets: ' + str(not_found)
540 544
541 if matching_targets: 545 if matching_targets:
542 search_targets = _LookupTargets(config.targets, unqualified_mapping) 546 search_targets = _LookupTargets(config.targets, unqualified_mapping)
543 matched_search_targets = _GetTargetsDependingOn(search_targets) 547 matched_search_targets = _GetTargetsDependingOn(search_targets)
544 # Reset the visited status for _GetBuildTargets. 548 # Reset the visited status for _GetBuildTargets.
545 for target in all_targets.itervalues(): 549 for target in all_targets.itervalues():
546 target.visited = False 550 target.visited = False
547 build_targets = _GetBuildTargets(matching_targets, roots) 551 build_targets = _GetBuildTargets(matching_targets, roots)
548 matched_search_targets = [gyp.common.ParseQualifiedTarget(target.name)[1] 552 matched_search_targets = [gyp.common.ParseQualifiedTarget(target.name)[1]
549 for target in matched_search_targets] 553 for target in matched_search_targets]
550 build_targets = [gyp.common.ParseQualifiedTarget(target.name)[1] 554 build_targets = [gyp.common.ParseQualifiedTarget(target.name)[1]
551 for target in build_targets] 555 for target in build_targets]
552 else: 556 else:
553 matched_search_targets = [] 557 matched_search_targets = []
554 build_targets = [] 558 build_targets = []
555 559
556 result_dict = { 'targets': matched_search_targets, 560 result_dict = { 'targets': matched_search_targets,
557 'status': found_dependency_string if matching_targets else 561 'status': found_dependency_string if matching_targets else
558 no_dependency_string, 562 no_dependency_string,
559 'build_targets': build_targets} 563 'build_targets': build_targets}
560 if warning: 564 if invalid_targets:
561 result_dict['warning'] = warning 565 result_dict['invalid_targets'] = invalid_targets
562 _WriteOutput(params, **result_dict) 566 _WriteOutput(params, **result_dict)
563 567
564 except Exception as e: 568 except Exception as e:
565 _WriteOutput(params, error=str(e)) 569 _WriteOutput(params, error=str(e))
OLDNEW
« no previous file with comments | « no previous file | test/analyzer/gyptest-analyzer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698