Commit 8dabdfa9 authored by agrieve's avatar agrieve Committed by Commit bot

Extract apkbuilder build action into a .gypi

- This is in preparation for split apks, where we'll need to call
apkbuilder multiple times.
- This also makes including a classes.dex file optional

BUG=484797

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

Cr-Commit-Position: refs/heads/master@{#330159}
parent 103db443
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
debugpackaging="${build.is.packaging.debug}" debugpackaging="${build.is.packaging.debug}"
debugsigning="${build.is.signing.debug}" debugsigning="${build.is.signing.debug}"
verbose="${verbose}" verbose="${verbose}"
hascode="true" hascode="${HAS_CODE}"
previousBuildType="/" previousBuildType="/"
buildType="${build.is.packaging.debug}/${build.is.signing.debug}"> buildType="${build.is.packaging.debug}/${build.is.signing.debug}">
<dex path="${intermediate.dex.file}"/> <dex path="${intermediate.dex.file}"/>
......
# 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.
# apk_path - Path to output apk.
# package_input_paths - Late-evaluated list of resource zips.
# native_libs_dir - Path to lib/ directory to use. Set to an empty directory
# if no native libs are needed.
# Optional variables:
# has_code - Whether to include classes.dex in the apk.
# dex_path - Path to classes.dex. Used only when has_code=1.
# extra_inputs - List of extra action inputs.
{
'variables': {
'variables': {
'has_code%': 1,
},
'conditions': [
['has_code == 0', {
'has_code_str': 'false',
}, {
'has_code_str': 'true',
}],
],
'has_code%': '<(has_code)',
'extra_inputs%': [],
# 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).<(apk_name).gypcmd >@(package_input_paths))',
'resource_packaged_apk_name': '<(apk_name)-resources.ap_',
'resource_packaged_apk_path': '<(intermediate_dir)/<(resource_packaged_apk_name)',
},
'action_name': 'apkbuilder_<(apk_name)',
'message': 'Packaging <(apk_name)',
'inputs': [
'<(DEPTH)/build/android/ant/apk-package.xml',
'<(DEPTH)/build/android/gyp/util/build_utils.py',
'<(DEPTH)/build/android/gyp/ant.py',
'<(resource_packaged_apk_path)',
'<@(extra_inputs)',
'>@(package_input_paths)',
'>(inputs_list_file)',
],
'outputs': [
'<(apk_path)',
],
'conditions': [
['has_code == 1', {
'inputs': ['<(dex_path)'],
'action': [
'-DDEX_FILE_PATH=<(dex_path)',
]
}],
],
'action': [
'python', '<(DEPTH)/build/android/gyp/ant.py',
'--',
'-quiet',
'-DHAS_CODE=<(has_code_str)',
'-DANDROID_SDK_ROOT=<(android_sdk_root)',
'-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
'-DRESOURCE_PACKAGED_APK_NAME=<(resource_packaged_apk_name)',
'-DNATIVE_LIBS_DIR=<(native_libs_dir)',
'-DAPK_NAME=<(apk_name)',
'-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
'-DOUT_DIR=<(intermediate_dir)',
'-DUNSIGNED_APK_PATH=<(apk_path)',
'-DEMMA_INSTRUMENT=<(emma_instrument)',
'-DEMMA_DEVICE_JAR=<(emma_device_jar)',
'-Dbasedir=.',
'-buildfile',
'<(DEPTH)/build/android/ant/apk-package.xml',
]
}
...@@ -534,10 +534,12 @@ template("create_apk") { ...@@ -534,10 +534,12 @@ template("create_apk") {
depfile = "$target_gen_dir/$target_name.d" depfile = "$target_gen_dir/$target_name.d"
inputs = [ inputs = [
_dex_path,
_resource_packaged_apk_path, _resource_packaged_apk_path,
_ant_script, _ant_script,
] ]
if (defined(_dex_path)) {
inputs += [ _dex_path ]
}
outputs = [ outputs = [
depfile, depfile,
...@@ -549,7 +551,6 @@ template("create_apk") { ...@@ -549,7 +551,6 @@ template("create_apk") {
rebase_path(_resource_packaged_apk_path, root_build_dir) rebase_path(_resource_packaged_apk_path, root_build_dir)
_rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir) _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir)
_rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir) _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir)
_rebased_dex_path = rebase_path(_dex_path, root_build_dir)
args = [ args = [
"--depfile", "--depfile",
rebase_path(depfile, root_build_dir), rebase_path(depfile, root_build_dir),
...@@ -564,11 +565,19 @@ template("create_apk") { ...@@ -564,11 +565,19 @@ template("create_apk") {
"-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path", "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path",
"-DEMMA_INSTRUMENT=0", "-DEMMA_INSTRUMENT=0",
"-DEMMA_DEVICE_JAR=$_rebased_emma_jar", "-DEMMA_DEVICE_JAR=$_rebased_emma_jar",
"-DDEX_FILE_PATH=$_rebased_dex_path",
"-Dbasedir=.", "-Dbasedir=.",
"-buildfile", "-buildfile",
rebase_path(_ant_script, root_build_dir), rebase_path(_ant_script, root_build_dir),
] ]
if (defined(_dex_path)) {
_rebased_dex_path = rebase_path(_dex_path, root_build_dir)
args += [
"-DDEX_FILE_PATH=$_rebased_dex_path",
"-DHAS_CODE=true",
]
} else {
args += [ "-DHAS_CODE=false" ]
}
} }
action("${target_name}__finalize") { action("${target_name}__finalize") {
......
...@@ -924,52 +924,16 @@ ...@@ -924,52 +924,16 @@
], ],
}, },
{ {
'action_name': 'ant_package_<(_target_name)',
'message': 'Packaging <(_target_name)',
'variables': { 'variables': {
# Write the inputs list to a file, so that its mtime is updated when 'apk_path': '<(unsigned_apk_path)',
# the list of inputs changes. 'native_libs_dir': '<(apk_package_native_libs_dir)',
'inputs_list_file': '>|(apk_package.<(_target_name).gypcmd >@(package_input_paths))' 'conditions': [
['native_lib_target != ""', {
'extra_inputs': ['<(native_lib_placeholder_stamp)'],
}],
],
}, },
'inputs': [ 'includes': ['android/apkbuilder_action.gypi'],
'<(DEPTH)/build/android/ant/apk-package.xml',
'<(DEPTH)/build/android/gyp/util/build_utils.py',
'<(DEPTH)/build/android/gyp/ant.py',
'<(dex_path)',
'<(codegen_stamp)',
'<(obfuscate_stamp)',
'<(resource_packaged_apk_path)',
'>@(package_input_paths)',
'>(inputs_list_file)',
],
'outputs': [
'<(unsigned_apk_path)',
],
'conditions': [
['native_lib_target != ""', {
'inputs': ['<(native_lib_placeholder_stamp)'],
}],
],
'action': [
'python', '<(DEPTH)/build/android/gyp/ant.py',
'--',
'-quiet',
'-DDEX_FILE_PATH=<(intermediate_dir)/classes.dex',
'-DANDROID_SDK_ROOT=<(android_sdk_root)',
'-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
'-DRESOURCE_PACKAGED_APK_NAME=<(resource_packaged_apk_name)',
'-DAPK_NAME=<(apk_name)',
'-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
'-DNATIVE_LIBS_DIR=<(apk_package_native_libs_dir)',
'-DOUT_DIR=<(intermediate_dir)',
'-DUNSIGNED_APK_PATH=<(unsigned_apk_path)',
'-DEMMA_INSTRUMENT=<(emma_instrument)',
'-DEMMA_DEVICE_JAR=<(emma_device_jar)',
'-Dbasedir=.',
'-buildfile',
'<(DEPTH)/build/android/ant/apk-package.xml',
]
}, },
], ],
} }
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
"build/android/android_no_jni_exports.lst", "build/android/android_no_jni_exports.lst",
"build/android/ant/apk-package.xml", "build/android/ant/apk-package.xml",
"build/android/ant/chromium-debug.keystore", "build/android/ant/chromium-debug.keystore",
"build/android/apkbuilder_action.gypi",
"build/android/asan_symbolize.py", "build/android/asan_symbolize.py",
"build/android/avd.py", "build/android/avd.py",
"build/android/bb_run_sharded_steps.py", "build/android/bb_run_sharded_steps.py",
......
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