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..ff836279a75ffb3972f7e2b6ae00b9ec14c25266 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,40 @@ def PrintBigWarning(message): |
print '***** ' * 8 |
PrintWarning(message) |
print '***** ' * 8 |
+ |
+ |
+def GetPythonDependencies(): |
+ """Gets the paths of imported non-system python modules. |
+ |
+ A path is assumed to be a "system" import if it is outside of chromium's |
+ src/. The paths will be relative to the current directory. |
+ """ |
+ 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) |
+ |
+ non_system_module_paths = [ |
+ p for p in abs_module_paths if p.startswith(CHROMIUM_SRC)] |
+ def ConvertPycToPy(s): |
+ if s.endswith('.pyc'): |
+ return s[:-1] |
+ return s |
+ |
+ non_system_module_paths = map(ConvertPycToPy, non_system_module_paths) |
+ non_system_module_paths = map(os.path.relpath, non_system_module_paths) |
+ return sorted(set(non_system_module_paths)) |
+ |
+ |
+def AddDepfileOption(parser): |
+ parser.add_option('--depfile', |
+ help='Path to depfile. This should be specified as the ' |
nyquist
2014/06/23 18:41:57
Should 'should' be 'must'?
cjhopman
2014/06/24 18:12:53
Done. I read this as "'Should' should be 'must'."
|
+ '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') |