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 |
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 # Some clients do not add //build/android/gyp to PYTHONPATH. |
| 20 import md5_check # pylint: disable=relative-import |
19 | 21 |
20 CHROMIUM_SRC = os.path.normpath( | 22 CHROMIUM_SRC = os.path.normpath( |
21 os.path.join(os.path.dirname(__file__), | 23 os.path.join(os.path.dirname(__file__), |
22 os.pardir, os.pardir, os.pardir, os.pardir)) | 24 os.pardir, os.pardir, os.pardir, os.pardir)) |
23 COLORAMA_ROOT = os.path.join(CHROMIUM_SRC, | 25 COLORAMA_ROOT = os.path.join(CHROMIUM_SRC, |
24 'third_party', 'colorama', 'src') | 26 'third_party', 'colorama', 'src') |
25 # aapt should ignore OWNERS files in addition the default ignore pattern. | 27 # aapt should ignore OWNERS files in addition the default ignore pattern. |
26 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' + | 28 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' + |
27 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp') | 29 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp') |
28 HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0) | 30 HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0) |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 file_jsons[file_path] = ReadJson(file_path) | 394 file_jsons[file_path] = ReadJson(file_path) |
393 | 395 |
394 expansion = file_jsons[file_path] | 396 expansion = file_jsons[file_path] |
395 for k in lookup_path[1:]: | 397 for k in lookup_path[1:]: |
396 expansion = expansion[k] | 398 expansion = expansion[k] |
397 | 399 |
398 new_args[i] = arg[:match.start()] + str(expansion) | 400 new_args[i] = arg[:match.start()] + str(expansion) |
399 | 401 |
400 return new_args | 402 return new_args |
401 | 403 |
| 404 |
| 405 def CallAndWriteDepfileIfStale(function, options, record_path=None, |
| 406 input_paths=None, input_strings=None, |
| 407 output_paths=None, force=False): |
| 408 """Wraps md5_check.CallAndRecordIfStale() and also writes dep & stamp files. |
| 409 |
| 410 Depfiles and stamp files are automatically added to output_paths when present |
| 411 in the |options| argument. They are then created after |function| is called. |
| 412 """ |
| 413 if not output_paths: |
| 414 raise Exception('At least one output_path must be specified.') |
| 415 input_paths = list(input_paths or []) |
| 416 input_strings = list(input_strings or []) |
| 417 output_paths = list(output_paths or []) |
| 418 |
| 419 python_deps = None |
| 420 if hasattr(options, 'depfile') and options.depfile: |
| 421 python_deps = GetPythonDependencies() |
| 422 # List python deps in input_strings rather than input_paths since the |
| 423 # contents of them does not change what gets written to the depfile. |
| 424 input_strings += python_deps |
| 425 output_paths += [options.depfile] |
| 426 |
| 427 stamp_file = hasattr(options, 'stamp') and options.stamp |
| 428 if stamp_file: |
| 429 output_paths += [stamp_file] |
| 430 |
| 431 def on_stale_md5(): |
| 432 function() |
| 433 if python_deps is not None: |
| 434 WriteDepfile(options.depfile, python_deps + input_paths) |
| 435 if stamp_file: |
| 436 Touch(stamp_file) |
| 437 |
| 438 md5_check.CallAndRecordIfStale( |
| 439 on_stale_md5, |
| 440 record_path=record_path, |
| 441 input_paths=input_paths, |
| 442 input_strings=input_strings, |
| 443 output_paths=output_paths, |
| 444 force=force) |
| 445 |
OLD | NEW |