Commit a657e537 authored by agrieve's avatar agrieve Committed by Commit bot

Extract package_resources step into a .gypi & make assets & resource zips optional

This is in preparation for for creating abi splits

BUG=484797

Review URL: https://codereview.chromium.org/1140763002

Cr-Commit-Position: refs/heads/master@{#330188}
parent 9de69c4c
......@@ -60,7 +60,7 @@ def ParseArgs():
# Check that required options have been provided.
required_options = ('android_sdk', 'android_sdk_tools', 'configuration_name',
'android_manifest', 'version_code', 'version_name',
'resource_zips', 'asset_dir', 'apk_path')
'apk_path')
build_utils.CheckOptions(options, parser, required=required_options)
......@@ -140,16 +140,17 @@ def main():
if options.shared_resources:
package_command.append('--shared-lib')
if os.path.exists(options.asset_dir):
if options.asset_dir and 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)
package_command += PackageArgsForExtractedZip(subdir)
if options.resource_zips:
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)
package_command += PackageArgsForExtractedZip(subdir)
if 'Debug' in options.configuration_name:
package_command += ['--debug-mode']
......
# Copyright 2015 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.
# This file is a helper to java_apk.gypi. It should be used to create an
# action that runs ApkBuilder via ANT.
#
# Required variables:
# apk_name - File name (minus path & extension) of the output apk.
# android_manifest_path - Path to AndroidManifest.xml.
# app_manifest_version_name - set the apps 'human readable' version number.
# app_manifest_version_code - set the apps version number.
# Optional variables:
# asset_location - The directory where assets are located (if any).
# resource_zips - List of paths to resource zip files.
# shared_resources - Make a resource package that can be loaded by a different
# application at runtime to access the package's resources.
# extensions_to_not_compress - E.g.: 'pak,dat,bin'
# extra_inputs - List of extra action inputs.
{
'variables': {
'asset_location%': '',
'resource_zips%': [],
'shared_resources%': 0,
'extensions_to_not_compress%': '',
'extra_inputs%': [],
'resource_packaged_apk_name': '<(apk_name)-resources.ap_',
'resource_packaged_apk_path': '<(intermediate_dir)/<(resource_packaged_apk_name)',
},
'action_name': 'package_resources_<(apk_name)',
'message': 'packaging resources for <(apk_name)',
'inputs': [
# TODO: This isn't always rerun correctly, http://crbug.com/351928
'<(DEPTH)/build/android/gyp/util/build_utils.py',
'<(DEPTH)/build/android/gyp/package_resources.py',
'<(android_manifest_path)',
'<@(extra_inputs)',
],
'outputs': [
'<(resource_packaged_apk_path)',
],
'action': [
'python', '<(DEPTH)/build/android/gyp/package_resources.py',
'--android-sdk', '<(android_sdk)',
'--android-sdk-tools', '<(android_sdk_tools)',
'--configuration-name', '<(CONFIGURATION_NAME)',
'--android-manifest', '<(android_manifest_path)',
'--version-code', '<(app_manifest_version_code)',
'--version-name', '<(app_manifest_version_name)',
'--no-compress', '<(extensions_to_not_compress)',
'--apk-path', '<(resource_packaged_apk_path)',
],
'conditions': [
['shared_resources == 1', {
'action': [
'--shared-resources',
],
}],
['asset_location != ""', {
'action': [
'--asset-dir', '<(asset_location)',
],
}],
['resource_zips != []', {
'action': [
'--resource-zips', '>(resource_zips)',
],
'inputs': [
'>@(resource_zips)',
],
}],
],
}
......@@ -449,8 +449,13 @@ template("create_apk") {
_android_manifest = invoker.android_manifest
_base_path = invoker.base_path
_final_apk_path = invoker.apk_path
_resources_zip = invoker.resources_zip
_dex_path = invoker.dex_path
if (defined(invoker.resources_zip)) {
_resources_zip = invoker.resources_zip
}
if (defined(invoker.dex_path)) {
_dex_path = invoker.dex_path
}
_keystore_path = invoker.keystore_path
_keystore_name = invoker.keystore_name
_keystore_password = invoker.keystore_password
......@@ -466,7 +471,6 @@ template("create_apk") {
_native_libs_dir = invoker.native_libs_dir
}
_asset_location = "//build/android/empty/res"
if (defined(invoker.asset_location)) {
_asset_location = invoker.asset_location
}
......@@ -493,14 +497,15 @@ template("create_apk") {
depfile = "${target_gen_dir}/${target_name}.d"
inputs = [
_android_manifest,
_resources_zip,
]
if (defined(_resources_zip)) {
inputs += [ _resources_zip ]
}
outputs = [
depfile,
_resource_packaged_apk_path,
]
_rebased_resources_zips = [ rebase_path(_resources_zip, root_build_dir) ]
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
......@@ -515,13 +520,22 @@ template("create_apk") {
_version_code,
"--version-name",
_version_name,
"--asset-dir",
rebase_path(_asset_location, root_build_dir),
"--resource-zips=$_rebased_resources_zips",
"--apk-path",
rebase_path(_resource_packaged_apk_path, root_build_dir),
]
if (defined(_asset_location)) {
args += [
"--asset-dir",
rebase_path(_asset_location, root_build_dir),
]
}
if (defined(_resources_zip)) {
args += [
"--resource-zips",
rebase_path(_resources_zip, root_build_dir),
]
}
if (_shared_resources) {
args += [ "--shared-resources" ]
}
......
......@@ -128,10 +128,7 @@
'android_manifest_path%': '<(java_in_dir)/AndroidManifest.xml',
'push_stamp': '<(intermediate_dir)/push.stamp',
'link_stamp': '<(intermediate_dir)/link.stamp',
'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp',
'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)',
'shared_resources%': 0,
'unsigned_apk_path': '<(intermediate_dir)/<(apk_name)-unsigned.apk',
'final_apk_path%': '<(PRODUCT_DIR)/apks/<(apk_name).apk',
......@@ -867,61 +864,20 @@
'includes': [ 'android/dex_action.gypi' ],
},
{
'action_name': 'package_resources',
'message': 'packaging resources for <(_target_name)',
'variables': {
'package_resources_options': [],
'package_resource_zip_input_paths': [
'extra_inputs': ['<(codegen_stamp)'],
'resource_zips': [
'<(resource_zip_path)',
'>@(dependencies_res_zip_paths)',
],
'conditions': [
['shared_resources == 1', {
'package_resources_options+': ['--shared-resources']
['is_test_apk == 0', {
'resource_zips': [
'>@(dependencies_res_zip_paths)',
],
}],
],
},
'conditions': [
['is_test_apk == 1', {
'variables': {
'dependencies_res_zip_paths=': [],
'additional_res_packages=': [],
}
}],
],
'inputs': [
# TODO: This isn't always rerun correctly, http://crbug.com/351928
'<(DEPTH)/build/android/gyp/util/build_utils.py',
'<(DEPTH)/build/android/gyp/package_resources.py',
'<(android_manifest_path)',
'>@(package_resource_zip_input_paths)',
'<(codegen_stamp)',
],
'outputs': [
'<(resource_packaged_apk_path)',
],
'action': [
'python', '<(DEPTH)/build/android/gyp/package_resources.py',
'--android-sdk', '<(android_sdk)',
'--android-sdk-tools', '<(android_sdk_tools)',
'--configuration-name', '<(CONFIGURATION_NAME)',
'--android-manifest', '<(android_manifest_path)',
'--version-code', '<(app_manifest_version_code)',
'--version-name', '<(app_manifest_version_name)',
'--asset-dir', '<(asset_location)',
'--resource-zips', '>(package_resource_zip_input_paths)',
'--no-compress', '<(extensions_to_not_compress)',
'--apk-path', '<(resource_packaged_apk_path)',
'<@(package_resources_options)',
],
'includes': [ 'android/package_resources_action.gypi' ],
},
{
'variables': {
......
......@@ -135,6 +135,7 @@
"build/android/native_app_dependencies.gypi",
"build/android/ndk.gyp",
"build/android/pack_arm_relocations.gypi",
"build/android/package_resources_action.gypi",
"build/android/provision_devices.py",
"build/android/push_libraries.gypi",
"build/android/rezip.gyp",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment