Commit 4094cdde authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

Reland "[build:android] Add a module for AR in Monochrome"

This is a reland of bc740b07 with a fix
to include the loadable modules into the final APK.

Original change's description:
> [build:android] Add a module for AR in Monochrome
>
> Add an AR Dynamic Feature Module (DFM) and bundle it into the public
> Monochrome bundle.
>
> + Add loadable modules to the build config so that their paths can be
>   passed to the module create target.
>
> + Add option to bundle targets to specify the Android SDK target for
>   synchronized proguarding. This was necessary because the Monochrome
>   base module uses a different Android SDK than the AR module, which
>   made proguard sad. Also pass the Android SDK Jar as a dedicated
>   classpath Jar to proguard and don't mix it with the other classpath
>   Jars.
>
> Bug: 863063
> Change-Id: I024d05dd99136c069e510995657ac7236f6b6e5e
> Reviewed-on: https://chromium-review.googlesource.com/1165533
> Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
> Reviewed-by: Ted Choc <tedchoc@chromium.org>
> Reviewed-by: Ian Vollick <vollick@chromium.org>
> Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
> Reviewed-by: agrieve <agrieve@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#582765}

TBR=tedchoc@chromium.org

Bug: 863063, 873986
Change-Id: I4a72667027ab283b43685197c980b46e90553df8
Reviewed-on: https://chromium-review.googlesource.com/1174772
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583682}
parent b8782be3
......@@ -829,20 +829,22 @@ def main(argv):
parser.add_option('--shared-libraries-runtime-deps',
help='Path to file containing runtime deps for shared '
'libraries.')
parser.add_option('--native-libs',
action='append',
help='GN-list of native libraries for primary '
'android-abi. Can be specified multiple times.',
default=[])
parser.add_option('--secondary-abi-shared-libraries-runtime-deps',
help='Path to file containing runtime deps for secondary '
'abi shared libraries.')
parser.add_option('--secondary-native-libs',
action='append',
help='GYP-list of native libraries for secondary '
help='GN-list of native libraries for secondary '
'android-abi. Can be specified multiple times.',
default=[])
parser.add_option('--uncompress-shared-libraries', default=False,
action='store_true',
help='Whether to store native libraries uncompressed')
parser.add_option('--extra-shared-libraries',
help='GN-list of paths to extra native libraries stored '
'in the APK.')
# apk options
parser.add_option('--apk-path', help='Path to the target\'s apk output.')
parser.add_option('--incremental-apk-path',
......@@ -1220,7 +1222,7 @@ def main(argv):
if options.type in ('android_apk', 'dist_aar',
'dist_jar', 'android_app_bundle_module', 'android_app_bundle'):
all_configs = deps_info.get('proguard_configs', [])
extra_jars = list(system_jars)
extra_jars = list()
for c in all_library_deps:
all_configs.extend(
p for p in c.get('proguard_configs', []) if p not in all_configs)
......@@ -1381,12 +1383,12 @@ def main(argv):
secondary_abi_runtime_deps_files)
secondary_abi_java_libraries_list = _CreateJavaLibrariesList(
secondary_abi_library_paths)
for gn_list in options.secondary_native_libs:
secondary_abi_library_paths.extend(build_utils.ParseGnList(gn_list))
for gyp_list in options.secondary_native_libs:
secondary_abi_library_paths.extend(build_utils.ParseGnList(gyp_list))
extra_shared_libraries = build_utils.ParseGnList(
options.extra_shared_libraries)
extra_shared_libraries = []
for gn_list in options.native_libs:
extra_shared_libraries.extend(build_utils.ParseGnList(gn_list))
all_inputs.extend(runtime_deps_files)
config['native'] = {
......
......@@ -284,10 +284,15 @@ template("write_build_config") {
]
}
if (defined(invoker.loadable_modules) && invoker.loadable_modules != []) {
_rebased_modules = rebase_path(invoker.loadable_modules, root_build_dir)
args += [ "--native-libs=$_rebased_modules" ]
}
if (defined(invoker.extra_shared_libraries)) {
_rebased_extra_shared_libraries =
rebase_path(invoker.extra_shared_libraries, root_build_dir)
args += [ "--extra-shared-libraries=$_rebased_extra_shared_libraries" ]
args += [ "--native-libs=$_rebased_extra_shared_libraries" ]
}
if (defined(invoker.secondary_abi_shared_libraries_runtime_deps_file)) {
......@@ -303,9 +308,9 @@ template("write_build_config") {
if (defined(invoker.secondary_abi_loadable_modules) &&
invoker.secondary_abi_loadable_modules != []) {
_rebased_modules =
_rebased_secondary_abi_modules =
rebase_path(invoker.secondary_abi_loadable_modules, root_build_dir)
args += [ "--secondary-native-libs=$_rebased_modules" ]
args += [ "--secondary-native-libs=$_rebased_secondary_abi_modules" ]
}
if (defined(invoker.uncompress_shared_libraries) &&
......@@ -921,6 +926,8 @@ if (enable_java_templates) {
rebase_path(_output_jar_path, root_build_dir),
"--classpath",
"@FileArg($_rebased_build_config:deps_info:proguard_classpath_jars)",
"--classpath",
"@FileArg($_rebased_build_config:android:sdk_jars)",
]
if (experimental_r8_path != "") {
args += [
......@@ -2884,6 +2891,7 @@ if (enable_java_templates) {
"classpath_deps",
"gradle_treat_as_prebuilt",
"input_jars_paths",
"loadable_modules",
"main_class",
"proguard_configs",
"proguard_enabled",
......
......@@ -2296,6 +2296,7 @@ if (enable_java_templates) {
"emma_never_instrument",
"java_files",
"javac_args",
"loadable_modules",
"no_build_hooks",
"secondary_abi_loadable_modules",
"uncompress_shared_libraries",
......@@ -2633,8 +2634,6 @@ if (enable_java_templates) {
args += [ "--native-libs=$_native_libs_file_arg" ]
}
if (_extra_native_libs != []) {
# Don't pass in _extra_native_libs_even_when_incremental, since these are
# end up in the apk and are not side-loaded.
_rebased_extra_native_libs =
rebase_path(_extra_native_libs, root_build_dir)
args += [ "--native-libs=$_rebased_extra_native_libs" ]
......@@ -3640,7 +3639,10 @@ if (enable_java_templates) {
# proguarding.
#
# enable_multidex: Optional. Enable multidexing of optimized modules jars
# when using synchronized proguarding.
# when using synchronized proguarding. Only applies to base module.
#
# proguard_android_sdk_dep: Optional. android_system_java_prebuilt() target
# used as a library jar for synchronized proguarding.
#
# Example:
# android_app_bundle("chrome_public_bundle") {
......@@ -3692,9 +3694,14 @@ if (enable_java_templates) {
_build_config = "$target_gen_dir/${target_name}.build_config"
_rebased_build_config = rebase_path(_build_config, root_build_dir)
_build_config_target = "${target_name}__build_config"
if (defined(invoker.proguard_android_sdk_dep)) {
proguard_android_sdk_dep_ = invoker.proguard_android_sdk_dep
} else {
proguard_android_sdk_dep_ = "//third_party/android_tools:android_sdk_java"
}
write_build_config(_build_config_target) {
type = "android_app_bundle"
possible_config_deps = _module_targets
possible_config_deps = _module_targets + [ proguard_android_sdk_dep_ ]
build_config = _build_config
}
......@@ -3770,7 +3777,7 @@ if (enable_java_templates) {
# http://crbug.com/725224. Fix for bots running out of memory.
use_pool = true
if (_enable_multidex) {
if (_enable_multidex && _module.name == "base") {
enable_multidex = _enable_multidex
extra_main_dex_proguard_config =
"$_module_target_gen_dir/$_module_target_name/" +
......
......@@ -22,6 +22,9 @@ import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
import("channel.gni")
import("java_sources.gni")
import("static_initializers.gni")
if (enable_arcore) {
import("//chrome/android/modules/ar/ar_module_tmpl.gni")
}
manifest_package = "org.chromium.chrome"
......@@ -1705,7 +1708,14 @@ if (defined(expected_static_initializer_count)) {
}
}
# Generate application bundles if possible.
# Feature modules that go into Chrome Android application bundles.
if (enable_arcore) {
ar_module_tmpl("ar_public_module") {
manifest_package = manifest_package
}
}
# Chrome Android application bundles.
android_app_bundle("chrome_public_bundle") {
bundle_name = "ChromePublicBundle"
base_module_target = ":chrome_public_base_module"
......@@ -1729,5 +1739,14 @@ android_app_bundle("monochrome_public_bundle") {
if (!is_java_debug) {
proguard_enabled = true
enable_multidex = true
proguard_android_sdk_dep = webview_framework_dep
}
if (enable_arcore) {
extra_modules = [
{
name = "ar"
module_target = ":ar_public_module"
},
]
}
}
......@@ -263,23 +263,19 @@ template("monochrome_public_common_apk_or_module_tmpl") {
png_to_webp = true
}
if (enable_arcore) {
deps += [ "//third_party/arcore-android-sdk:libdynamite_client_java" ]
}
if (package_arcore) {
# We store this as a separate .so in the APK and only load as needed.
if (android_64bit_target_cpu && build_apk_secondary_abi) {
deps += [
"//third_party/arcore-android-sdk:libarcore_library_secondary_abi",
]
toolchain_out_dir = get_label_info(
"//third_party/arcore-android-sdk:libarcore_library($android_secondary_abi_toolchain)",
"root_out_dir")
secondary_abi_loadable_modules =
[ "${toolchain_out_dir}/libarcore_sdk_c_minimal.so" ]
} else {
deps += [ "//third_party/arcore-android-sdk:libarcore_library" ]
loadable_modules = [ "${root_out_dir}/libarcore_sdk_c_minimal.so" ]
if (invoker.target_type == "android_apk") {
if (enable_arcore) {
deps += [ "//third_party/arcore-android-sdk:libdynamite_client_java" ]
}
if (package_arcore) {
# We store this as a separate .so in the APK and only load as needed.
if (android_64bit_target_cpu && build_apk_secondary_abi) {
secondary_abi_loadable_modules = [ "//third_party/arcore-android-sdk/libraries/android_arm/libarcore_sdk_c_minimal.so" ]
} else if (android_64bit_target_cpu && !build_apk_secondary_abi) {
loadable_modules = [ "//third_party/arcore-android-sdk/libraries/android_arm64/libarcore_sdk_c_minimal.so" ]
} else {
loadable_modules = [ "//third_party/arcore-android-sdk/libraries/android_arm/libarcore_sdk_c_minimal.so" ]
}
}
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 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. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="{{manifest_package}}">
<!-- Chrome AR is only supported on Android N+. -->
<uses-sdk
android:minSdkVersion="24"
android:targetSdkVersion="{{target_sdk_version}}" />
<!-- TODO(crbug.com/863068): Set dist:onDemand="true" once we can on-demand
install modules. -->
<!-- TODO(crbug.com/871912: Use @string reference for dist:title. -->
<dist:module
dist:onDemand="false"
dist:title="AR">
<dist:fusing dist:include="false" />
</dist:module>
<application>
</application>
</manifest>
tiborg@chromium.org
vollick@chromium.org
# TEAM: xr-dev@chromium.org
# COMPONENT: Internals>XR>AR
# OS: Android
\ No newline at end of file
The AR dynamic feature module on-demand delivers code necessary to support AR in
Chrome. This folder contains the template for creating an AR DFM target as well
as the required Android manifest.
\ No newline at end of file
# Copyright 2018 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.
import("//build/config/android/rules.gni")
import("//device/vr/buildflags/buildflags.gni")
assert(enable_arcore)
template("ar_module_tmpl") {
_manifest = "$target_gen_dir/AndroidManifest.xml"
assert(defined(invoker.manifest_package))
_manifest_target = "${target_name}__manifest"
jinja_template(_manifest_target) {
input = "//chrome/android/modules/ar/AndroidManifest.xml"
output = _manifest
variables = [
"target_sdk_version=$android_sdk_version",
"manifest_package=${invoker.manifest_package}",
]
}
android_app_bundle_module(target_name) {
module_name = "ArModule"
android_manifest = _manifest
android_manifest_dep = ":$_manifest_target"
deps = [
"//third_party/arcore-android-sdk:libdynamite_client_java",
]
# We only want to add the 32 bit arcore shim even for 64 bit monochrome
# builds. AR is never used in 64 bit mode. We store the arcore shim as a
# separate .so in the bundle module and only load as needed.
if (android_64bit_target_cpu && build_apk_secondary_abi) {
secondary_abi_loadable_modules = [ "//third_party/arcore-android-sdk/libraries/android_arm/libarcore_sdk_c_minimal.so" ]
# Bundletool requires all modules of a bundle to support the same set of
# architectures. Monochrome base module supports arm64. Add a zero-byte,
# "64 bit" dummy library to trick bundletool into thinking that the AR
# module does support arm64, too.
loadable_modules =
[ "//third_party/arcore-android-sdk/libarcore_dummy.so" ]
} else if (android_64bit_target_cpu && !build_apk_secondary_abi) {
loadable_modules = [ "//third_party/arcore-android-sdk/libraries/android_arm64/libarcore_sdk_c_minimal.so" ]
} else {
loadable_modules = [ "//third_party/arcore-android-sdk/libraries/android_arm/libarcore_sdk_c_minimal.so" ]
}
uncompress_shared_libraries = true
proguard_enabled = !is_java_debug
}
}
......@@ -10,30 +10,6 @@ java_prebuilt("libdynamite_client_java") {
jar_path = "libarcore_client_c.jar"
}
if (!android_64bit_target_cpu || !build_apk_secondary_abi ||
current_toolchain == android_secondary_abi_toolchain) {
copy("libarcore_library") {
if (current_cpu == "arm") {
sources = [
"libraries/android_arm/libarcore_sdk_c_minimal.so",
]
} else if (current_cpu == "arm64") {
sources = [
"libraries/android_arm64/libarcore_sdk_c_minimal.so",
]
}
outputs = [
"${root_out_dir}/libarcore_sdk_c_minimal.so",
]
}
} else {
group("libarcore_library_secondary_abi") {
public_deps = [
":libarcore_library($android_secondary_abi_toolchain)",
]
}
}
config("libarcore_config") {
include_dirs = [ "src/libraries/include/" ]
}
......@@ -29,6 +29,9 @@ The LICENSE file is taken from
* https://github.com/google-ar/arcore-unity-sdk/blob/master/LICENSE
Changes:
2018-08-10 - First, removed arcore shim copy target from BUILD.gn since it is no
longer needed. Second, added zero-byte dummy arcore library for AR
module support.
2018-07-26 - Added test-apks/ subdirectory for storing production versions of AR
APKs for testing.
2018-07-19 - Updated BUILD.gn to support secondary abi (the previous change for
......
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