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

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

Issue 1356873003: CallAndRecordIfStale(): Add knownledge of output_files, depfiles, stamp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@incremental-script-dep
Patch Set: add assert and remove map() Created 5 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/proguard.py ('k') | build/android/gyp/util/md5_check.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
11 import re 11 import re
12 import shlex 12 import shlex
13 import shutil 13 import shutil
14 import subprocess 14 import subprocess
15 import sys 15 import sys
16 import tempfile 16 import tempfile
17 import zipfile 17 import zipfile
18 18
19 from util import md5_check
19 20
20 CHROMIUM_SRC = os.path.normpath( 21 CHROMIUM_SRC = os.path.normpath(
21 os.path.join(os.path.dirname(__file__), 22 os.path.join(os.path.dirname(__file__),
22 os.pardir, os.pardir, os.pardir, os.pardir)) 23 os.pardir, os.pardir, os.pardir, os.pardir))
23 COLORAMA_ROOT = os.path.join(CHROMIUM_SRC, 24 COLORAMA_ROOT = os.path.join(CHROMIUM_SRC,
24 'third_party', 'colorama', 'src') 25 'third_party', 'colorama', 'src')
25 # aapt should ignore OWNERS files in addition the default ignore pattern. 26 # aapt should ignore OWNERS files in addition the default ignore pattern.
26 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' + 27 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' +
27 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp') 28 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp')
28 HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0) 29 HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0)
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 file_jsons[file_path] = ReadJson(file_path) 393 file_jsons[file_path] = ReadJson(file_path)
393 394
394 expansion = file_jsons[file_path] 395 expansion = file_jsons[file_path]
395 for k in lookup_path[1:]: 396 for k in lookup_path[1:]:
396 expansion = expansion[k] 397 expansion = expansion[k]
397 398
398 new_args[i] = arg[:match.start()] + str(expansion) 399 new_args[i] = arg[:match.start()] + str(expansion)
399 400
400 return new_args 401 return new_args
401 402
403
404 def CallAndWriteDepfileIfStale(function, options, record_path=None,
405 input_paths=None, input_strings=None,
406 output_paths=None, force=False):
407 """Wraps md5_check.CallAndRecordIfStale() and also writes dep & stamp files.
408
409 Depfiles and stamp files are automatically added to output_paths when present
410 in the |options| argument. They are then created after |function| is called.
411 """
412 if not output_paths:
413 raise Exception('At least one output_path must be specified.')
414 input_paths = list(input_paths or [])
415 input_strings = list(input_strings or [])
416 output_paths = list(output_paths or [])
417
418 python_deps = None
419 if hasattr(options, 'depfile') and options.depfile:
420 python_deps = GetPythonDependencies()
421 # List python deps in input_strings rather than input_paths since the
422 # contents of them does not change what gets written to the depfile.
423 input_strings += python_deps
424 output_paths += [options.depfile]
425
426 stamp_file = hasattr(options, 'stamp') and options.stamp
427 if stamp_file:
428 output_paths += [stamp_file]
429
430 def on_stale_md5():
431 function()
432 if python_deps is not None:
433 WriteDepfile(options.depfile, python_deps + input_paths)
434 if stamp_file:
435 Touch(stamp_file)
436
437 md5_check.CallAndRecordIfStale(
438 on_stale_md5,
439 record_path=record_path,
440 input_paths=input_paths,
441 input_strings=input_strings,
442 output_paths=output_paths,
443 force=force)
444
OLDNEW
« no previous file with comments | « build/android/gyp/proguard.py ('k') | build/android/gyp/util/md5_check.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698