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. | 19 # Some clients do not add //build/android/gyp to PYTHONPATH. |
20 import md5_check # pylint: disable=relative-import | 20 import md5_check # pylint: disable=relative-import |
21 | 21 |
22 CHROMIUM_SRC = os.path.normpath( | 22 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) |
23 os.path.join(os.path.dirname(__file__), | 23 from pylib import constants |
24 os.pardir, os.pardir, os.pardir, os.pardir)) | 24 |
25 COLORAMA_ROOT = os.path.join(CHROMIUM_SRC, | 25 COLORAMA_ROOT = os.path.join(constants.DIR_SOURCE_ROOT, |
26 'third_party', 'colorama', 'src') | 26 'third_party', 'colorama', 'src') |
27 # aapt should ignore OWNERS files in addition the default ignore pattern. | 27 # aapt should ignore OWNERS files in addition the default ignore pattern. |
28 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' + | 28 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' + |
29 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp') | 29 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp') |
30 HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0) | 30 HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0) |
31 HERMETIC_FILE_ATTR = (0644 << 16L) | 31 HERMETIC_FILE_ATTR = (0644 << 16L) |
32 | 32 |
33 | 33 |
34 @contextlib.contextmanager | 34 @contextlib.contextmanager |
35 def TempDir(): | 35 def TempDir(): |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 """Gets the paths of imported non-system python modules. | 332 """Gets the paths of imported non-system python modules. |
333 | 333 |
334 A path is assumed to be a "system" import if it is outside of chromium's | 334 A path is assumed to be a "system" import if it is outside of chromium's |
335 src/. The paths will be relative to the current directory. | 335 src/. The paths will be relative to the current directory. |
336 """ | 336 """ |
337 module_paths = (m.__file__ for m in sys.modules.itervalues() | 337 module_paths = (m.__file__ for m in sys.modules.itervalues() |
338 if m is not None and hasattr(m, '__file__')) | 338 if m is not None and hasattr(m, '__file__')) |
339 | 339 |
340 abs_module_paths = map(os.path.abspath, module_paths) | 340 abs_module_paths = map(os.path.abspath, module_paths) |
341 | 341 |
| 342 assert os.path.isabs(constants.DIR_SOURCE_ROOT) |
342 non_system_module_paths = [ | 343 non_system_module_paths = [ |
343 p for p in abs_module_paths if p.startswith(CHROMIUM_SRC)] | 344 p for p in abs_module_paths if p.startswith(constants.DIR_SOURCE_ROOT)] |
344 def ConvertPycToPy(s): | 345 def ConvertPycToPy(s): |
345 if s.endswith('.pyc'): | 346 if s.endswith('.pyc'): |
346 return s[:-1] | 347 return s[:-1] |
347 return s | 348 return s |
348 | 349 |
349 non_system_module_paths = map(ConvertPycToPy, non_system_module_paths) | 350 non_system_module_paths = map(ConvertPycToPy, non_system_module_paths) |
350 non_system_module_paths = map(os.path.relpath, non_system_module_paths) | 351 non_system_module_paths = map(os.path.relpath, non_system_module_paths) |
351 return sorted(set(non_system_module_paths)) | 352 return sorted(set(non_system_module_paths)) |
352 | 353 |
353 | 354 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 446 |
446 md5_check.CallAndRecordIfStale( | 447 md5_check.CallAndRecordIfStale( |
447 on_stale_md5, | 448 on_stale_md5, |
448 record_path=record_path, | 449 record_path=record_path, |
449 input_paths=input_paths, | 450 input_paths=input_paths, |
450 input_strings=input_strings, | 451 input_strings=input_strings, |
451 output_paths=output_paths, | 452 output_paths=output_paths, |
452 force=force, | 453 force=force, |
453 pass_changes=True) | 454 pass_changes=True) |
454 | 455 |
OLD | NEW |