| 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. |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 # If a build file (or any of its included files) is modified we assume all | 331 # If a build file (or any of its included files) is modified we assume all |
| 332 # targets in the file are modified. | 332 # targets in the file are modified. |
| 333 if build_file_in_files[build_file]: | 333 if build_file_in_files[build_file]: |
| 334 print 'matching target from modified build file', target_name | 334 print 'matching target from modified build file', target_name |
| 335 target.match_status = MATCH_STATUS_MATCHES | 335 target.match_status = MATCH_STATUS_MATCHES |
| 336 matching_targets.append(target) | 336 matching_targets.append(target) |
| 337 else: | 337 else: |
| 338 sources = _ExtractSources(target_name, target_dicts[target_name], | 338 sources = _ExtractSources(target_name, target_dicts[target_name], |
| 339 toplevel_dir) | 339 toplevel_dir) |
| 340 for source in sources: | 340 for source in sources: |
| 341 if os.path.normpath(source) in files: | 341 if _ToGypPath(os.path.normpath(source)) in files: |
| 342 print 'target', target_name, 'matches', source | 342 print 'target', target_name, 'matches', source |
| 343 target.match_status = MATCH_STATUS_MATCHES | 343 target.match_status = MATCH_STATUS_MATCHES |
| 344 matching_targets.append(target) | 344 matching_targets.append(target) |
| 345 break | 345 break |
| 346 | 346 |
| 347 # Add dependencies to visit as well as updating back pointers for deps. | 347 # Add dependencies to visit as well as updating back pointers for deps. |
| 348 for dep in target_dicts[target_name].get('dependencies', []): | 348 for dep in target_dicts[target_name].get('dependencies', []): |
| 349 targets_to_visit.append(dep) | 349 targets_to_visit.append(dep) |
| 350 | 350 |
| 351 created_dep_target, dep_target = _GetOrCreateTargetByName(targets, dep) | 351 created_dep_target, dep_target = _GetOrCreateTargetByName(targets, dep) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 f.close() | 491 f.close() |
| 492 except IOError as e: | 492 except IOError as e: |
| 493 print 'Error writing to output file', output_path, str(e) | 493 print 'Error writing to output file', output_path, str(e) |
| 494 | 494 |
| 495 | 495 |
| 496 def _WasGypIncludeFileModified(params, files): | 496 def _WasGypIncludeFileModified(params, files): |
| 497 """Returns true if one of the files in |files| is in the set of included | 497 """Returns true if one of the files in |files| is in the set of included |
| 498 files.""" | 498 files.""" |
| 499 if params['options'].includes: | 499 if params['options'].includes: |
| 500 for include in params['options'].includes: | 500 for include in params['options'].includes: |
| 501 if _ToGypPath(include) in files: | 501 if _ToGypPath(os.path.normpath(include)) in files: |
| 502 print 'Include file modified, assuming all changed', include | 502 print 'Include file modified, assuming all changed', include |
| 503 return True | 503 return True |
| 504 return False | 504 return False |
| 505 | 505 |
| 506 | 506 |
| 507 def _NamesNotIn(names, mapping): | 507 def _NamesNotIn(names, mapping): |
| 508 """Returns a list of the values in |names| that are not in |mapping|.""" | 508 """Returns a list of the values in |names| that are not in |mapping|.""" |
| 509 return [name for name in names if name not in mapping] | 509 return [name for name in names if name not in mapping] |
| 510 | 510 |
| 511 | 511 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 result_dict = { 'targets': matched_search_targets, | 599 result_dict = { 'targets': matched_search_targets, |
| 600 'status': found_dependency_string if matching_targets else | 600 'status': found_dependency_string if matching_targets else |
| 601 no_dependency_string, | 601 no_dependency_string, |
| 602 'build_targets': build_targets} | 602 'build_targets': build_targets} |
| 603 if invalid_targets: | 603 if invalid_targets: |
| 604 result_dict['invalid_targets'] = invalid_targets | 604 result_dict['invalid_targets'] = invalid_targets |
| 605 _WriteOutput(params, **result_dict) | 605 _WriteOutput(params, **result_dict) |
| 606 | 606 |
| 607 except Exception as e: | 607 except Exception as e: |
| 608 _WriteOutput(params, error=str(e)) | 608 _WriteOutput(params, error=str(e)) |
| OLD | NEW |