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

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

Issue 1454433002: Python 3 compatibility Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Rebase with master (4ec6c4e3a94bd04a6da2858163d40b2429b8aad1) Created 4 years, 8 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
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 test_targets: unqualified target names to search for. Any target in this list 10 test_targets: unqualified target names to search for. Any target in this list
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 In Gyp the "all" target is shorthand for the root targets in the files passed 56 In Gyp the "all" target is shorthand for the root targets in the files passed
57 to gyp. For example, if file "a.gyp" contains targets "a1" and 57 to gyp. For example, if file "a.gyp" contains targets "a1" and
58 "a2", and file "b.gyp" contains targets "b1" and "b2" and "a2" has a dependency 58 "a2", and file "b.gyp" contains targets "b1" and "b2" and "a2" has a dependency
59 on "b2" and gyp is supplied "a.gyp" then "all" consists of "a1" and "a2". 59 on "b2" and gyp is supplied "a.gyp" then "all" consists of "a1" and "a2".
60 Notice that "b1" and "b2" are not in the "all" target as "b.gyp" was not 60 Notice that "b1" and "b2" are not in the "all" target as "b.gyp" was not
61 directly supplied to gyp. OTOH if both "a.gyp" and "b.gyp" are supplied to gyp 61 directly supplied to gyp. OTOH if both "a.gyp" and "b.gyp" are supplied to gyp
62 then the "all" target includes "b1" and "b2". 62 then the "all" target includes "b1" and "b2".
63 """ 63 """
64 64
65 from __future__ import print_function
66
65 import gyp.common 67 import gyp.common
66 import gyp.ninja_syntax as ninja_syntax 68 import gyp.ninja_syntax as ninja_syntax
67 import json 69 import json
68 import os 70 import os
69 import posixpath 71 import posixpath
70 import sys 72 import sys
71 73
72 debug = False 74 debug = False
73 75
74 found_dependency_string = 'Found dependency' 76 found_dependency_string = 'Found dependency'
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 # variable expansion may lead to //. 150 # variable expansion may lead to //.
149 org_source = source 151 org_source = source
150 source = source[0] + source[1:].replace('//', '/') 152 source = source[0] + source[1:].replace('//', '/')
151 if source.startswith('../'): 153 if source.startswith('../'):
152 source = _ResolveParent(source, base_path_components) 154 source = _ResolveParent(source, base_path_components)
153 if len(source): 155 if len(source):
154 result.append(source) 156 result.append(source)
155 continue 157 continue
156 result.append(base_path + source) 158 result.append(base_path + source)
157 if debug: 159 if debug:
158 print 'AddSource', org_source, result[len(result) - 1] 160 print('AddSource', org_source, result[len(result) - 1])
159 161
160 162
161 def _ExtractSourcesFromAction(action, base_path, base_path_components, 163 def _ExtractSourcesFromAction(action, base_path, base_path_components,
162 results): 164 results):
163 if 'inputs' in action: 165 if 'inputs' in action:
164 _AddSources(action['inputs'], base_path, base_path_components, results) 166 _AddSources(action['inputs'], base_path, base_path_components, results)
165 167
166 168
167 def _ToLocalPath(toplevel_dir, path): 169 def _ToLocalPath(toplevel_dir, path):
168 """Converts |path| to a path relative to |toplevel_dir|.""" 170 """Converts |path| to a path relative to |toplevel_dir|."""
169 if path == toplevel_dir: 171 if path == toplevel_dir:
170 return '' 172 return ''
171 if path.startswith(toplevel_dir + '/'): 173 if path.startswith(toplevel_dir + '/'):
172 return path[len(toplevel_dir) + len('/'):] 174 return path[len(toplevel_dir) + len('/'):]
173 return path 175 return path
174 176
175 177
176 def _ExtractSources(target, target_dict, toplevel_dir): 178 def _ExtractSources(target, target_dict, toplevel_dir):
177 # |target| is either absolute or relative and in the format of the OS. Gyp 179 # |target| is either absolute or relative and in the format of the OS. Gyp
178 # source paths are always posix. Convert |target| to a posix path relative to 180 # source paths are always posix. Convert |target| to a posix path relative to
179 # |toplevel_dir_|. This is done to make it easy to build source paths. 181 # |toplevel_dir_|. This is done to make it easy to build source paths.
180 base_path = posixpath.dirname(_ToLocalPath(toplevel_dir, _ToGypPath(target))) 182 base_path = posixpath.dirname(_ToLocalPath(toplevel_dir, _ToGypPath(target)))
181 base_path_components = base_path.split('/') 183 base_path_components = base_path.split('/')
182 184
183 # Add a trailing '/' so that _AddSources() can easily build paths. 185 # Add a trailing '/' so that _AddSources() can easily build paths.
184 if len(base_path): 186 if len(base_path):
185 base_path += '/' 187 base_path += '/'
186 188
187 if debug: 189 if debug:
188 print 'ExtractSources', target, base_path 190 print('ExtractSources', target, base_path)
189 191
190 results = [] 192 results = []
191 if 'sources' in target_dict: 193 if 'sources' in target_dict:
192 _AddSources(target_dict['sources'], base_path, base_path_components, 194 _AddSources(target_dict['sources'], base_path, base_path_components,
193 results) 195 results)
194 # Include the inputs from any actions. Any changes to these affect the 196 # Include the inputs from any actions. Any changes to these affect the
195 # resulting output. 197 # resulting output.
196 if 'actions' in target_dict: 198 if 'actions' in target_dict:
197 for action in target_dict['actions']: 199 for action in target_dict['actions']:
198 _ExtractSourcesFromAction(action, base_path, base_path_components, 200 _ExtractSourcesFromAction(action, base_path, base_path_components,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 config.get('additional_compile_targets', [])) 273 config.get('additional_compile_targets', []))
272 self.test_target_names = set(config.get('test_targets', [])) 274 self.test_target_names = set(config.get('test_targets', []))
273 275
274 276
275 def _WasBuildFileModified(build_file, data, files, toplevel_dir): 277 def _WasBuildFileModified(build_file, data, files, toplevel_dir):
276 """Returns true if the build file |build_file| is either in |files| or 278 """Returns true if the build file |build_file| is either in |files| or
277 one of the files included by |build_file| is in |files|. |toplevel_dir| is 279 one of the files included by |build_file| is in |files|. |toplevel_dir| is
278 the root of the source tree.""" 280 the root of the source tree."""
279 if _ToLocalPath(toplevel_dir, _ToGypPath(build_file)) in files: 281 if _ToLocalPath(toplevel_dir, _ToGypPath(build_file)) in files:
280 if debug: 282 if debug:
281 print 'gyp file modified', build_file 283 print('gyp file modified', build_file)
282 return True 284 return True
283 285
284 # First element of included_files is the file itself. 286 # First element of included_files is the file itself.
285 if len(data[build_file]['included_files']) <= 1: 287 if len(data[build_file]['included_files']) <= 1:
286 return False 288 return False
287 289
288 for include_file in data[build_file]['included_files'][1:]: 290 for include_file in data[build_file]['included_files'][1:]:
289 # |included_files| are relative to the directory of the |build_file|. 291 # |included_files| are relative to the directory of the |build_file|.
290 rel_include_file = \ 292 rel_include_file = \
291 _ToGypPath(gyp.common.UnrelativePath(include_file, build_file)) 293 _ToGypPath(gyp.common.UnrelativePath(include_file, build_file))
292 if _ToLocalPath(toplevel_dir, rel_include_file) in files: 294 if _ToLocalPath(toplevel_dir, rel_include_file) in files:
293 if debug: 295 if debug:
294 print 'included gyp file modified, gyp_file=', build_file, \ 296 print('included gyp file modified, gyp_file=', build_file, \
295 'included file=', rel_include_file 297 'included file=', rel_include_file)
296 return True 298 return True
297 return False 299 return False
298 300
299 301
300 def _GetOrCreateTargetByName(targets, target_name): 302 def _GetOrCreateTargetByName(targets, target_name):
301 """Creates or returns the Target at targets[target_name]. If there is no 303 """Creates or returns the Target at targets[target_name]. If there is no
302 Target for |target_name| one is created. Returns a tuple of whether a new 304 Target for |target_name| one is created. Returns a tuple of whether a new
303 Target was created and the Target.""" 305 Target was created and the Target."""
304 if target_name in targets: 306 if target_name in targets:
305 return False, targets[target_name] 307 return False, targets[target_name]
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 if not build_file in build_file_in_files: 368 if not build_file in build_file_in_files:
367 build_file_in_files[build_file] = \ 369 build_file_in_files[build_file] = \
368 _WasBuildFileModified(build_file, data, files, toplevel_dir) 370 _WasBuildFileModified(build_file, data, files, toplevel_dir)
369 371
370 if build_file in build_files: 372 if build_file in build_files:
371 build_file_targets.add(target) 373 build_file_targets.add(target)
372 374
373 # If a build file (or any of its included files) is modified we assume all 375 # If a build file (or any of its included files) is modified we assume all
374 # targets in the file are modified. 376 # targets in the file are modified.
375 if build_file_in_files[build_file]: 377 if build_file_in_files[build_file]:
376 print 'matching target from modified build file', target_name 378 print('matching target from modified build file', target_name)
377 target.match_status = MATCH_STATUS_MATCHES 379 target.match_status = MATCH_STATUS_MATCHES
378 matching_targets.append(target) 380 matching_targets.append(target)
379 else: 381 else:
380 sources = _ExtractSources(target_name, target_dicts[target_name], 382 sources = _ExtractSources(target_name, target_dicts[target_name],
381 toplevel_dir) 383 toplevel_dir)
382 for source in sources: 384 for source in sources:
383 if _ToGypPath(os.path.normpath(source)) in files: 385 if _ToGypPath(os.path.normpath(source)) in files:
384 print 'target', target_name, 'matches', source 386 print('target', target_name, 'matches', source)
385 target.match_status = MATCH_STATUS_MATCHES 387 target.match_status = MATCH_STATUS_MATCHES
386 matching_targets.append(target) 388 matching_targets.append(target)
387 break 389 break
388 390
389 # Add dependencies to visit as well as updating back pointers for deps. 391 # Add dependencies to visit as well as updating back pointers for deps.
390 for dep in target_dicts[target_name].get('dependencies', []): 392 for dep in target_dicts[target_name].get('dependencies', []):
391 targets_to_visit.append(dep) 393 targets_to_visit.append(dep)
392 394
393 created_dep_target, dep_target = _GetOrCreateTargetByName(name_to_target, 395 created_dep_target, dep_target = _GetOrCreateTargetByName(name_to_target,
394 dep) 396 dep)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 |matches| of the Targets as it recurses. 428 |matches| of the Targets as it recurses.
427 target: the Target to look for.""" 429 target: the Target to look for."""
428 if target.match_status == MATCH_STATUS_DOESNT_MATCH: 430 if target.match_status == MATCH_STATUS_DOESNT_MATCH:
429 return False 431 return False
430 if target.match_status == MATCH_STATUS_MATCHES or \ 432 if target.match_status == MATCH_STATUS_MATCHES or \
431 target.match_status == MATCH_STATUS_MATCHES_BY_DEPENDENCY: 433 target.match_status == MATCH_STATUS_MATCHES_BY_DEPENDENCY:
432 return True 434 return True
433 for dep in target.deps: 435 for dep in target.deps:
434 if _DoesTargetDependOnMatchingTargets(dep): 436 if _DoesTargetDependOnMatchingTargets(dep):
435 target.match_status = MATCH_STATUS_MATCHES_BY_DEPENDENCY 437 target.match_status = MATCH_STATUS_MATCHES_BY_DEPENDENCY
436 print '\t', target.name, 'matches by dep', dep.name 438 print('\t', target.name, 'matches by dep', dep.name)
437 return True 439 return True
438 target.match_status = MATCH_STATUS_DOESNT_MATCH 440 target.match_status = MATCH_STATUS_DOESNT_MATCH
439 return False 441 return False
440 442
441 443
442 def _GetTargetsDependingOnMatchingTargets(possible_targets): 444 def _GetTargetsDependingOnMatchingTargets(possible_targets):
443 """Returns the list of Targets in |possible_targets| that depend (either 445 """Returns the list of Targets in |possible_targets| that depend (either
444 directly on indirectly) on at least one of the targets containing the files 446 directly on indirectly) on at least one of the targets containing the files
445 supplied as input to analyzer. 447 supplied as input to analyzer.
446 possible_targets: targets to search from.""" 448 possible_targets: targets to search from."""
447 found = [] 449 found = []
448 print 'Targets that matched by dependency:' 450 print('Targets that matched by dependency:')
449 for target in possible_targets: 451 for target in possible_targets:
450 if _DoesTargetDependOnMatchingTargets(target): 452 if _DoesTargetDependOnMatchingTargets(target):
451 found.append(target) 453 found.append(target)
452 return found 454 return found
453 455
454 456
455 def _AddCompileTargets(target, roots, add_if_no_ancestor, result): 457 def _AddCompileTargets(target, roots, add_if_no_ancestor, result):
456 """Recurses through all targets that depend on |target|, adding all targets 458 """Recurses through all targets that depend on |target|, adding all targets
457 that need to be built (and are in |roots|) to |result|. 459 that need to be built (and are in |roots|) to |result|.
458 roots: set of root targets. 460 roots: set of root targets.
(...skipping 18 matching lines...) Expand all
477 # built easier. 479 # built easier.
478 # And always add static_libraries that have no dependencies on them from 480 # And always add static_libraries that have no dependencies on them from
479 # linkables. This is necessary as the other dependencies on them may be 481 # linkables. This is necessary as the other dependencies on them may be
480 # static libraries themselves, which are not compile time dependencies. 482 # static libraries themselves, which are not compile time dependencies.
481 if target.in_roots and \ 483 if target.in_roots and \
482 (target.is_executable or 484 (target.is_executable or
483 (not target.added_to_compile_targets and 485 (not target.added_to_compile_targets and
484 (add_if_no_ancestor or target.requires_build)) or 486 (add_if_no_ancestor or target.requires_build)) or
485 (target.is_static_library and add_if_no_ancestor and 487 (target.is_static_library and add_if_no_ancestor and
486 not target.is_or_has_linked_ancestor)): 488 not target.is_or_has_linked_ancestor)):
487 print '\t\tadding to compile targets', target.name, 'executable', \ 489 print('\t\tadding to compile targets', target.name, 'executable',
488 target.is_executable, 'added_to_compile_targets', \ 490 target.is_executable, 'added_to_compile_targets',
489 target.added_to_compile_targets, 'add_if_no_ancestor', \ 491 target.added_to_compile_targets, 'add_if_no_ancestor',
490 add_if_no_ancestor, 'requires_build', target.requires_build, \ 492 add_if_no_ancestor, 'requires_build', target.requires_build,
491 'is_static_library', target.is_static_library, \ 493 'is_static_library', target.is_static_library,
492 'is_or_has_linked_ancestor', target.is_or_has_linked_ancestor 494 'is_or_has_linked_ancestor', target.is_or_has_linked_ancestor
495 )
493 result.add(target) 496 result.add(target)
494 target.added_to_compile_targets = True 497 target.added_to_compile_targets = True
495 498
496 499
497 def _GetCompileTargets(matching_targets, supplied_targets): 500 def _GetCompileTargets(matching_targets, supplied_targets):
498 """Returns the set of Targets that require a build. 501 """Returns the set of Targets that require a build.
499 matching_targets: targets that changed and need to be built. 502 matching_targets: targets that changed and need to be built.
500 supplied_targets: set of targets supplied to analyzer to search from.""" 503 supplied_targets: set of targets supplied to analyzer to search from."""
501 result = set() 504 result = set()
502 for target in matching_targets: 505 for target in matching_targets:
503 print 'finding compile targets for match', target.name 506 print('finding compile targets for match', target.name)
504 _AddCompileTargets(target, supplied_targets, True, result) 507 _AddCompileTargets(target, supplied_targets, True, result)
505 return result 508 return result
506 509
507 510
508 def _WriteOutput(params, **values): 511 def _WriteOutput(params, **values):
509 """Writes the output, either to stdout or a file is specified.""" 512 """Writes the output, either to stdout or a file is specified."""
510 if 'error' in values: 513 if 'error' in values:
511 print 'Error:', values['error'] 514 print('Error:', values['error'])
512 if 'status' in values: 515 if 'status' in values:
513 print values['status'] 516 print(values['status'])
514 if 'targets' in values: 517 if 'targets' in values:
515 values['targets'].sort() 518 values['targets'].sort()
516 print 'Supplied targets that depend on changed files:' 519 print('Supplied targets that depend on changed files:')
517 for target in values['targets']: 520 for target in values['targets']:
518 print '\t', target 521 print('\t', target)
519 if 'invalid_targets' in values: 522 if 'invalid_targets' in values:
520 values['invalid_targets'].sort() 523 values['invalid_targets'].sort()
521 print 'The following targets were not found:' 524 print('The following targets were not found:')
522 for target in values['invalid_targets']: 525 for target in values['invalid_targets']:
523 print '\t', target 526 print('\t', target)
524 if 'build_targets' in values: 527 if 'build_targets' in values:
525 values['build_targets'].sort() 528 values['build_targets'].sort()
526 print 'Targets that require a build:' 529 print('Targets that require a build:')
527 for target in values['build_targets']: 530 for target in values['build_targets']:
528 print '\t', target 531 print('\t', target)
529 if 'compile_targets' in values: 532 if 'compile_targets' in values:
530 values['compile_targets'].sort() 533 values['compile_targets'].sort()
531 print 'Targets that need to be built:' 534 print('Targets that need to be built:')
532 for target in values['compile_targets']: 535 for target in values['compile_targets']:
533 print '\t', target 536 print('\t', target)
534 if 'test_targets' in values: 537 if 'test_targets' in values:
535 values['test_targets'].sort() 538 values['test_targets'].sort()
536 print 'Test targets:' 539 print('Test targets:')
537 for target in values['test_targets']: 540 for target in values['test_targets']:
538 print '\t', target 541 print('\t', target)
539 542
540 output_path = params.get('generator_flags', {}).get( 543 output_path = params.get('generator_flags', {}).get(
541 'analyzer_output_path', None) 544 'analyzer_output_path', None)
542 if not output_path: 545 if not output_path:
543 print json.dumps(values) 546 print(json.dumps(values))
544 return 547 return
545 try: 548 try:
546 f = open(output_path, 'w') 549 f = open(output_path, 'w')
547 f.write(json.dumps(values) + '\n') 550 f.write(json.dumps(values) + '\n')
548 f.close() 551 f.close()
549 except IOError as e: 552 except IOError as e:
550 print 'Error writing to output file', output_path, str(e) 553 print('Error writing to output file', output_path, str(e))
551 554
552 555
553 def _WasGypIncludeFileModified(params, files): 556 def _WasGypIncludeFileModified(params, files):
554 """Returns true if one of the files in |files| is in the set of included 557 """Returns true if one of the files in |files| is in the set of included
555 files.""" 558 files."""
556 if params['options'].includes: 559 if params['options'].includes:
557 for include in params['options'].includes: 560 for include in params['options'].includes:
558 if _ToGypPath(os.path.normpath(include)) in files: 561 if _ToGypPath(os.path.normpath(include)) in files:
559 print 'Include file modified, assuming all changed', include 562 print('Include file modified, assuming all changed', include)
560 return True 563 return True
561 return False 564 return False
562 565
563 566
564 def _NamesNotIn(names, mapping): 567 def _NamesNotIn(names, mapping):
565 """Returns a list of the values in |names| that are not in |mapping|.""" 568 """Returns a list of the values in |names| that are not in |mapping|."""
566 return [name for name in names if name not in mapping] 569 return [name for name in names if name not in mapping]
567 570
568 571
569 def _LookupTargets(names, mapping): 572 def _LookupTargets(names, mapping):
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 test_target_names_no_all = set(self._test_target_names) 634 test_target_names_no_all = set(self._test_target_names)
632 test_target_names_no_all.discard('all') 635 test_target_names_no_all.discard('all')
633 test_targets_no_all = _LookupTargets(test_target_names_no_all, 636 test_targets_no_all = _LookupTargets(test_target_names_no_all,
634 self._unqualified_mapping) 637 self._unqualified_mapping)
635 test_target_names_contains_all = 'all' in self._test_target_names 638 test_target_names_contains_all = 'all' in self._test_target_names
636 if test_target_names_contains_all: 639 if test_target_names_contains_all:
637 test_targets = [x for x in (set(test_targets_no_all) | 640 test_targets = [x for x in (set(test_targets_no_all) |
638 set(self._root_targets))] 641 set(self._root_targets))]
639 else: 642 else:
640 test_targets = [x for x in test_targets_no_all] 643 test_targets = [x for x in test_targets_no_all]
641 print 'supplied test_targets' 644 print('supplied test_targets')
642 for target_name in self._test_target_names: 645 for target_name in self._test_target_names:
643 print '\t', target_name 646 print('\t', target_name)
644 print 'found test_targets' 647 print('found test_targets')
645 for target in test_targets: 648 for target in test_targets:
646 print '\t', target.name 649 print('\t', target.name)
647 print 'searching for matching test targets' 650 print('searching for matching test targets')
648 matching_test_targets = _GetTargetsDependingOnMatchingTargets(test_targets) 651 matching_test_targets = _GetTargetsDependingOnMatchingTargets(test_targets)
649 matching_test_targets_contains_all = (test_target_names_contains_all and 652 matching_test_targets_contains_all = (test_target_names_contains_all and
650 set(matching_test_targets) & 653 set(matching_test_targets) &
651 set(self._root_targets)) 654 set(self._root_targets))
652 if matching_test_targets_contains_all: 655 if matching_test_targets_contains_all:
653 # Remove any of the targets for all that were not explicitly supplied, 656 # Remove any of the targets for all that were not explicitly supplied,
654 # 'all' is subsequentely added to the matching names below. 657 # 'all' is subsequentely added to the matching names below.
655 matching_test_targets = [x for x in (set(matching_test_targets) & 658 matching_test_targets = [x for x in (set(matching_test_targets) &
656 set(test_targets_no_all))] 659 set(test_targets_no_all))]
657 print 'matched test_targets' 660 print('matched test_targets')
658 for target in matching_test_targets: 661 for target in matching_test_targets:
659 print '\t', target.name 662 print('\t', target.name)
660 matching_target_names = [gyp.common.ParseQualifiedTarget(target.name)[1] 663 matching_target_names = [gyp.common.ParseQualifiedTarget(target.name)[1]
661 for target in matching_test_targets] 664 for target in matching_test_targets]
662 if matching_test_targets_contains_all: 665 if matching_test_targets_contains_all:
663 matching_target_names.append('all') 666 matching_target_names.append('all')
664 print '\tall' 667 print('\tall')
665 return matching_target_names 668 return matching_target_names
666 669
667 def find_matching_compile_target_names(self): 670 def find_matching_compile_target_names(self):
668 """Returns the set of output compile targets.""" 671 """Returns the set of output compile targets."""
669 assert self.is_build_impacted(); 672 assert self.is_build_impacted();
670 # Compile targets are found by searching up from changed targets. 673 # Compile targets are found by searching up from changed targets.
671 # Reset the visited status for _GetBuildTargets. 674 # Reset the visited status for _GetBuildTargets.
672 for target in self._name_to_target.itervalues(): 675 for target in self._name_to_target.values():
673 target.visited = False 676 target.visited = False
674 677
675 supplied_targets = _LookupTargets(self._supplied_target_names_no_all(), 678 supplied_targets = _LookupTargets(self._supplied_target_names_no_all(),
676 self._unqualified_mapping) 679 self._unqualified_mapping)
677 if 'all' in self._supplied_target_names(): 680 if 'all' in self._supplied_target_names():
678 supplied_targets = [x for x in (set(supplied_targets) | 681 supplied_targets = [x for x in (set(supplied_targets) |
679 set(self._root_targets))] 682 set(self._root_targets))]
680 print 'Supplied test_targets & compile_targets' 683 print('Supplied test_targets & compile_targets')
681 for target in supplied_targets: 684 for target in supplied_targets:
682 print '\t', target.name 685 print('\t', target.name)
683 print 'Finding compile targets' 686 print('Finding compile targets')
684 compile_targets = _GetCompileTargets(self._changed_targets, 687 compile_targets = _GetCompileTargets(self._changed_targets,
685 supplied_targets) 688 supplied_targets)
686 return [gyp.common.ParseQualifiedTarget(target.name)[1] 689 return [gyp.common.ParseQualifiedTarget(target.name)[1]
687 for target in compile_targets] 690 for target in compile_targets]
688 691
689 692
690 def GenerateOutput(target_list, target_dicts, data, params): 693 def GenerateOutput(target_list, target_dicts, data, params):
691 """Called by gyp as the final stage. Outputs results.""" 694 """Called by gyp as the final stage. Outputs results."""
692 config = Config() 695 config = Config()
693 try: 696 try:
694 config.Init(params) 697 config.Init(params)
695 698
696 if not config.files: 699 if not config.files:
697 raise Exception('Must specify files to analyze via config_path generator ' 700 raise Exception('Must specify files to analyze via config_path generator '
698 'flag') 701 'flag')
699 702
700 toplevel_dir = _ToGypPath(os.path.abspath(params['options'].toplevel_dir)) 703 toplevel_dir = _ToGypPath(os.path.abspath(params['options'].toplevel_dir))
701 if debug: 704 if debug:
702 print 'toplevel_dir', toplevel_dir 705 print('toplevel_dir', toplevel_dir)
703 706
704 if _WasGypIncludeFileModified(params, config.files): 707 if _WasGypIncludeFileModified(params, config.files):
705 result_dict = { 'status': all_changed_string, 708 result_dict = { 'status': all_changed_string,
706 'test_targets': list(config.test_target_names), 709 'test_targets': list(config.test_target_names),
707 'compile_targets': list( 710 'compile_targets': list(
708 config.additional_compile_target_names | 711 config.additional_compile_target_names |
709 config.test_target_names) } 712 config.test_target_names) }
710 _WriteOutput(params, **result_dict) 713 _WriteOutput(params, **result_dict)
711 return 714 return
712 715
(...skipping 19 matching lines...) Expand all
732 found_at_least_one_target else no_dependency_string, 735 found_at_least_one_target else no_dependency_string,
733 'compile_targets': list( 736 'compile_targets': list(
734 set(compile_target_names) | 737 set(compile_target_names) |
735 set(test_target_names)) } 738 set(test_target_names)) }
736 if calculator.invalid_targets: 739 if calculator.invalid_targets:
737 result_dict['invalid_targets'] = calculator.invalid_targets 740 result_dict['invalid_targets'] = calculator.invalid_targets
738 _WriteOutput(params, **result_dict) 741 _WriteOutput(params, **result_dict)
739 742
740 except Exception as e: 743 except Exception as e:
741 _WriteOutput(params, error=str(e)) 744 _WriteOutput(params, error=str(e))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698