diff options
-rwxr-xr-x | build/android/gyp/generate_v14_compatible_resources.py | 30 | ||||
-rwxr-xr-x | build/android/gyp/process_resources.py | 27 | ||||
-rw-r--r-- | build/grit_action.gypi | 2 | ||||
-rw-r--r-- | build/java.gypi | 48 | ||||
-rw-r--r-- | build/java_apk.gypi | 21 |
5 files changed, 68 insertions, 60 deletions
diff --git a/build/android/gyp/generate_v14_compatible_resources.py b/build/android/gyp/generate_v14_compatible_resources.py index bbfa1e5..03874f0 100755 --- a/build/android/gyp/generate_v14_compatible_resources.py +++ b/build/android/gyp/generate_v14_compatible_resources.py @@ -280,15 +280,12 @@ def ParseArgs(): build_utils.CheckOptions(options, parser, required=required_options) return options +def GenerateV14Resources(res_dir, res_v14_dir, verify_only): + build_utils.DeleteDirectory(res_v14_dir) + build_utils.MakeDirectory(res_v14_dir) -def main(): - options = ParseArgs() - - build_utils.DeleteDirectory(options.res_v14_compatibility_dir) - build_utils.MakeDirectory(options.res_v14_compatibility_dir) - - for name in os.listdir(options.res_dir): - if not os.path.isdir(os.path.join(options.res_dir, name)): + for name in os.listdir(res_dir): + if not os.path.isdir(os.path.join(res_dir, name)): continue dir_pieces = name.split('-') @@ -307,9 +304,9 @@ def main(): if 'ldrtl' in qualifiers: continue - input_dir = os.path.abspath(os.path.join(options.res_dir, name)) + input_dir = os.path.abspath(os.path.join(res_dir, name)) - if options.verify_only: + if verify_only: if not api_level_qualifier or int(api_level_qualifier[1:]) < 17: VerifyV14ResourcesInDir(input_dir, resource_type) else: @@ -317,9 +314,8 @@ def main(): 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') + output_v14_dir = os.path.join(res_v14_dir, name) + output_v17_dir = os.path.join(res_v14_dir, name + '-v17') # We only convert layout resources under layout*/, xml*/, # and style resources under values*/. @@ -331,13 +327,19 @@ def main(): 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, + output_v14_dir = os.path.join(res_v14_dir, '-'.join([resource_type] + output_qualifiers)) GenerateV14StyleResourcesInDir(input_dir, output_v14_dir) elif not api_level_qualifier: ErrorIfStyleResourceExistsInDir(input_dir) +def main(): + options = ParseArgs() + + GenerateV14Resources( + options.res_dir, options.res_v14_compatibility_dir, options.verify_only) + if options.stamp: build_utils.Touch(options.stamp) diff --git a/build/android/gyp/process_resources.py b/build/android/gyp/process_resources.py index 64a7560..132cdf6 100755 --- a/build/android/gyp/process_resources.py +++ b/build/android/gyp/process_resources.py @@ -4,7 +4,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -"""Process Android library resources to generate R.java and crunched images.""" +"""Process Android resources to generate R.java, and prepare for packaging. + +This will crunch images and generate v14 compatible resources +(see generate_v14_compatible_resources.py). +""" import optparse import os @@ -12,6 +16,8 @@ import re import shlex import shutil +import generate_v14_compatible_resources + from util import build_utils def ParseArgs(): @@ -36,7 +42,16 @@ def ParseArgs(): parser.add_option('--android-manifest', help='AndroidManifest.xml path') parser.add_option('--proguard-file', help='Path to proguard.txt generated file') - parser.add_option('--stamp', help='File to touch on success') + + parser.add_option('--res-v14-compatibility-dir', + help='output directory into which ' + 'v14 compatible resources will be generated') + parser.add_option( + '--v14-verify-only', + action='store_true', + help='Do not generate v14 resources. Instead, just verify that the ' + 'resources are already compatible with v14, i.e. they don\'t use ' + 'attributes that cause crashes on certain devices.') parser.add_option( '--extra-res-packages', @@ -47,6 +62,8 @@ def ParseArgs(): 'list of resources to be included in the R.java file in the format ' 'generated by aapt') + parser.add_option('--stamp', help='File to touch on success') + (options, args) = parser.parse_args() if args: @@ -61,6 +78,7 @@ def ParseArgs(): 'resource_dir', 'crunch_output_dir', 'R_dir', + 'res_v14_compatibility_dir', ) build_utils.CheckOptions(options, parser, required=required_options) @@ -142,6 +160,11 @@ def main(): build_utils.DeleteDirectory(options.R_dir) build_utils.MakeDirectory(options.R_dir) + generate_v14_compatible_resources.GenerateV14Resources( + options.resource_dir, + options.res_v14_compatibility_dir, + options.v14_verify_only) + # Generate R.java. This R.java contains non-final constants and is used only # while compiling the library jar (e.g. chromium_content.jar). When building # an apk, a new R.java file with the correct resource -> ID mappings will be diff --git a/build/grit_action.gypi b/build/grit_action.gypi index fef961f..ab7a70b 100644 --- a/build/grit_action.gypi +++ b/build/grit_action.gypi @@ -10,7 +10,7 @@ # It would be really nice to do this with a rule instead of actions, but it # would need to determine inputs and outputs via grit_info on a per-file -# basis. GYP rules don’t currently support that. They could be extended to +# basis. GYP rules don't currently support that. They could be extended to # do this, but then every generator would need to be updated to handle this. { diff --git a/build/java.gypi b/build/java.gypi index d392206..a67c836 100644 --- a/build/java.gypi +++ b/build/java.gypi @@ -111,7 +111,6 @@ 'variables': { 'res_dir': '<(java_in_dir)/res', 'res_crunched_dir': '<(intermediate_dir)/res_crunched', - 'res_v14_compatibility_stamp': '<(intermediate_dir)/res_v14_compatibility.stamp', 'res_v14_compatibility_dir': '<(intermediate_dir)/res_v14_compatibility', 'res_input_dirs': ['<(res_dir)', '<@(res_extra_dirs)'], 'resource_input_paths': ['<!@(find <(res_dir) -type f)'], @@ -119,8 +118,7 @@ 'R_text_file': '<(R_dir)/R.txt', 'R_stamp': '<(intermediate_dir)/resources.stamp', 'generated_src_dirs': ['<(R_dir)'], - 'additional_input_paths': ['<(R_stamp)', - '<(res_v14_compatibility_stamp)',], + 'additional_input_paths': ['<(R_stamp)', ], 'additional_res_dirs': [], 'dependencies_res_input_dirs': [], 'dependencies_res_files': [], @@ -131,8 +129,7 @@ # generated_R_dirs and include its resources via # dependencies_res_files. 'generated_R_dirs': ['<(R_dir)'], - 'additional_input_paths': ['<(R_stamp)', - '<(res_v14_compatibility_stamp)',], + 'additional_input_paths': ['<(R_stamp)', ], 'dependencies_res_files': ['<@(resource_input_paths)'], 'dependencies_res_input_dirs': ['<@(res_input_dirs)'], @@ -165,11 +162,18 @@ '>@(dependencies_res_input_dirs)',], # Write the inputs list to a file, so that its mtime is updated when # the list of inputs changes. - 'inputs_list_file': '>|(java_resources.<(_target_name).gypcmd >@(resource_input_paths) >@(dependencies_res_files))' + 'inputs_list_file': '>|(java_resources.<(_target_name).gypcmd >@(resource_input_paths) >@(dependencies_res_files))', + 'process_resources_options': [], + 'conditions': [ + ['res_v14_verify_only == 1', { + 'process_resources_options': ['--v14-verify-only'] + }], + ], }, 'inputs': [ '<(DEPTH)/build/android/gyp/util/build_utils.py', '<(DEPTH)/build/android/gyp/process_resources.py', + '<(DEPTH)/build/android/gyp/generate_v14_compatible_resources.py', '>@(resource_input_paths)', '>@(dependencies_res_files)', '>(inputs_list_file)', @@ -184,43 +188,15 @@ '--R-dir', '<(R_dir)', '--dependencies-res-dirs', '>(dependencies_res_dirs)', '--resource-dir', '<(res_dir)', + '--res-v14-compatibility-dir', '<(res_v14_compatibility_dir)', '--crunch-output-dir', '<(res_crunched_dir)', '--android-manifest', '<(android_manifest)', '--non-constant-id', '--custom-package', '<(R_package)', '--stamp', '<(R_stamp)', + '<@(process_resources_options)', ], }, - # Generate API 14 resources. - { - 'action_name': 'generate_api_14_resources_<(_target_name)', - 'message': 'Generating Android API 14 resources <(_target_name)', - 'variables' : { - 'res_v14_additional_options': [], - }, - 'conditions': [ - ['res_v14_verify_only == 1', { - 'variables': { - 'res_v14_additional_options': ['--verify-only'] - }, - }], - ], - 'inputs': [ - '<(DEPTH)/build/android/gyp/util/build_utils.py', - '<(DEPTH)/build/android/gyp/generate_v14_compatible_resources.py', - '>@(resource_input_paths)', - ], - 'outputs': [ - '<(res_v14_compatibility_stamp)', - ], - 'action': [ - 'python', '<(DEPTH)/build/android/gyp/generate_v14_compatible_resources.py', - '--res-dir=<(res_dir)', - '--res-v14-compatibility-dir=<(res_v14_compatibility_dir)', - '--stamp', '<(res_v14_compatibility_stamp)', - '<@(res_v14_additional_options)', - ] - }, ], }], ['proguard_preprocess == 1', { diff --git a/build/java_apk.gypi b/build/java_apk.gypi index c94959a..1d8fa8e 100644 --- a/build/java_apk.gypi +++ b/build/java_apk.gypi @@ -65,6 +65,7 @@ 'proguard_flags_paths': ['<(generated_proguard_file)'], 'jar_name': 'chromium_apk_<(_target_name).jar', 'resource_dir%':'<(DEPTH)/build/android/ant/empty/res', + 'res_v14_compatibility_dir': '<(intermediate_dir)/res_v14_compatibility', 'R_package%':'', 'additional_R_text_files': [], 'additional_res_dirs': [], @@ -115,6 +116,7 @@ 'symlink_script_host_path': '<(intermediate_dir)/create_symlinks.sh', 'symlink_script_device_path': '<(device_intermediate_dir)/create_symlinks.sh', 'create_standalone_apk%': 1, + 'res_v14_verify_only%': 0, 'variables': { 'variables': { 'native_lib_target%': '', @@ -444,15 +446,17 @@ # Write the inputs list to a file, so that its mtime is updated when # the list of inputs changes. 'inputs_list_file': '>|(apk_codegen.<(_target_name).gypcmd >@(additional_input_paths) >@(resource_input_paths))', - }, - 'conditions': [ - ['is_test_apk == 1', { - 'variables': { + 'process_resources_options': [], + 'conditions': [ + ['is_test_apk == 1', { 'additional_res_dirs=': [], 'additional_res_packages=': [], - } - }], - ], + }], + ['res_v14_verify_only == 1', { + 'process_resources_options': ['--v14-verify-only'] + }], + ], + }, 'inputs': [ '<(DEPTH)/build/android/gyp/util/build_utils.py', '<(DEPTH)/build/android/gyp/process_resources.py', @@ -479,11 +483,14 @@ '--proguard-file', '<(generated_proguard_file)', '--resource-dir', '<(resource_dir)', + '--res-v14-compatibility-dir', '<(res_v14_compatibility_dir)', '--crunch-output-dir', '<(crunch_output_dir)', '--R-dir', '<(intermediate_dir)/gen', '--stamp', '<(codegen_stamp)', + + '<@(process_resources_options)', ], }, { |