summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorcjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-11 01:20:55 +0000
committercjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-11 01:20:55 +0000
commit10198a4457165fdfed8d920c39ec5bda60405657 (patch)
tree1a58b38b0d10ea3c7ea56befedb32670438f0fc3 /build
parenta827a56218099cbb06ae49c89c6dea6c32a2644f (diff)
downloadchromium_src-10198a4457165fdfed8d920c39ec5bda60405657.zip
chromium_src-10198a4457165fdfed8d920c39ec5bda60405657.tar.gz
chromium_src-10198a4457165fdfed8d920c39ec5bda60405657.tar.bz2
Pass resources to dependents as zip files instead of directories
This makes all temporary work be done in temporary directories. This change is particularly helpful for 2 reasons: first, it makes it more difficult to accidentally include stale, unwanted files during an incremental build. Second, it is easier to trigger dependent actions (zip file timestamps should be updated when their contents change, while the same is not true for directories). Makes the output of build/java_strings_grd.gypi be a zipfile containing the resources. BUG=359249,375431 Review URL: https://codereview.chromium.org/321463002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276226 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build')
-rwxr-xr-xbuild/android/gyp/package_resources.py88
-rwxr-xr-xbuild/android/gyp/process_resources.py197
-rw-r--r--build/android/gyp/util/build_utils.py45
-rwxr-xr-xbuild/android/gyp/zip.py26
-rw-r--r--build/java.gypi64
-rw-r--r--build/java_apk.gypi41
-rw-r--r--build/java_strings_grd.gypi42
7 files changed, 306 insertions, 197 deletions
diff --git a/build/android/gyp/package_resources.py b/build/android/gyp/package_resources.py
index cdb7bc61..7a7e16c 100755
--- a/build/android/gyp/package_resources.py
+++ b/build/android/gyp/package_resources.py
@@ -15,6 +15,7 @@ https://android.googlesource.com/platform/sdk/+/master/files/ant/build.xml
import optparse
import os
+import shutil
from util import build_utils
@@ -35,8 +36,8 @@ def ParseArgs():
parser.add_option('--android-manifest', help='AndroidManifest.xml path')
parser.add_option('--version-code', help='Version code for apk.')
parser.add_option('--version-name', help='Version name for apk.')
- parser.add_option('--resource-dirs',
- help='directories containing resources to be packaged')
+ parser.add_option('--resource-zips',
+ help='zip files containing resources to be packaged')
parser.add_option('--asset-dir',
help='directories containing assets to be packaged')
@@ -51,42 +52,75 @@ def ParseArgs():
# Check that required options have been provided.
required_options = ('android_sdk', 'android_sdk_tools', 'configuration_name',
'android_manifest', 'version_code', 'version_name',
- 'asset_dir', 'apk_path')
+ 'resource_zips', 'asset_dir', 'apk_path')
build_utils.CheckOptions(options, parser, required=required_options)
return options
+def MoveImagesToNonMdpiFolders(res_root):
+ """Move images from drawable-*-mdpi-* folders to drawable-* folders.
+
+ Why? http://crbug.com/289843
+ """
+ for src_dir_name in os.listdir(res_root):
+ src_components = src_dir_name.split('-')
+ if src_components[0] != 'drawable' or 'mdpi' not in src_components:
+ continue
+ src_dir = os.path.join(res_root, src_dir_name)
+ if not os.path.isdir(src_dir):
+ continue
+ dst_components = [c for c in src_components if c != 'mdpi']
+ assert dst_components != src_components
+ dst_dir_name = '-'.join(dst_components)
+ dst_dir = os.path.join(res_root, dst_dir_name)
+ build_utils.MakeDirectory(dst_dir)
+ for src_file_name in os.listdir(src_dir):
+ if not src_file_name.endswith('.png'):
+ continue
+ src_file = os.path.join(src_dir, src_file_name)
+ dst_file = os.path.join(dst_dir, src_file_name)
+ assert not os.path.lexists(dst_file)
+ shutil.move(src_file, dst_file)
+
+
def main():
options = ParseArgs()
android_jar = os.path.join(options.android_sdk, 'android.jar')
aapt = os.path.join(options.android_sdk_tools, 'aapt')
- package_command = [aapt,
- 'package',
- '--version-code', options.version_code,
- '--version-name', options.version_name,
- '-M', options.android_manifest,
- '--no-crunch',
- '-f',
- '--auto-add-overlay',
-
- '-I', android_jar,
- '-F', options.apk_path,
- ]
-
- if os.path.exists(options.asset_dir):
- package_command += ['-A', options.asset_dir]
-
- for p in build_utils.ParseGypList(options.resource_dirs):
- package_command += ['-S', p]
-
- if 'Debug' in options.configuration_name:
- package_command += ['--debug-mode']
-
- build_utils.CheckOutput(
- package_command, print_stdout=False, print_stderr=False)
+ with build_utils.TempDir() as temp_dir:
+ package_command = [aapt,
+ 'package',
+ '--version-code', options.version_code,
+ '--version-name', options.version_name,
+ '-M', options.android_manifest,
+ '--no-crunch',
+ '-f',
+ '--auto-add-overlay',
+
+ '-I', android_jar,
+ '-F', options.apk_path,
+ ]
+
+ if os.path.exists(options.asset_dir):
+ package_command += ['-A', options.asset_dir]
+
+ dep_zips = build_utils.ParseGypList(options.resource_zips)
+ for z in dep_zips:
+ subdir = os.path.join(temp_dir, os.path.basename(z))
+ if os.path.exists(subdir):
+ raise Exception('Resource zip name conflict: ' + os.path.basename(z))
+ build_utils.ExtractAll(z, path=subdir)
+ MoveImagesToNonMdpiFolders(subdir)
+ package_command += ['-S', subdir]
+
+ if 'Debug' in options.configuration_name:
+ package_command += ['--debug-mode']
+
+ build_utils.CheckOutput(
+ package_command, print_stdout=False, print_stderr=False)
if __name__ == '__main__':
diff --git a/build/android/gyp/process_resources.py b/build/android/gyp/process_resources.py
index 132cdf6..ec19f59 100755
--- a/build/android/gyp/process_resources.py
+++ b/build/android/gyp/process_resources.py
@@ -13,8 +13,7 @@ This will crunch images and generate v14 compatible resources
import optparse
import os
import re
-import shlex
-import shutil
+import zipfile
import generate_v14_compatible_resources
@@ -27,25 +26,27 @@ def ParseArgs():
An options object as from optparse.OptionsParser.parse_args()
"""
parser = optparse.OptionParser()
+
parser.add_option('--android-sdk', help='path to the Android SDK folder')
parser.add_option('--android-sdk-tools',
help='path to the Android SDK build tools folder')
- parser.add_option('--R-dir', help='directory to hold generated R.java')
- parser.add_option('--dependencies-res-dirs',
- help='directories containing resources to be packaged')
- parser.add_option('--resource-dir',
- help='directory containing this target\'s resources.')
- 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')
+
parser.add_option('--android-manifest', help='AndroidManifest.xml path')
+ parser.add_option('--custom-package', help='Java package for R.java')
+
+ parser.add_option('--resource-dirs',
+ help='Directories containing resources of this target.')
+ parser.add_option('--dependencies-res-zips',
+ help='Resources from dependents.')
+
+ parser.add_option('--R-dir', help='directory to hold generated R.java')
+ parser.add_option('--resource-zip-out',
+ help='Path for output zipped resources.')
+
parser.add_option('--proguard-file',
help='Path to proguard.txt generated file')
- 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',
@@ -74,11 +75,10 @@ def ParseArgs():
'android_sdk',
'android_sdk_tools',
'android_manifest',
- 'dependencies_res_dirs',
- 'resource_dir',
- 'crunch_output_dir',
+ 'dependencies_res_zips',
+ 'resource_dirs',
+ 'resource_zip_out',
'R_dir',
- 'res_v14_compatibility_dir',
)
build_utils.CheckOptions(options, parser, required=required_options)
@@ -110,30 +110,7 @@ def CreateExtraRJavaFiles(
-def MoveImagesToNonMdpiFolders(res_root):
- """Move images from drawable-*-mdpi-* folders to drawable-* folders.
- Why? http://crbug.com/289843
- """
- for src_dir_name in os.listdir(res_root):
- src_components = src_dir_name.split('-')
- if src_components[0] != 'drawable' or 'mdpi' not in src_components:
- continue
- src_dir = os.path.join(res_root, src_dir_name)
- if not os.path.isdir(src_dir):
- continue
- dst_components = [c for c in src_components if c != 'mdpi']
- assert dst_components != src_components
- dst_dir_name = '-'.join(dst_components)
- dst_dir = os.path.join(res_root, dst_dir_name)
- build_utils.MakeDirectory(dst_dir)
- for src_file_name in os.listdir(src_dir):
- if not src_file_name.endswith('.png'):
- continue
- src_file = os.path.join(src_dir, src_file_name)
- dst_file = os.path.join(dst_dir, src_file_name)
- assert not os.path.lexists(dst_file)
- shutil.move(src_file, dst_file)
def DidCrunchFail(returncode, stderr):
@@ -160,57 +137,95 @@ 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
- # generated by merging the resources from all libraries and the main apk
- # project.
- package_command = [aapt,
- 'package',
- '-m',
- '-M', options.android_manifest,
- '--auto-add-overlay',
- '-I', android_jar,
- '--output-text-symbols', options.R_dir,
- '-J', options.R_dir]
- all_res_dirs = ([options.resource_dir]
- + shlex.split(options.dependencies_res_dirs))
- for res_dir in all_res_dirs:
- package_command += ['-S', res_dir]
- if options.non_constant_id:
- package_command.append('--non-constant-id')
- if options.custom_package:
- package_command += ['--custom-package', options.custom_package]
- if options.proguard_file:
- package_command += ['-G', options.proguard_file]
-
- build_utils.CheckOutput(package_command)
-
- if options.extra_res_packages:
- CreateExtraRJavaFiles(
- options.R_dir,
- build_utils.ParseGypList(options.extra_res_packages),
- build_utils.ParseGypList(options.extra_r_text_files))
-
- # Crunch image resources. This shrinks png files and is necessary for 9-patch
- # images to display correctly.
- build_utils.DeleteDirectory(options.crunch_output_dir)
- build_utils.MakeDirectory(options.crunch_output_dir)
- aapt_cmd = [aapt,
- 'crunch',
- '-S', options.resource_dir,
- '-C', options.crunch_output_dir]
- build_utils.CheckOutput(aapt_cmd, fail_func=DidCrunchFail)
-
- MoveImagesToNonMdpiFolders(options.crunch_output_dir)
-
- if options.stamp:
- build_utils.Touch(options.stamp)
+ with build_utils.TempDir() as temp_dir:
+ deps_dir = os.path.join(temp_dir, 'deps')
+ build_utils.MakeDirectory(deps_dir)
+ v14_dir = os.path.join(temp_dir, 'v14')
+ build_utils.MakeDirectory(v14_dir)
+
+ input_resource_dirs = build_utils.ParseGypList(options.resource_dirs)
+
+ for resource_dir in input_resource_dirs:
+ generate_v14_compatible_resources.GenerateV14Resources(
+ resource_dir,
+ v14_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
+ # generated by merging the resources from all libraries and the main apk
+ # project.
+ package_command = [aapt,
+ 'package',
+ '-m',
+ '-M', options.android_manifest,
+ '--auto-add-overlay',
+ '-I', android_jar,
+ '--output-text-symbols', options.R_dir,
+ '-J', options.R_dir]
+
+ for d in input_resource_dirs:
+ package_command += ['-S', d]
+
+ dep_zips = build_utils.ParseGypList(options.dependencies_res_zips)
+ for z in dep_zips:
+ subdir = os.path.join(deps_dir, os.path.basename(z))
+ if os.path.exists(subdir):
+ raise Exception('Resource zip name conflict: ' + os.path.basename(z))
+ build_utils.ExtractAll(z, path=subdir)
+ package_command += ['-S', subdir]
+
+ if options.non_constant_id:
+ package_command.append('--non-constant-id')
+ if options.custom_package:
+ package_command += ['--custom-package', options.custom_package]
+ if options.proguard_file:
+ package_command += ['-G', options.proguard_file]
+ build_utils.CheckOutput(package_command, print_stderr=False)
+
+ if options.extra_res_packages:
+ CreateExtraRJavaFiles(
+ options.R_dir,
+ build_utils.ParseGypList(options.extra_res_packages),
+ build_utils.ParseGypList(options.extra_r_text_files))
+
+ # This is the list of directories with resources to put in the final .zip
+ # file. The order of these is important so that crunched/v14 resources
+ # override the normal ones.
+ zip_resource_dirs = input_resource_dirs + [v14_dir]
+
+ base_crunch_dir = os.path.join(temp_dir, 'crunch')
+
+ # Crunch image resources. This shrinks png files and is necessary for
+ # 9-patch images to display correctly. 'aapt crunch' accepts only a single
+ # directory at a time and deletes everything in the output directory.
+ for idx, d in enumerate(input_resource_dirs):
+ crunch_dir = os.path.join(base_crunch_dir, str(idx))
+ build_utils.MakeDirectory(crunch_dir)
+ zip_resource_dirs.append(crunch_dir)
+ aapt_cmd = [aapt,
+ 'crunch',
+ '-C', crunch_dir,
+ '-S', d]
+ build_utils.CheckOutput(aapt_cmd, fail_func=DidCrunchFail)
+
+ # Python zipfile does not provide a way to replace a file (it just writes
+ # another file with the same name). So, first collect all the files to put
+ # in the zip (with proper overriding), and then zip them.
+ files_to_zip = dict()
+ for d in zip_resource_dirs:
+ for root, _, files in os.walk(d):
+ for f in files:
+ archive_path = os.path.join(os.path.relpath(root, d), f)
+ path = os.path.join(root, f)
+ files_to_zip[archive_path] = path
+ with zipfile.ZipFile(options.resource_zip_out, 'w') as outzip:
+ for archive_path, path in files_to_zip.iteritems():
+ outzip.write(path, archive_path)
+
+ if options.stamp:
+ build_utils.Touch(options.stamp)
if __name__ == '__main__':
diff --git a/build/android/gyp/util/build_utils.py b/build/android/gyp/util/build_utils.py
index 36c8319..2a53312 100644
--- a/build/android/gyp/util/build_utils.py
+++ b/build/android/gyp/util/build_utils.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import contextlib
import fnmatch
import json
import os
@@ -10,6 +11,17 @@ import shlex
import shutil
import subprocess
import sys
+import tempfile
+import zipfile
+
+
+@contextlib.contextmanager
+def TempDir():
+ dirname = tempfile.mkdtemp()
+ try:
+ yield dirname
+ finally:
+ shutil.rmtree(dirname)
def MakeDirectory(dir_path):
@@ -142,6 +154,39 @@ def IsDeviceReady():
return device_state.strip() == 'device'
+def CheckZipPath(name):
+ if os.path.normpath(name) != name:
+ raise Exception('Non-canonical zip path: %s, %s' % name)
+ if os.path.isabs(name):
+ raise Exception('Absolute zip path: %s, %s' % name)
+
+
+def ExtractAll(zip_path, path=None, no_clobber=True):
+ if path is None:
+ path = os.getcwd()
+ elif not os.path.exists(path):
+ MakeDirectory(path)
+
+ with zipfile.ZipFile(zip_path) as z:
+ for name in z.namelist():
+ CheckZipPath(name)
+ if no_clobber:
+ output_path = os.path.join(path, name)
+ if os.path.exists(output_path):
+ raise Exception(
+ 'Path already exists from zip: %s %s %s'
+ % (zip_path, name, output_path))
+
+ z.extractall(path=path)
+
+
+def DoZip(inputs, output, base_dir):
+ with zipfile.ZipFile(output, 'w') as outfile:
+ for f in inputs:
+ CheckZipPath(f)
+ outfile.write(f, os.path.relpath(f, base_dir))
+
+
def PrintWarning(message):
print 'WARNING: ' + message
diff --git a/build/android/gyp/zip.py b/build/android/gyp/zip.py
new file mode 100755
index 0000000..51322df
--- /dev/null
+++ b/build/android/gyp/zip.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+#
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Archives a set of files.
+"""
+
+import optparse
+import sys
+
+from util import build_utils
+
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('--input-dir', help='Directory of files to archive.')
+ parser.add_option('--output', help='Path to output archive.')
+ options, _ = parser.parse_args()
+
+ inputs = build_utils.FindInDirectory(options.input_dir, '*')
+ build_utils.DoZip(inputs, options.output, options.input_dir)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/build/java.gypi b/build/java.gypi
index a67c836..641dc77 100644
--- a/build/java.gypi
+++ b/build/java.gypi
@@ -110,41 +110,31 @@
['has_java_resources == 1', {
'variables': {
'res_dir': '<(java_in_dir)/res',
- 'res_crunched_dir': '<(intermediate_dir)/res_crunched',
- '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)'],
+
'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)', ],
- 'additional_res_dirs': [],
- 'dependencies_res_input_dirs': [],
- 'dependencies_res_files': [],
+ 'additional_input_paths': ['<(resource_zip_path)', ],
+
+ 'dependencies_res_zip_paths': [],
+ 'resource_zip_path': '<(PRODUCT_DIR)/res.java/<(_target_name).zip',
},
'all_dependent_settings': {
'variables': {
- # Dependent jars include this target's R.java file via
- # generated_R_dirs and include its resources via
- # dependencies_res_files.
+ # Dependent libraries include this target's R.java file via
+ # generated_R_dirs.
'generated_R_dirs': ['<(R_dir)'],
- 'additional_input_paths': ['<(R_stamp)', ],
- 'dependencies_res_files': ['<@(resource_input_paths)'],
- 'dependencies_res_input_dirs': ['<@(res_input_dirs)'],
+ # Dependent libraries and apks include this target's resources via
+ # dependencies_res_zip_paths.
+ 'additional_input_paths': ['<(resource_zip_path)'],
+ 'dependencies_res_zip_paths': ['<(resource_zip_path)'],
- # Dependent APKs include this target's resources via
- # additional_res_dirs, additional_res_packages, and
- # additional_R_text_files.
- 'additional_res_dirs': [
- # The order of these is important to ensure that the proper
- # version (i.e. the crunched version) of resources takes
- # precedence.
- '<(res_crunched_dir)',
- '<(res_v14_compatibility_dir)',
- '<@(res_input_dirs)'
- ],
+ # additional_res_packages and additional_R_text_files are used to
+ # create this packages R.java files when building the APK.
'additional_res_packages': ['<(R_package)'],
'additional_R_text_files': ['<(R_text_file)'],
},
@@ -156,13 +146,9 @@
'message': 'processing resources for <(_target_name)',
'variables': {
'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml',
- # Include the dependencies' res dirs so that references to
- # resources in dependencies can be resolved.
- 'dependencies_res_dirs': ['<@(res_extra_dirs)',
- '>@(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))',
'process_resources_options': [],
'conditions': [
['res_v14_verify_only == 1', {
@@ -175,25 +161,27 @@
'<(DEPTH)/build/android/gyp/process_resources.py',
'<(DEPTH)/build/android/gyp/generate_v14_compatible_resources.py',
'>@(resource_input_paths)',
- '>@(dependencies_res_files)',
+ '>@(dependencies_res_zip_paths)',
'>(inputs_list_file)',
],
'outputs': [
- '<(R_stamp)',
+ '<(resource_zip_path)',
],
'action': [
'python', '<(DEPTH)/build/android/gyp/process_resources.py',
'--android-sdk', '<(android_sdk)',
'--android-sdk-tools', '<(android_sdk_tools)',
- '--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',
+
+ '--android-manifest', '<(android_manifest)',
'--custom-package', '<(R_package)',
- '--stamp', '<(R_stamp)',
+
+ '--dependencies-res-zips', '>(dependencies_res_zip_paths)',
+ '--resource-dirs', '<(res_input_dirs)',
+
+ '--R-dir', '<(R_dir)',
+ '--resource-zip-out', '<(resource_zip_path)',
+
'<@(process_resources_options)',
],
},
diff --git a/build/java_apk.gypi b/build/java_apk.gypi
index 1d8fa8e..b654ad8 100644
--- a/build/java_apk.gypi
+++ b/build/java_apk.gypi
@@ -65,10 +65,9 @@
'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': [],
+ 'dependencies_res_zip_paths': [],
'additional_res_packages': [],
'is_test_apk%': 0,
'resource_input_paths': [],
@@ -105,7 +104,7 @@
'push_stamp': '<(intermediate_dir)/push.stamp',
'link_stamp': '<(intermediate_dir)/link.stamp',
'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp',
- 'crunch_output_dir': '<(intermediate_dir)/res',
+ 'resource_zip_path': '<(intermediate_dir)/<(_target_name).resources.zip',
'resource_packaged_apk_name': '<(apk_name)-resources.ap_',
'resource_packaged_apk_path': '<(intermediate_dir)/<(resource_packaged_apk_name)',
'unsigned_apk_path': '<(intermediate_dir)/<(apk_name)-unsigned.apk',
@@ -170,7 +169,6 @@
'variables': {
# We generate R.java in package R_package (in addition to the package
# listed in the AndroidManifest.xml, which is unavoidable).
- 'additional_res_dirs': ['<(DEPTH)/build/android/ant/empty/res'],
'additional_res_packages': ['<(R_package)'],
'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'],
},
@@ -449,7 +447,7 @@
'process_resources_options': [],
'conditions': [
['is_test_apk == 1', {
- 'additional_res_dirs=': [],
+ 'dependencies_res_zip_paths=': [],
'additional_res_packages=': [],
}],
['res_v14_verify_only == 1', {
@@ -463,9 +461,11 @@
'<(android_manifest_path)',
'>@(additional_input_paths)',
'>@(resource_input_paths)',
+ '>@(dependencies_res_zip_paths)',
'>(inputs_list_file)',
],
'outputs': [
+ '<(resource_zip_path)',
'<(generated_proguard_file)',
'<(codegen_stamp)',
],
@@ -475,7 +475,7 @@
'--android-sdk-tools', '<(android_sdk_tools)',
'--android-manifest', '<(android_manifest_path)',
- '--dependencies-res-dirs', '>(additional_res_dirs)',
+ '--dependencies-res-zips', '>(dependencies_res_zip_paths)',
'--extra-res-packages', '>(additional_res_packages)',
'--extra-r-text-files', '>(additional_R_text_files)',
@@ -483,8 +483,7 @@
'--proguard-file', '<(generated_proguard_file)',
'--resource-dir', '<(resource_dir)',
- '--res-v14-compatibility-dir', '<(res_v14_compatibility_dir)',
- '--crunch-output-dir', '<(crunch_output_dir)',
+ '--resource-zip-out', '<(resource_zip_path)',
'--R-dir', '<(intermediate_dir)/gen',
@@ -659,26 +658,15 @@
'action_name': 'package_resources',
'message': 'packaging resources for <(_target_name)',
'variables': {
- 'extra_package_input_paths': [
- '>@(package_input_paths)',
- '>@(additional_input_paths)',
- '>@(resource_input_paths)'
+ 'package_resource_zip_input_paths': [
+ '<(resource_zip_path)',
+ '>@(dependencies_res_zip_paths)',
],
- 'package_resource_dirs': [
- # <(crunch_output_dir) must come before <(resource_dir) so that
- # the crunched files take precedence.
- '<(crunch_output_dir)',
- '<(resource_dir)',
- '>@(additional_res_dirs)',
- ],
- # Write the inputs list to a file, so that its mtime is updated when
- # the list of inputs changes.
- 'inputs_list_file': '>|(apk_package.<(_target_name).gypcmd >@(extra_package_input_paths))',
},
'conditions': [
['is_test_apk == 1', {
'variables': {
- 'additional_res_dirs=': [],
+ 'dependencies_res_zip_paths=': [],
'additional_res_packages=': [],
}
}],
@@ -689,10 +677,9 @@
'<(DEPTH)/build/android/gyp/package_resources.py',
'<(android_manifest_path)',
- '<(codegen_stamp)',
+ '>@(package_resource_zip_input_paths)',
- '>@(extra_package_input_paths)',
- '>(inputs_list_file)',
+ '<(codegen_stamp)',
],
'outputs': [
'<(resource_packaged_apk_path)',
@@ -709,7 +696,7 @@
'--version-name', '<(app_manifest_version_name)',
'--asset-dir', '<(asset_location)',
- '--resource-dirs', '>(package_resource_dirs)',
+ '--resource-zips', '>(package_resource_zip_input_paths)',
'--apk-path', '<(resource_packaged_apk_path)',
],
diff --git a/build/java_strings_grd.gypi b/build/java_strings_grd.gypi
index ff374e3..7534be5 100644
--- a/build/java_strings_grd.gypi
+++ b/build/java_strings_grd.gypi
@@ -19,30 +19,44 @@
# grd_file - The path to the grd file to use.
{
'variables': {
- 'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)',
- 'res_grit_dir': '<(intermediate_dir)/res_grit',
+ 'res_grit_dir': '<(INTERMEDIATE_DIR)/<(_target_name)/res_grit',
'grit_grd_file': '<(grd_file)',
- 'resource_input_paths': [
- '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(res_grit_dir)" <(grd_file))'
- ],
+ 'resource_zip_path': '<(PRODUCT_DIR)/res.java/<(_target_name).zip',
+ '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': '',
+ 'grit_outputs': [
+ '<!@pymod_do_main(grit_info <@(grit_defines) <@(grit_additional_defines) '
+ '--outputs \'<(grit_out_dir)\' '
+ '<(grit_grd_file) -f "<(grit_resource_ids)")',
+ ]
},
'all_dependent_settings': {
'variables': {
- 'additional_res_dirs': ['<@(res_grit_dir)'],
- 'dependencies_res_files': ['<@(resource_input_paths)'],
- 'dependencies_res_input_dirs': ['<@(res_grit_dir)'],
+ 'additional_input_paths': ['<(resource_zip_path)'],
+ 'dependencies_res_zip_paths': ['<(resource_zip_path)'],
},
},
'actions': [
{
'action_name': 'generate_localized_strings_xml',
- 'variables': {
- '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': '',
- },
'includes': ['../build/grit_action.gypi'],
},
+ {
+ 'action_name': 'create_resources_zip',
+ 'inputs': [
+ '<(DEPTH)/build/android/gyp/zip.py',
+ '<@(grit_outputs)',
+ ],
+ 'outputs': [
+ '<(resource_zip_path)',
+ ],
+ 'action': [
+ 'python', '<(DEPTH)/build/android/gyp/zip.py',
+ '--input-dir', '<(res_grit_dir)',
+ '--output', '<(resource_zip_path)',
+ ],
+ }
],
}