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

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

Issue 18653002: [Android] Add a gyp option to disable generating v14 resources script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed to --only-verify option. Please discard the previous patch set. Created 7 years, 5 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/java.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/generate_v14_compatible_resources.py
diff --git a/build/android/gyp/generate_v14_compatible_resources.py b/build/android/gyp/generate_v14_compatible_resources.py
index 6b848082adc544605f1bb88269aa9c59229e0296..e7efc6247535ec248a21c8ff4688200816c98985 100755
--- a/build/android/gyp/generate_v14_compatible_resources.py
+++ b/build/android/gyp/generate_v14_compatible_resources.py
@@ -98,16 +98,17 @@ def ErrorIfStyleResourceExistsInDir(input_dir):
if HasStyleResource(dom):
raise Exception('error: style file ' + input_filename +
' should be under ' + input_dir +
- '-v17 directory. Please refer to crbug.com/243952 '
- 'for the details.')
+ '-v17 directory. Please refer to '
+ 'http://crbug.com/243952 for the details.')
-def GenerateV14LayoutResourceDom(dom, filename):
+def GenerateV14LayoutResourceDom(dom, filename_for_warning):
newt (away) 2013/07/08 22:55:49 it's OK to print both a warning and an error if a
Kibeom Kim (inactive) 2013/07/09 00:20:50 Looks like we have to skip warning for pre-v17 bec
newt (away) 2013/07/09 00:52:49 Where is that call? I only see this method called
"""Convert layout resource to API 14 compatible layout resource.
Args:
dom: parsed minidom object to be modified.
- filename: file name to display in case we print warnings.
+ filename_for_warning: file name to display in case we print warnings.
+ If None, do not print warning.
Returns:
True if dom is modified, False otherwise.
"""
@@ -125,28 +126,35 @@ def GenerateV14LayoutResourceDom(dom, filename):
element.setAttribute(ATTRIBUTES_TO_MAP[name], value)
del element.attributes[name]
is_modified = True
- else:
- WarnIfDeprecatedAttribute(name, value, filename)
+ elif filename_for_warning:
+ WarnIfDeprecatedAttribute(name, value, filename_for_warning)
return is_modified
-def GenerateV14StyleResourceDom(dom, filename):
+def GenerateV14StyleResourceDom(dom, filename_for_warning):
"""Convert style resource to API 14 compatible style resource.
Args:
dom: parsed minidom object to be modified.
- filename: file name to display in case we print warnings.
+ filename_for_warning: file name to display in case we print warnings.
+ If None, do not print warning.
+ Returns:
+ True if dom is modified, False otherwise.
"""
+ is_modified = False
+
for style_element in dom.getElementsByTagName('style'):
for item_element in style_element.getElementsByTagName('item'):
name = item_element.attributes['name'].value
value = item_element.childNodes[0].nodeValue
if name in ATTRIBUTES_TO_MAP:
item_element.attributes['name'].value = ATTRIBUTES_TO_MAP[name]
- else:
- WarnIfDeprecatedAttribute(name, value, filename)
+ is_modified = True
+ elif filename_for_warning:
+ WarnIfDeprecatedAttribute(name, value, filename_for_warning)
+ return is_modified
def GenerateV14LayoutResource(input_filename, output_v14_filename,
output_v17_filename):
@@ -201,6 +209,17 @@ def GenerateV14StyleResourcesInDir(input_dir, output_v14_dir):
output_v14_filename = os.path.join(output_v14_dir, rel_filename)
GenerateV14StyleResource(input_filename, output_v14_filename)
+def VerifyNoRtlAttributeInDir(input_dir):
newt (away) 2013/07/08 22:55:49 how about "VerifyV14StyleResourcesInDir"?
Kibeom Kim (inactive) 2013/07/09 00:20:50 Done.
+ for input_filename in build_utils.FindInDirectory(input_dir, '*.xml'):
+ dom = minidom.parse(input_filename)
+ if (GenerateV14LayoutResourceDom(dom, None) or
newt (away) 2013/07/08 22:55:49 it's a bit odd to run both of these methods on the
Kibeom Kim (inactive) 2013/07/09 00:20:50 Done.
+ GenerateV14StyleResourceDom(dom, None)):
+ raise Exception('error : ' + input_filename +
+ ' has an RTL attribute, i.e., attribute that has "start"'
+ 'or "end" in its name. Pre-v17 resources should not '
+ 'include it because it can cause crashes on certain '
+ 'devices. Please refer to http://crbug.com/243952 '
+ 'for the details.')
def ParseArgs():
"""Parses command line options.
@@ -216,6 +235,9 @@ def ParseArgs():
help='output directory into which '
'v14 compatible resources will be generated')
parser.add_option('--stamp', help='File to touch on success')
+ parser.add_option('--only-verify', help='Do not generate v14 resources. '
newt (away) 2013/07/08 22:55:49 "Do not generate v14 resources. Instead, just veri
Kibeom Kim (inactive) 2013/07/09 00:20:50 Done.
+ 'Only verify it and raise an error if the current resource can '
+ 'cause crashes on certain devices.')
newt (away) 2013/07/08 22:55:49 use 'action="store_true"' here. then options.only_
Kibeom Kim (inactive) 2013/07/09 00:20:50 Done.
options, args = parser.parse_args()
@@ -230,6 +252,7 @@ def ParseArgs():
def main(argv):
options = ParseArgs()
+ only_verify = bool(options.only_verify) and int(options.only_verify) > 0
newt (away) 2013/07/08 22:55:49 remove this
Kibeom Kim (inactive) 2013/07/09 00:20:50 Done.
build_utils.DeleteDirectory(options.res_v14_compatibility_dir)
build_utils.MakeDirectory(options.res_v14_compatibility_dir)
@@ -254,29 +277,35 @@ def main(argv):
if 'ldrtl' in qualifiers:
continue
- # We also need to copy the original v17 resource to *-v17 directory
- # because the generated v14 resource will hide the original resource.
- input_dir = os.path.join(options.res_dir, name)
- output_v14_dir = os.path.join(options.res_v14_compatibility_dir, name)
- output_v17_dir = os.path.join(options.res_v14_compatibility_dir, name +
- '-v17')
-
- # We only convert layout resources under layout*/, xml*/,
- # and style resources under values*/.
- if resource_type in ('layout', 'xml'):
- if not api_level_qualifier:
- GenerateV14LayoutResourcesInDir(input_dir, output_v14_dir,
- output_v17_dir)
- elif resource_type == 'values':
- if api_level_qualifier == 'v17':
- output_qualifiers = qualifiers[:]
- del output_qualifiers[api_level_qualifier_index]
- output_v14_dir = os.path.join(options.res_v14_compatibility_dir,
- '-'.join([resource_type] +
- output_qualifiers))
- GenerateV14StyleResourcesInDir(input_dir, output_v14_dir)
- elif not api_level_qualifier:
- ErrorIfStyleResourceExistsInDir(input_dir)
+ input_dir = os.path.abspath(os.path.join(options.res_dir, name))
+
+ if only_verify:
+ if not api_level_qualifier or int(api_level_qualifier[1:]) < 17:
+ if resource_type in ('layout', 'xml', 'values'):
+ VerifyNoRtlAttributeInDir(input_dir)
+ else:
+ # We also need to copy the original v17 resource to *-v17 directory
+ # because the generated v14 resource will hide the original resource.
+ output_v14_dir = os.path.join(options.res_v14_compatibility_dir, name)
+ output_v17_dir = os.path.join(options.res_v14_compatibility_dir, name +
+ '-v17')
+
+ # We only convert layout resources under layout*/, xml*/,
+ # and style resources under values*/.
+ if resource_type in ('layout', 'xml'):
+ if not api_level_qualifier:
+ GenerateV14LayoutResourcesInDir(input_dir, output_v14_dir,
+ output_v17_dir)
+ elif resource_type == 'values':
+ if api_level_qualifier == 'v17':
+ output_qualifiers = qualifiers[:]
+ del output_qualifiers[api_level_qualifier_index]
+ output_v14_dir = os.path.join(options.res_v14_compatibility_dir,
+ '-'.join([resource_type] +
+ output_qualifiers))
+ GenerateV14StyleResourcesInDir(input_dir, output_v14_dir)
+ elif not api_level_qualifier:
+ ErrorIfStyleResourceExistsInDir(input_dir)
if options.stamp:
build_utils.Touch(options.stamp)
« no previous file with comments | « no previous file | build/java.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698