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

Unified Diff: build/android/gradle/generate_gradle.py

Issue 2667023002: Android: Add owned resources to android studio (Closed)
Patch Set: Created 3 years, 11 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/gradle/generate_gradle.py
diff --git a/build/android/gradle/generate_gradle.py b/build/android/gradle/generate_gradle.py
index fbe0966ac3b40b2e4ce3ea8a5fb3b613eb9f5c18..f1c08cbee687ec03d75818e40011ba092cf1a334 100755
--- a/build/android/gradle/generate_gradle.py
+++ b/build/android/gradle/generate_gradle.py
@@ -34,6 +34,7 @@ _JAVA_SUBDIR = 'symlinked-java'
_SRCJARS_SUBDIR = 'extracted-srcjars'
_JNI_LIBS_SUBDIR = 'symlinked-libs'
_ARMEABI_SUBDIR = 'armeabi'
+_RES_SUBDIR = 'extracted-res'
_DEFAULT_TARGETS = [
# TODO(agrieve): Requires alternate android.jar to compile.
@@ -212,6 +213,18 @@ class _ProjectContextGenerator(object):
os.path.join(self.EntryOutputDir(entry), _SRCJARS_SUBDIR))
return java_dirs
+ def _GenResDirs(self, entry):
+ res_dirs = entry.DepsInfo().get('owned_resources_dirs', [])
agrieve 2017/02/01 19:24:12 nit: you're mutating the list that lives in the co
Peter Wen 2017/02/01 22:09:55 Done.
+ zips = entry.DepsInfo().get('owned_resources_zips', [])
agrieve 2017/02/01 19:24:12 nit: don't need the default value of [] since you
Peter Wen 2017/02/01 22:09:54 Done.
+ if zips:
+ res_dir = os.path.join(self.EntryOutputDir(entry), _RES_SUBDIR)
agrieve 2017/02/01 19:24:12 nit: add a comment that these are just for generat
Peter Wen 2017/02/01 22:09:55 Done.
+ for zip_path in _RebasePath(zips):
+ logging.info('Extracting %s to %s', zip_path, res_dir)
agrieve 2017/02/01 19:24:12 maybe: Make a helper function for this and share i
Peter Wen 2017/02/01 22:09:55 Done.
+ with zipfile.ZipFile(zip_path) as z:
+ z.extractall(res_dir)
+ res_dirs.append(res_dir)
+ return res_dirs
+
def _Relativize(self, entry, paths):
return _RebasePath(paths, self.EntryOutputDir(entry))
@@ -240,6 +253,7 @@ class _ProjectContextGenerator(object):
entry, android_test_manifest)
variables['java_dirs'] = self._Relativize(entry, self._GenJavaDirs(entry))
variables['jni_libs'] = self._Relativize(entry, self._GenJniLibs(entry))
+ variables['res_dirs'] = self._Relativize(entry, self._GenResDirs(entry))
deps = [_ProjectEntry.FromBuildConfigPath(p)
for p in entry.Gradle()['dependent_android_projects']]
variables['android_project_deps'] = [d.ProjectName() for d in deps]

Powered by Google App Engine
This is Rietveld 408576698