Reland #2 of Make secondary abi work for component build

Previously reverted in:
https://codereview.chromium.org/2333593002/

Reason for reland:
Removed offending import for real this time.

BUG=622855

Review-Url: https://codereview.chromium.org/2335663002
Cr-Original-Commit-Position: refs/heads/master@{#417942}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 06d80348f0e49fe7558ee8b3adad6f56078b5842
This commit is contained in:
agrieve 2016-09-12 08:26:15 -07:00 коммит произвёл Commit bot
Родитель 9d601d07a9
Коммит 7aec10bd59
4 изменённых файлов: 171 добавлений и 42 удалений

Просмотреть файл

@ -70,7 +70,7 @@ copy("cpplib_unstripped") {
action("cpplib_stripped") {
_strip_bin = "${android_tool_prefix}strip"
_soname = "libc++_shared.so"
_input_so = "${root_out_dir}/lib.unstripped/${_soname}"
_input_so = "${root_shlib_dir}/lib.unstripped/${_soname}"
_output_so = "${root_shlib_dir}/${_soname}"
deps = [
@ -91,9 +91,9 @@ action("cpplib_stripped") {
_output_so,
]
_rebased_strip_bin = rebase_path(_strip_bin, root_out_dir)
_rebased_input_so = rebase_path(_input_so, root_out_dir)
_rebased_output_so = rebase_path(_output_so, root_out_dir)
_rebased_strip_bin = rebase_path(_strip_bin, root_build_dir)
_rebased_input_so = rebase_path(_input_so, root_build_dir)
_rebased_output_so = rebase_path(_output_so, root_build_dir)
args = [
_rebased_strip_bin,
"--strip-unneeded",

Просмотреть файл

@ -209,6 +209,11 @@ def _ExtractSharedLibsFromRuntimeDeps(runtime_deps_files):
ret.reverse()
return ret
def _CreateJavaLibrariesList(library_paths):
""" Create a java literal array with the "base" library names:
e.g. libfoo.so -> foo
"""
return ('{%s}' % ','.join(['"%s"' % s[3:-3] for s in library_paths]))
def main(argv):
parser = optparse.OptionParser()
@ -264,6 +269,9 @@ def main(argv):
parser.add_option('--shared-libraries-runtime-deps',
help='Path to file containing runtime deps for shared '
'libraries.')
parser.add_option('--secondary-abi-shared-libraries-runtime-deps',
help='Path to file containing runtime deps for secondary '
'abi shared libraries.')
# apk options
parser.add_option('--apk-path', help='Path to the target\'s apk output.')
@ -629,15 +637,24 @@ def main(argv):
options.shared_libraries_runtime_deps or '[]')
if runtime_deps_files:
library_paths = _ExtractSharedLibsFromRuntimeDeps(runtime_deps_files)
# Create a java literal array with the "base" library names:
# e.g. libfoo.so -> foo
java_libraries_list = ('{%s}' % ','.join(
['"%s"' % s[3:-3] for s in library_paths]))
java_libraries_list = _CreateJavaLibrariesList(library_paths)
secondary_abi_library_paths = []
secondary_abi_java_libraries_list = None
secondary_abi_runtime_deps_files = build_utils.ParseGnList(
options.secondary_abi_shared_libraries_runtime_deps or '[]')
if secondary_abi_runtime_deps_files:
secondary_abi_library_paths = _ExtractSharedLibsFromRuntimeDeps(
secondary_abi_runtime_deps_files)
secondary_abi_java_libraries_list = _CreateJavaLibrariesList(
secondary_abi_library_paths)
all_inputs.extend(runtime_deps_files)
config['native'] = {
'libraries': library_paths,
'secondary_abi_libraries': secondary_abi_library_paths,
'java_libraries_list': java_libraries_list,
'secondary_abi_java_libraries_list': secondary_abi_java_libraries_list,
}
config['assets'], config['uncompressed_assets'] = (
_MergeAssets(deps.All('android_assets')))

Просмотреть файл

@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Do not add any imports to non-//build directories here.
# Some projects (e.g. V8) do not have non-build directories DEPS'ed in.
import("//build_overrides/build.gni")
import("//build/config/android/config.gni")
import("//build/config/sanitizers/sanitizers.gni")
@ -300,6 +302,17 @@ template("write_build_config") {
]
}
if (defined(invoker.secondary_abi_shared_libraries_runtime_deps_file)) {
# Don't list secondary_abi_shared_libraries_runtime_deps_file as an
# input in order to avoid having to depend on the runtime_deps target.
# See comment in rules.gni for why we do this.
args += [
"--secondary-abi-shared-libraries-runtime-deps",
rebase_path(invoker.secondary_abi_shared_libraries_runtime_deps_file,
root_build_dir),
]
}
if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) {
args += [
"--proguard-enabled",
@ -629,6 +642,7 @@ template("test_runner_script") {
if (enable_java_templates) {
import("//build/config/zip.gni")
import("//third_party/ijar/ijar.gni")
import("//third_party/android_platform/config.gni")
rebased_android_sdk = rebase_path(android_sdk, root_build_dir)
rebased_android_sdk_build_tools =
@ -1272,8 +1286,16 @@ if (enable_java_templates) {
if (_native_lib_placeholders != []) {
args += [ "--native-lib-placeholders=$_native_lib_placeholders" ]
}
if (defined(invoker.secondary_native_libs) &&
invoker.secondary_native_libs != []) {
# TODO (michaelbai): Remove the secondary_native_libs variable.
if (defined(invoker.secondary_abi_native_libs_filearg)) {
assert(defined(android_app_secondary_abi))
args += [
"--secondary-native-libs=${invoker.secondary_abi_native_libs_filearg}",
"--secondary-android-abi=$android_app_secondary_abi",
]
} else if (defined(invoker.secondary_native_libs) &&
invoker.secondary_native_libs != []) {
assert(defined(android_app_secondary_abi))
inputs += invoker.secondary_native_libs
_secondary_native_libs = rebase_path(invoker.secondary_native_libs)
@ -1598,6 +1620,7 @@ if (enable_java_templates) {
"emma_instrument",
"native_lib_placeholders",
"native_libs_filearg",
"secondary_abi_native_libs_filearg",
"secondary_native_libs",
"uncompress_shared_libraries",
"write_asset_list",
@ -2640,4 +2663,40 @@ if (enable_java_templates) {
]
}
}
template("pack_relocation_section") {
assert(defined(invoker.file_list_json))
assert(defined(invoker.libraries_filearg))
action(target_name) {
forward_variables_from(invoker,
[
"deps",
"public_deps",
"inputs",
"testonly",
])
script = "//build/android/gyp/pack_relocations.py"
depfile = "$target_gen_dir/$target_name.d"
_packed_libraries_dir = "$target_gen_dir/$target_name/packed-libs"
outputs = [
invoker.file_list_json,
]
deps += [ relocation_packer_target ]
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--enable-packing=1",
"--android-pack-relocations",
rebase_path(relocation_packer_exe, root_build_dir),
"--stripped-libraries-dir",
rebase_path(root_build_dir, root_build_dir),
"--packed-libraries-dir",
rebase_path(_packed_libraries_dir, root_build_dir),
"--libraries=${invoker.libraries_filearg}",
"--filelistjson",
rebase_path(invoker.file_list_json, root_build_dir),
]
}
}
}

Просмотреть файл

@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Do not add any imports to non-//build directories here.
# Some projects (e.g. V8) do not have non-build directories DEPS'ed in.
import("//build/config/android/config.gni")
import("//build/config/android/internal_rules.gni")
import("//build/config/dcheck_always_on.gni")
@ -141,7 +143,6 @@ template("wrapper_script") {
if (enable_java_templates) {
import("//build/config/sanitizers/sanitizers.gni")
import("//third_party/android_platform/config.gni")
import("//tools/grit/grit_rule.gni")
# Declare a jni target
@ -1424,6 +1425,9 @@ if (enable_java_templates) {
# shared_libraries: List shared_library targets to bundle. If these
# libraries depend on other shared_library targets, those dependencies will
# also be included in the apk (e.g. for is_component_build).
# secondary_abi_shared_libraries: secondary abi shared_library targets to
# bundle. If these libraries depend on other shared_library targets, those
# dependencies will also be included in the apk (e.g. for is_component_build).
# native_lib_placeholders: List of placeholder filenames to add to the apk
# (optional).
# apk_under_test: For an instrumentation test apk, this is the target of the
@ -1438,7 +1442,8 @@ if (enable_java_templates) {
# requires_sdk_api_level_23: If defined and true, the apk is intended for
# installation only on Android M or later. In these releases the system
# linker does relocation unpacking, so we can enable it unconditionally.
# secondary_native_libs: The path of native libraries for secondary app abi.
# secondary_native_libs (deprecated): The path of native libraries for secondary
# app abi.
# run_findbugs_override: Forces run_findbugs on or off. If undefined, the
# default will use the build arg run_findbugs.
# proguard_jar_path: The path to proguard.jar you wish to use. If undefined,
@ -1554,13 +1559,25 @@ if (enable_java_templates) {
# The dependency that makes the chromium linker, if any is needed.
_native_libs_deps = []
_shared_libraries_is_valid =
defined(invoker.shared_libraries) && invoker.shared_libraries != []
_secondary_abi_native_libs_deps = []
assert(_secondary_abi_native_libs_deps == []) # mark as used.
_secondary_abi_shared_libraries_is_valid =
defined(invoker.secondary_abi_shared_libraries) &&
invoker.secondary_abi_shared_libraries != []
if (defined(invoker.shared_libraries) && invoker.shared_libraries != []) {
_native_libs_deps += invoker.shared_libraries
if (is_component_build || is_asan) {
if (is_component_build || is_asan) {
if (_shared_libraries_is_valid) {
_native_libs_deps += [ "//build/android:cpplib_stripped" ]
}
if (_secondary_abi_shared_libraries_is_valid) {
_secondary_abi_native_libs_deps += [ "//build/android:cpplib_stripped($android_secondary_abi_toolchain)" ]
}
}
if (_shared_libraries_is_valid) {
_native_libs_deps += invoker.shared_libraries
# To determine the filenames of all dependent shared libraries, write the
# runtime deps of |shared_libraries| to a file during "gn gen".
@ -1583,6 +1600,21 @@ if (enable_java_templates) {
}
}
if (_secondary_abi_shared_libraries_is_valid) {
_secondary_abi_native_libs_deps += invoker.secondary_abi_shared_libraries
# To determine the filenames of all dependent shared libraries, write the
# runtime deps of |shared_libraries| to a file during "gn gen".
# write_build_config.py will then grep this file for *.so to obtain the
# complete list.
_secondary_abi_runtime_deps_file =
"$target_gen_dir/${_template_name}.secondary.abi.native.runtimedeps"
group("${_template_name}_secondary_abi__runtime_deps") {
deps = _secondary_abi_native_libs_deps
write_runtime_deps = _secondary_abi_runtime_deps_file
}
}
if (defined(invoker.deps)) {
set_sources_assignment_filter([ "*manifest*" ])
sources = invoker.deps
@ -1661,6 +1693,10 @@ if (enable_java_templates) {
if (_native_libs_deps != []) {
shared_libraries_runtime_deps_file = _runtime_deps_file
}
if (_secondary_abi_native_libs_deps != []) {
secondary_abi_shared_libraries_runtime_deps_file =
_secondary_abi_runtime_deps_file
}
}
_final_deps = []
@ -1928,51 +1964,62 @@ if (enable_java_templates) {
_native_libs_file_arg_dep = ":$build_config_target"
_native_libs_file_arg = "@FileArg($_rebased_build_config:native:libraries)"
_secondary_abi_native_libs_file_arg_dep = ":$build_config_target"
_secondary_abi_native_libs_file_arg =
"@FileArg($_rebased_build_config:native:secondary_abi_libraries)"
assert(_secondary_abi_native_libs_file_arg != "" &&
_secondary_abi_native_libs_file_arg_dep != "") # Mark as used.
if (_native_libs_deps != [] && _enable_relocation_packing) {
_prepare_native_target_name = "${_template_name}__prepare_native"
_native_libs_dir = "$gen_dir/packed-libs"
_native_libs_json = "$gen_dir/packed-libs/filelist.json"
_rebased_native_libs_json = rebase_path(_native_libs_json, root_build_dir)
_native_libs_file_arg_dep = ":$_prepare_native_target_name"
_native_libs_file_arg = "@FileArg($_rebased_native_libs_json:files)"
action(_prepare_native_target_name) {
pack_relocation_section(_prepare_native_target_name) {
forward_variables_from(invoker,
[
"deps",
"public_deps",
])
script = "//build/android/gyp/pack_relocations.py"
depfile = "$target_gen_dir/$target_name.d"
outputs = [
_native_libs_json,
]
file_list_json = _native_libs_json
libraries_filearg =
"@FileArg(${_rebased_build_config}:native:libraries)"
inputs = [
_build_config,
]
deps += _native_libs_deps
deps += [
":$build_config_target",
relocation_packer_target,
]
deps += [ ":$build_config_target" ]
}
if (_secondary_abi_native_libs_deps != []) {
_prepare_native_target_name =
"${_template_name}_secondary_abi__prepare_native"
_native_libs_json =
"$gen_dir/packed-libs/$android_secondary_abi_cpu/filelist.json"
_rebased_native_libs_json =
rebase_path(_native_libs_json, root_build_dir)
_secondary_abi_native_libs_file_arg_dep =
":$_prepare_native_target_name"
_secondary_abi_native_libs_file_arg =
"@FileArg($_rebased_native_libs_json:files)"
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--enable-packing=1",
"--android-pack-relocations",
rebase_path(relocation_packer_exe, root_build_dir),
"--stripped-libraries-dir",
rebase_path(root_build_dir, root_build_dir),
"--packed-libraries-dir",
rebase_path(_native_libs_dir, root_build_dir),
"--libraries=@FileArg(${_rebased_build_config}:native:libraries)",
"--filelistjson=$_rebased_native_libs_json",
]
pack_relocation_section(_prepare_native_target_name) {
forward_variables_from(invoker,
[
"deps",
"public_deps",
])
file_list_json = _native_libs_json
libraries_filearg = "@FileArg(${_rebased_build_config}:native:secondary_abi_libraries)"
inputs = [
_build_config,
]
deps += _secondary_abi_native_libs_deps
deps += [ ":$build_config_target" ]
}
}
}
@ -2067,6 +2114,12 @@ if (enable_java_templates) {
_extra_native_libs_even_when_incremental
}
if (_secondary_abi_native_libs_deps != [] && !_create_abi_split) {
deps += _secondary_abi_native_libs_deps +
[ _secondary_abi_native_libs_file_arg_dep ]
secondary_abi_native_libs_filearg = _secondary_abi_native_libs_file_arg
}
# Placeholders necessary for some older devices.
# http://crbug.com/395038
forward_variables_from(invoker, [ "native_lib_placeholders" ])