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

Side by Side Diff: build/android/gyp/util/build_utils.py

Issue 2336173003: Fix android depfiles to always list GN's outputs[0] (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « build/android/gyp/pack_relocations.py ('k') | build/android/gyp/write_build_config.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 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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 def AddDepfileOption(parser): 416 def AddDepfileOption(parser):
417 # TODO(agrieve): Get rid of this once we've moved to argparse. 417 # TODO(agrieve): Get rid of this once we've moved to argparse.
418 if hasattr(parser, 'add_option'): 418 if hasattr(parser, 'add_option'):
419 func = parser.add_option 419 func = parser.add_option
420 else: 420 else:
421 func = parser.add_argument 421 func = parser.add_argument
422 func('--depfile', 422 func('--depfile',
423 help='Path to depfile. Must be specified as the action\'s first output.') 423 help='Path to depfile. Must be specified as the action\'s first output.')
424 424
425 425
426 def WriteDepfile(path, dependencies): 426 def WriteDepfile(depfile_path, first_gn_output, inputs=None, add_pydeps=True):
427 MakeDirectory(os.path.dirname(path)) 427 assert depfile_path != first_gn_output # http://crbug.com/646165
428 with open(path, 'w') as depfile: 428 inputs = inputs or []
429 depfile.write(path) 429 if add_pydeps:
430 inputs = GetPythonDependencies() + inputs
431 MakeDirectory(os.path.dirname(depfile_path))
432 # Ninja does not support multiple outputs in depfiles.
433 with open(depfile_path, 'w') as depfile:
434 depfile.write(first_gn_output.replace(' ', '\\ '))
jbudorick 2016/09/13 21:43:27 Heads up: this broke the (currently experimental)
430 depfile.write(': ') 435 depfile.write(': ')
431 depfile.write(' '.join(dependencies)) 436 depfile.write(' '.join(i.replace(' ', '\\ ') for i in inputs))
432 depfile.write('\n') 437 depfile.write('\n')
433 438
434 439
435 def ExpandFileArgs(args): 440 def ExpandFileArgs(args):
436 """Replaces file-arg placeholders in args. 441 """Replaces file-arg placeholders in args.
437 442
438 These placeholders have the form: 443 These placeholders have the form:
439 @FileArg(filename:key1:key2:...:keyn) 444 @FileArg(filename:key1:key2:...:keyn)
440 445
441 The value of such a placeholder is calculated by reading 'filename' as json. 446 The value of such a placeholder is calculated by reading 'filename' as json.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 if stamp_file: 522 if stamp_file:
518 output_paths += [stamp_file] 523 output_paths += [stamp_file]
519 524
520 def on_stale_md5(changes): 525 def on_stale_md5(changes):
521 args = (changes,) if pass_changes else () 526 args = (changes,) if pass_changes else ()
522 function(*args) 527 function(*args)
523 if python_deps is not None: 528 if python_deps is not None:
524 all_depfile_deps = list(python_deps) 529 all_depfile_deps = list(python_deps)
525 if depfile_deps: 530 if depfile_deps:
526 all_depfile_deps.extend(depfile_deps) 531 all_depfile_deps.extend(depfile_deps)
527 WriteDepfile(options.depfile, all_depfile_deps) 532 WriteDepfile(options.depfile, output_paths[0], all_depfile_deps,
533 add_pydeps=False)
528 if stamp_file: 534 if stamp_file:
529 Touch(stamp_file) 535 Touch(stamp_file)
530 536
531 md5_check.CallAndRecordIfStale( 537 md5_check.CallAndRecordIfStale(
532 on_stale_md5, 538 on_stale_md5,
533 record_path=record_path, 539 record_path=record_path,
534 input_paths=input_paths, 540 input_paths=input_paths,
535 input_strings=input_strings, 541 input_strings=input_strings,
536 output_paths=output_paths, 542 output_paths=output_paths,
537 force=force, 543 force=force,
538 pass_changes=True) 544 pass_changes=True)
539 545
OLDNEW
« no previous file with comments | « build/android/gyp/pack_relocations.py ('k') | build/android/gyp/write_build_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698