diff options
author | cjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-23 18:38:32 +0000 |
---|---|---|
committer | cjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-23 18:38:32 +0000 |
commit | 2d401ff88410a222791306b4410d1d3ee60f6f20 (patch) | |
tree | 99449a3fcdac3b57ac619df922327618abebc28a | |
parent | e05c1c7a8450d3ed825f00ea0739f67fb857dee4 (diff) | |
download | chromium_src-2d401ff88410a222791306b4410d1d3ee60f6f20.zip chromium_src-2d401ff88410a222791306b4410d1d3ee60f6f20.tar.gz chromium_src-2d401ff88410a222791306b4410d1d3ee60f6f20.tar.bz2 |
Make process_resources.py more configurable
This allows more configuration of the aapt call from within gyp. This is primarily to support differences that are required to use process_resources.py for java_apk.gypi.
BUG=158821
Review URL: https://chromiumcodereview.appspot.com/12516019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190055 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | build/android/process_resources.py | 25 | ||||
-rw-r--r-- | build/java.gypi | 45 |
2 files changed, 42 insertions, 28 deletions
diff --git a/build/android/process_resources.py b/build/android/process_resources.py index a5e2878..f5de24d 100755 --- a/build/android/process_resources.py +++ b/build/android/process_resources.py @@ -10,9 +10,7 @@ import optparse import os import subprocess - -BUILD_ANDROID_DIR = os.path.dirname(__file__) - +from pylib import build_utils def ParseArgs(): """Parses command line options. @@ -24,11 +22,15 @@ def ParseArgs(): parser.add_option('--android-sdk', help='path to the Android SDK folder') parser.add_option('--android-sdk-tools', help='path to the Android SDK platform tools folder') - parser.add_option('--R-package', help='Java package for generated R.java') parser.add_option('--R-dir', help='directory to hold generated R.java') parser.add_option('--res-dir', help='directory containing resources') parser.add_option('--out-res-dir', help='directory to hold crunched resources') + parser.add_option('--non-constant-id', action='store_true') + parser.add_option('--custom-package', help='Java package for R.java') + parser.add_option('--android-manifest', help='AndroidManifest.xml path') + parser.add_option('--stamp', help='File to touch on success') + # This is part of a temporary fix for crbug.com/177552. # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. parser.add_option('--ignore', help='this argument is ignored') @@ -38,7 +40,7 @@ def ParseArgs(): parser.error('No positional arguments should be given.') # Check that required options have been provided. - required_options = ('android_sdk', 'android_sdk_tools', 'R_package', + required_options = ('android_sdk', 'android_sdk_tools', 'R_dir', 'res_dir', 'out_res_dir') for option_name in required_options: if getattr(options, option_name) is None: @@ -51,7 +53,8 @@ def main(): options = ParseArgs() android_jar = os.path.join(options.android_sdk, 'android.jar') aapt = os.path.join(options.android_sdk_tools, 'aapt') - dummy_manifest = os.path.join(BUILD_ANDROID_DIR, 'AndroidManifest.xml') + + build_utils.MakeDirectory(options.R_dir) # 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 @@ -61,9 +64,7 @@ def main(): package_command = [aapt, 'package', '-m', - '--non-constant-id', - '--custom-package', options.R_package, - '-M', dummy_manifest, + '-M', options.android_manifest, '-S', options.res_dir, '--auto-add-overlay', '-I', android_jar, @@ -72,6 +73,10 @@ def main(): # If strings.xml was generated from a grd file, it will be in out_res_dir. if os.path.isdir(options.out_res_dir): package_command += ['-S', options.out_res_dir] + if options.non_constant_id: + package_command.append('--non-constant-id') + if options.custom_package: + package_command += ['--custom-package', options.custom_package] subprocess.check_call(package_command) # Crunch image resources. This shrinks png files and is necessary for 9-patch @@ -81,6 +86,8 @@ def main(): '-S', options.res_dir, '-C', options.out_res_dir]) + build_utils.Touch(options.stamp) + if __name__ == '__main__': main() diff --git a/build/java.gypi b/build/java.gypi index 2758cd1..17a12fc9 100644 --- a/build/java.gypi +++ b/build/java.gypi @@ -47,16 +47,16 @@ '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' ], 'variables': { - 'input_jars_paths': [ '<(android_sdk_jar)' ], + 'android_jar': '<(android_sdk)/android.jar', + 'input_jars_paths': [ '<(android_jar)' ], 'additional_src_dirs': [], 'javac_includes': [], 'jar_name': '<(_target_name).jar', 'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', 'excluded_classes': [ '*/R.class', '*/R##*.class' ], - 'additional_input_paths': ['>@(additional_R_files)'], + 'additional_input_paths': [], 'generated_src_dirs': ['>@(generated_R_dirs)'], 'generated_R_dirs': [], - 'additional_R_files': [], 'has_java_resources%': 0, 'java_strings_grd%': '', 'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)', @@ -76,19 +76,20 @@ 'res_dir': '<(java_in_dir)/res', 'out_res_dir': '<(intermediate_dir)/res', 'R_dir': '<(intermediate_dir)/java_R', - 'R_file': '<(R_dir)/<(R_package_relpath)/R.java', 'R_text_file': '<(R_dir)/R.txt', + 'R_stamp': '<(intermediate_dir)/resources.stamp', 'generated_src_dirs': ['<(R_dir)'], - 'additional_input_paths': ['<(R_file)'], + 'additional_input_paths': ['<(R_stamp)'], # grit_grd_file is used by grit_action.gypi, included below. 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', + 'resource_input_paths': [], }, 'all_dependent_settings': { 'variables': { # Dependent jars include this target's R.java file via # generated_R_dirs and additional_R_files. 'generated_R_dirs': ['<(R_dir)'], - 'additional_R_files': ['<(R_file)'], + 'additional_input_paths': ['<(R_stamp)'], 'additional_R_text_files': ['<(R_text_file)'], # Dependent APKs include this target's resources via @@ -99,6 +100,14 @@ }, 'conditions': [ ['java_strings_grd != ""', { + 'variables': { + 'resource_input_paths': [ + # TODO(newt): replace this with .../values/strings.xml once + # the English strings.xml is generated as well? That would be + # simpler and faster and should be equivalent. + '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(out_res_dir)" <(grit_grd_file))', + ], + }, 'actions': [ { 'action_name': 'generate_localized_strings_xml', @@ -117,36 +126,34 @@ { 'action_name': 'process_resources', 'message': 'processing resources for <(_target_name)', - 'conditions': [ - ['java_strings_grd != ""', { - 'inputs': [ - # TODO(newt): replace this with .../values/strings.xml once - # the English strings.xml is generated as well? That would be - # simpler and faster and should be equivalent. - '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(out_res_dir)" <(grit_grd_file))', - ], - }], - ], + 'variables': { + 'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml', + }, 'inputs': [ + '<(DEPTH)/build/android/pylib/build_utils.py', '<(DEPTH)/build/android/process_resources.py', '<!@(find <(res_dir) -type f)', + '<@(resource_input_paths)', ], 'outputs': [ - '<(R_file)', + '<(R_stamp)', ], 'action': [ '<(DEPTH)/build/android/process_resources.py', '--android-sdk', '<(android_sdk)', '--android-sdk-tools', '<(android_sdk_tools)', - '--R-package', '<(R_package)', '--R-dir', '<(R_dir)', '--res-dir', '<(res_dir)', '--out-res-dir', '<(out_res_dir)', + '--android-manifest', '<(android_manifest)', + '--non-constant-id', + '--custom-package', '<(R_package)', + '--stamp', '<(R_stamp)', # Add list of inputs to the command line, so if inputs change # (e.g. if a resource if removed), the command will be re-run. # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. - '--ignore', '>(_inputs)', + '--ignore=>!(echo \'>(_inputs)\' | md5sum)', ], }, ], |