summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authornewt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-26 07:31:57 +0000
committernewt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-26 07:31:57 +0000
commit7dc7681f29d8692d4736f8bb93a536f68f374466 (patch)
tree687cc62325b52f06867d11ece1707eb2bebfe34e /build
parenta021bb66f63f12a26feb9da7b7c9792da60af543 (diff)
downloadchromium_src-7dc7681f29d8692d4736f8bb93a536f68f374466.zip
chromium_src-7dc7681f29d8692d4736f8bb93a536f68f374466.tar.gz
chromium_src-7dc7681f29d8692d4736f8bb93a536f68f374466.tar.bz2
Generate Android string files from generated_resources.grd.
This enables Android layouts and Java code to use strings from generated_resources.grd directly. Strings tagged with formatter_data="android_java" in generated_resources.grd are used to produce an Android strings xml file. BUG=176069 Review URL: https://chromiumcodereview.appspot.com/12529025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build')
-rwxr-xr-xbuild/android/process_resources.py25
-rw-r--r--build/common.gypi3
-rw-r--r--build/java.gypi43
-rw-r--r--build/java_apk.gypi19
4 files changed, 47 insertions, 43 deletions
diff --git a/build/android/process_resources.py b/build/android/process_resources.py
index f5de24d..63582df 100755
--- a/build/android/process_resources.py
+++ b/build/android/process_resources.py
@@ -8,6 +8,7 @@
import optparse
import os
+import shlex
import subprocess
from pylib import build_utils
@@ -23,8 +24,11 @@ def ParseArgs():
parser.add_option('--android-sdk-tools',
help='path to the Android SDK platform tools folder')
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',
+ parser.add_option('--res-dirs',
+ help='directories containing resources to be packaged')
+ parser.add_option('--crunch-input-dir',
+ help='directory containing images to be crunched')
+ parser.add_option('--crunch-output-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')
@@ -40,10 +44,10 @@ 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_dir', 'res_dir', 'out_res_dir')
+ required_options = ('android_sdk', 'android_sdk_tools', 'R_dir', 'res_dirs',
+ 'crunch_input_dir', 'crunch_output_dir')
for option_name in required_options:
- if getattr(options, option_name) is None:
+ if not getattr(options, option_name):
parser.error('--%s is required' % option_name.replace('_', '-'))
return options
@@ -65,14 +69,13 @@ def main():
'package',
'-m',
'-M', options.android_manifest,
- '-S', options.res_dir,
'--auto-add-overlay',
'-I', android_jar,
'--output-text-symbols', options.R_dir,
'-J', options.R_dir]
- # 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]
+ res_dirs = shlex.split(options.res_dirs)
+ for res_dir in res_dirs:
+ package_command += ['-S', res_dir]
if options.non_constant_id:
package_command.append('--non-constant-id')
if options.custom_package:
@@ -83,8 +86,8 @@ def main():
# images to display correctly.
subprocess.check_call([aapt,
'crunch',
- '-S', options.res_dir,
- '-C', options.out_res_dir])
+ '-S', options.crunch_input_dir,
+ '-C', options.crunch_output_dir])
build_utils.Touch(options.stamp)
diff --git a/build/common.gypi b/build/common.gypi
index 2aa4ef1..5f9b152 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -1434,7 +1434,8 @@
],
}],
['OS=="android"', {
- 'grit_defines': ['-D', 'android'],
+ 'grit_defines': ['-D', 'android',
+ '-E', 'ANDROID_JAVA_TAGGED_ONLY=true'],
}],
['OS=="mac"', {
'grit_defines': ['-D', 'scale_factors=2x'],
diff --git a/build/java.gypi b/build/java.gypi
index 17a12fc9..1ab72c2 100644
--- a/build/java.gypi
+++ b/build/java.gypi
@@ -41,6 +41,9 @@
# R_package_relpath - Same as R_package, but replace each '.' with '/'.
# java_strings_grd - The name of the grd file from which to generate localized
# strings.xml files, if any.
+# res_extra_dirs - A list of extra directories containing Android resources.
+# These directories may be generated at build time.
+# res_extra_files - A list of the files in res_extra_dirs.
{
'dependencies': [
@@ -59,6 +62,9 @@
'generated_R_dirs': [],
'has_java_resources%': 0,
'java_strings_grd%': '',
+ 'res_extra_dirs': [],
+ 'res_extra_files': [],
+ 'resource_input_paths': ['>@(res_extra_files)'],
'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)',
'classes_dir': '<(intermediate_dir)/classes',
'compile_stamp': '<(intermediate_dir)/compile.stamp',
@@ -74,15 +80,14 @@
['has_java_resources == 1', {
'variables': {
'res_dir': '<(java_in_dir)/res',
- 'out_res_dir': '<(intermediate_dir)/res',
+ 'res_crunched_dir': '<(intermediate_dir)/res_crunched',
+ 'res_input_dirs': ['<(res_dir)', '<@(res_extra_dirs)'],
+ 'resource_input_paths': ['<!@(find <(res_dir) -type f)'],
'R_dir': '<(intermediate_dir)/java_R',
'R_text_file': '<(R_dir)/R.txt',
'R_stamp': '<(intermediate_dir)/resources.stamp',
'generated_src_dirs': ['<(R_dir)'],
'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': {
@@ -90,29 +95,29 @@
# generated_R_dirs and additional_R_files.
'generated_R_dirs': ['<(R_dir)'],
'additional_input_paths': ['<(R_stamp)'],
- 'additional_R_text_files': ['<(R_text_file)'],
# Dependent APKs include this target's resources via
- # additional_res_dirs and additional_res_packages.
- 'additional_res_dirs': ['<(out_res_dir)', '<(res_dir)'],
+ # additional_res_dirs, additional_res_packages, and
+ # additional_R_text_files.
+ 'additional_res_dirs': ['<(res_crunched_dir)', '<@(res_input_dirs)'],
'additional_res_packages': ['<(R_package)'],
+ 'additional_R_text_files': ['<(R_text_file)'],
},
},
'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))',
- ],
+ 'res_grit_dir': '<(intermediate_dir)/res_grit',
+ 'res_input_dirs': ['<(res_grit_dir)'],
+ 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)',
+ 'resource_input_paths': ['<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(res_grit_dir)" <(grit_grd_file))'],
},
'actions': [
{
'action_name': 'generate_localized_strings_xml',
'variables': {
- 'grit_out_dir': '<(out_res_dir)',
+ 'grit_additional_defines': ['-E', 'ANDROID_JAVA_TAGGED_ONLY=false'],
+ 'grit_out_dir': '<(res_grit_dir)',
# resource_ids is unneeded since we don't generate .h headers.
'grit_resource_ids': '',
},
@@ -132,8 +137,7 @@
'inputs': [
'<(DEPTH)/build/android/pylib/build_utils.py',
'<(DEPTH)/build/android/process_resources.py',
- '<!@(find <(res_dir) -type f)',
- '<@(resource_input_paths)',
+ '>@(resource_input_paths)',
],
'outputs': [
'<(R_stamp)',
@@ -143,14 +147,15 @@
'--android-sdk', '<(android_sdk)',
'--android-sdk-tools', '<(android_sdk_tools)',
'--R-dir', '<(R_dir)',
- '--res-dir', '<(res_dir)',
- '--out-res-dir', '<(out_res_dir)',
+ '--res-dirs', '<(res_input_dirs)',
+ '--crunch-input-dir', '>(res_dir)',
+ '--crunch-output-dir', '<(res_crunched_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
+ # Add hash 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=>!(echo \'>(_inputs)\' | md5sum)',
diff --git a/build/java_apk.gypi b/build/java_apk.gypi
index 3f3e706..0aea316 100644
--- a/build/java_apk.gypi
+++ b/build/java_apk.gypi
@@ -69,7 +69,7 @@
'additional_res_packages': [],
'is_test_apk%': 0,
'java_strings_grd%': '',
- 'grit_grd_file%': '',
+ 'res_grit_files': [],
'library_manifest_paths%' : [],
},
'sources': [
@@ -118,16 +118,18 @@
}],
['java_strings_grd != ""', {
'variables': {
- 'out_res_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res',
- 'additional_res_dirs': ['<(out_res_dir)'],
+ 'res_grit_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res_grit',
+ 'additional_res_dirs': ['<(res_grit_dir)'],
# grit_grd_file is used by grit_action.gypi, included below.
'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)',
+ 'res_grit_files': ['<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(res_grit_dir)" <(grit_grd_file))'],
},
'actions': [
{
'action_name': 'generate_localized_strings_xml',
'variables': {
- 'grit_out_dir': '<(out_res_dir)',
+ 'grit_additional_defines': ['-E', 'ANDROID_JAVA_TAGGED_ONLY=false'],
+ 'grit_out_dir': '<(res_grit_dir)',
# resource_ids is unneeded since we don't generate .h headers.
'grit_resource_ids': '',
},
@@ -152,19 +154,12 @@
'>@(native_libs_paths)',
'>@(additional_input_paths)',
'>@(library_manifest_paths)',
+ '<@(res_grit_files)',
],
'conditions': [
['resource_dir!=""', {
'inputs': ['<!@(find <(java_in_dir)/<(resource_dir) -name "*")']
}],
- ['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))',
- ],
- }],
['is_test_apk == 1', {
'variables': {
'additional_res_dirs=': [],