OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. 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 import ast | 5 import ast |
6 import contextlib | 6 import contextlib |
7 import fnmatch | 7 import fnmatch |
8 import json | 8 import json |
9 import os | 9 import os |
10 import pipes | 10 import pipes |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 expansion = expansion[k] | 464 expansion = expansion[k] |
465 | 465 |
466 new_args[i] = arg[:match.start()] + str(expansion) | 466 new_args[i] = arg[:match.start()] + str(expansion) |
467 | 467 |
468 return new_args | 468 return new_args |
469 | 469 |
470 | 470 |
471 def CallAndWriteDepfileIfStale(function, options, record_path=None, | 471 def CallAndWriteDepfileIfStale(function, options, record_path=None, |
472 input_paths=None, input_strings=None, | 472 input_paths=None, input_strings=None, |
473 output_paths=None, force=False, | 473 output_paths=None, force=False, |
474 pass_changes=False): | 474 pass_changes=False, |
475 depfile_deps=None): | |
475 """Wraps md5_check.CallAndRecordIfStale() and also writes dep & stamp files. | 476 """Wraps md5_check.CallAndRecordIfStale() and also writes dep & stamp files. |
476 | 477 |
477 Depfiles and stamp files are automatically added to output_paths when present | 478 Depfiles and stamp files are automatically added to output_paths when present |
478 in the |options| argument. They are then created after |function| is called. | 479 in the |options| argument. They are then created after |function| is called. |
480 | |
481 By default, only python dependencies are added to the depfile. If there are | |
482 other input paths that are not captured by GN deps, then they should be listed | |
483 in depfile_deps. It's important to write paths to the depfile that are already | |
484 captured by GN deps since GN args can cause GN deps to change, and such | |
485 changes are not immediately reflected in depfiles (http://crbug.com/589311). | |
479 """ | 486 """ |
480 if not output_paths: | 487 if not output_paths: |
481 raise Exception('At least one output_path must be specified.') | 488 raise Exception('At least one output_path must be specified.') |
482 input_paths = list(input_paths or []) | 489 input_paths = list(input_paths or []) |
483 input_strings = list(input_strings or []) | 490 input_strings = list(input_strings or []) |
484 output_paths = list(output_paths or []) | 491 output_paths = list(output_paths or []) |
485 | 492 |
486 python_deps = None | 493 python_deps = None |
487 if hasattr(options, 'depfile') and options.depfile: | 494 if hasattr(options, 'depfile') and options.depfile: |
488 python_deps = GetPythonDependencies() | 495 python_deps = GetPythonDependencies() |
489 # List python deps in input_strings rather than input_paths since the | 496 # List python deps in input_strings rather than input_paths since the |
490 # contents of them does not change what gets written to the depfile. | 497 # contents of them does not change what gets written to the depfile. |
491 input_strings += python_deps | 498 input_strings += python_deps |
492 output_paths += [options.depfile] | 499 output_paths += [options.depfile] |
493 | 500 |
494 stamp_file = hasattr(options, 'stamp') and options.stamp | 501 stamp_file = hasattr(options, 'stamp') and options.stamp |
495 if stamp_file: | 502 if stamp_file: |
496 output_paths += [stamp_file] | 503 output_paths += [stamp_file] |
497 | 504 |
498 def on_stale_md5(changes): | 505 def on_stale_md5(changes): |
499 args = (changes,) if pass_changes else () | 506 args = (changes,) if pass_changes else () |
500 function(*args) | 507 function(*args) |
501 if python_deps is not None: | 508 if python_deps is not None: |
502 WriteDepfile(options.depfile, python_deps + input_paths) | 509 all_depfile_deps = list(python_deps) |
jbudorick
2016/03/09 16:31:08
What happened to input_paths?
agrieve
2016/03/11 15:21:13
That's the fix. Have a look at the new comment I a
jbudorick
2016/03/11 15:24:17
definitely skipped right through that comment the
| |
510 if depfile_deps: | |
511 all_depfile_deps.extend(depfile_deps) | |
512 WriteDepfile(options.depfile, all_depfile_deps) | |
503 if stamp_file: | 513 if stamp_file: |
504 Touch(stamp_file) | 514 Touch(stamp_file) |
505 | 515 |
506 md5_check.CallAndRecordIfStale( | 516 md5_check.CallAndRecordIfStale( |
507 on_stale_md5, | 517 on_stale_md5, |
508 record_path=record_path, | 518 record_path=record_path, |
509 input_paths=input_paths, | 519 input_paths=input_paths, |
510 input_strings=input_strings, | 520 input_strings=input_strings, |
511 output_paths=output_paths, | 521 output_paths=output_paths, |
512 force=force, | 522 force=force, |
513 pass_changes=True) | 523 pass_changes=True) |
514 | 524 |
OLD | NEW |