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

Unified Diff: build/android/gyp/util/build_utils.py

Issue 269943005: Add android_library template (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
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 607f9be2771039fdd20bf09bc3ee0e690a85d059..ba1224a1c6652828acdd81c2eaabf6dd4fc288fb 100644
--- a/build/android/gyp/util/build_utils.py
+++ b/build/android/gyp/util/build_utils.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import ast
import fnmatch
import json
import os
@@ -10,7 +11,18 @@ import shlex
import shutil
import subprocess
import sys
+import tempfile
+import traceback
Nico 2014/05/05 22:08:10 nit: 2 newlines between toplevels
cjhopman 2014/06/25 01:20:03 Done.
+class TempDir(object):
+ def __init__(self):
+ self.dir = tempfile.mkdtemp()
+
+ def __enter__(self):
+ return self.dir
+
+ def __exit__(self, type, value, traceback):
+ shutil.rmtree(self.dir)
Nico 2014/05/05 22:08:10 nit: Maybe: @contextmanager def TempDir(): dir
cjhopman 2014/06/25 01:20:03 Done.
Nico 2014/05/05 22:08:10 nit: 2 newlines between toplevels
cjhopman 2014/06/25 01:20:03 Done.
def MakeDirectory(dir_path):
try:
@@ -24,7 +36,10 @@ def DeleteDirectory(dir_path):
shutil.rmtree(dir_path)
-def Touch(path):
+def Touch(path, fail_if_missing=False):
+ if fail_if_missing and not os.path.exists(path):
+ raise Exception(path + ' doesn\'t exist.')
+
MakeDirectory(os.path.dirname(path))
with open(path, 'a'):
os.utime(path, None)
@@ -45,6 +60,10 @@ def FindInDirectories(directories, filename_filter):
return all_files
+def ParseGnList(gn_string):
+ return ast.literal_eval(gn_string)
+
+
def ParseGypList(gyp_string):
# The ninja generator doesn't support $ in strings, so use ## to
# represent $.
@@ -150,3 +169,28 @@ def PrintBigWarning(message):
print '***** ' * 8
PrintWarning(message)
print '***** ' * 8
+
Nico 2014/05/05 22:08:10 nit: 2 newlines
cjhopman 2014/06/25 01:20:03 Done.
+def GetPythonDependencies():
Nico 2014/05/05 22:08:10 docstring
cjhopman 2014/06/25 01:20:03 Done.
+ 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__, '..', '..', '..', '..'))
Nico 2014/05/05 22:08:10 Can you put this in a constant at the top of the f
cjhopman 2014/06/25 01:20:03 Done.
+
+ non_system_module_paths = [p for p in abs_module_paths if p.startswith(chromium_src)]
Nico 2014/05/05 22:08:10 nit: 80 cols
cjhopman 2014/06/25 01:20:03 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/05/05 22:08:10 Huh, so these are all absolute paths? Can we make
cjhopman 2014/06/25 01:20:03 Done.
+
Nico 2014/05/05 22:08:10 2 newlines
cjhopman 2014/06/25 01:20:03 Done.
+def WriteDepfile(path, dependencies):
+ with open(path, 'w') as depfile:
+ depfile.write(path)
+ depfile.write(': ')
+ depfile.write(' '.join(dependencies))
+ depfile.write('\n')

Powered by Google App Engine
This is Rietveld 408576698