Add creation of v14 compatible resources to process_resources.py
There are a lot of steps in processing resources and preparing them for packaging. It will be easier if these are all done by the same script. BUG=375431,359249 Review URL: https://codereview.chromium.org/321453002 git-svn-id: http://src.chromium.org/svn/trunk/src/build@275401 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
d60afc0a86
Коммит
fd4f1b695a
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
||||
{
|
||||
|
|
48
java.gypi
48
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', {
|
||||
|
|
|
@ -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': [],
|
||||
|
@ -479,6 +480,7 @@
|
|||
'--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',
|
||||
|
|
Загрузка…
Ссылка в новой задаче