Chromium Code Reviews| Index: build/android/gyp/util/build_utils.py |
| diff --git a/build/android/gyp/util/build_utils.py b/build/android/gyp/util/build_utils.py |
| index 0b4466d440ea2283340fdeec9d63aa973e801c14..1ab76b30c938f68a96a5aaa11445138ce5fd9a57 100644 |
| --- a/build/android/gyp/util/build_utils.py |
| +++ b/build/android/gyp/util/build_utils.py |
| @@ -82,6 +82,7 @@ def CheckOptions(options, parser, required=None): |
| if getattr(options, option_name) is None: |
| parser.error('--%s is required' % option_name.replace('_', '-')) |
| + |
| def WriteJson(obj, path, only_if_changed=False): |
| old_dump = None |
| if os.path.exists(path): |
| @@ -94,6 +95,7 @@ def WriteJson(obj, path, only_if_changed=False): |
| with open(path, 'w') as outfile: |
| outfile.write(new_dump) |
| + |
| def ReadJson(path): |
| with open(path, 'r') as jsonfile: |
| return json.load(jsonfile) |
| @@ -212,3 +214,38 @@ def PrintBigWarning(message): |
| print '***** ' * 8 |
| PrintWarning(message) |
| print '***** ' * 8 |
| + |
| + |
| +def GetPythonDependencies(): |
| + """Gets the paths of imported non-system python modules.""" |
| + module_paths = (m.__file__ for m in sys.modules.itervalues() |
| + if m is not None and hasattr(m, '__file__')) |
| + |
| + abs_module_paths = map(os.path.abspath, module_paths) |
| + |
| + chromium_src = os.path.abspath( |
| + os.path.join(__file__, '..', '..', '..', '..')) |
| + |
| + non_system_module_paths = [ |
| + p for p in abs_module_paths if p.startswith(chromium_src)] |
|
Nico
2014/06/23 15:32:00
See thread ".d files and absolute paths" on gn-dev
cjhopman
2014/06/23 17:26:56
Done.
|
| + def ConvertPycToPy(s): |
| + if s.endswith('.pyc'): |
| + return s[:-1] |
| + return s |
| + |
| + non_system_module_paths = map(ConvertPycToPy, non_system_module_paths) |
| + return list(set(non_system_module_paths)) |
|
Nico
2014/06/23 15:32:00
set() means this won't have a deterministic order
cjhopman
2014/06/23 17:26:56
Done.
|
| + |
| + |
| +def AddDepfileOption(parser): |
| + parser.add_option('--depfile', |
| + help='Path to depfile. This should be specified as the ' |
| + 'action\'s first output.') |
| + |
| + |
| +def WriteDepfile(path, dependencies): |
| + with open(path, 'w') as depfile: |
| + depfile.write(path) |
| + depfile.write(': ') |
| + depfile.write(' '.join(dependencies)) |
| + depfile.write('\n') |