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

Unified Diff: build/android/gyp/copy_v17_resources.py

Issue 14948008: [Android] Auto-generate v14 style xml resources from the exisitng v17 style resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« no previous file with comments | « no previous file | build/android/gyp/generate_v14_resources.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/copy_v17_resources.py
diff --git a/build/android/gyp/copy_v17_resources.py b/build/android/gyp/copy_v17_resources.py
index 81c9aed0a8a6db0801a291dea97ea583844ada6c..3a10d3f4e1493699e872389d3cc600182cdb4fbc 100755
--- a/build/android/gyp/copy_v17_resources.py
+++ b/build/android/gyp/copy_v17_resources.py
@@ -15,13 +15,21 @@ import optparse
import os
import shutil
import sys
+import xml.dom.minidom as minidom
from util import build_utils
-def CopyXmlResourcesInDir(input_dir, output_dir):
+def CopyXmlResourcesInDir(input_dir, output_dir, only_styles=False):
"""Copy all XML resources from input_dir to output_dir."""
for input_file in build_utils.FindInDirectory(input_dir, '*.xml'):
+ if only_styles:
+ # If the xml file does not have a style element,
+ # it's not style resource, so skip.
+ dom = minidom.parse(input_file)
+ if not dom.getElementsByTagName('style'):
+ continue
+
output_path = os.path.join(output_dir,
os.path.relpath(input_file, input_dir))
build_utils.MakeDirectory(os.path.dirname(output_path))
@@ -66,18 +74,21 @@ def main(argv):
resource_type = dir_pieces[0]
qualifiers = dir_pieces[1:]
- # We only copy resources under layout*/ and xml*/.
- if resource_type not in ('layout', 'xml'):
- continue
-
# Skip RTL resources because they are not supported by API 14.
if 'ldrtl' in qualifiers:
continue
- # Copy all the resource files.
- input_path = os.path.join(options.res_dir, name)
- output_path = os.path.join(options.res_v17_dir, name + '-v17')
- CopyXmlResourcesInDir(input_path, output_path)
+ input_dir = os.path.join(options.res_dir, name)
+ output_dir = os.path.join(options.res_v17_dir, name + '-v17')
+
+ # We only copy resources under layout*/, xml*/,
+ # and style resources under values*/.
+ # TODO(kkimlabs): don't process xml directly once all layouts have
+ # been moved out of XML directory. see http://crbug.com/238458
+ if resource_type in ('layout', 'xml'):
+ CopyXmlResourcesInDir(input_dir, output_dir)
+ elif resource_type in ('values'):
+ CopyXmlResourcesInDir(input_dir, output_dir, only_styles=True)
if options.stamp:
build_utils.Touch(options.stamp)
« no previous file with comments | « no previous file | build/android/gyp/generate_v14_resources.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698