blob: 893a6051c8ab0cab8d6c53c6a9945efbc8258176 [file] [log] [blame]
# 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.
import("//build/config/android/rules.gni")
import("current_version/current_version.gni")
import("manifest/manifest_mustache_pass.gni")
webapk_manifest_to_upload_output =
"${target_gen_dir}/webapk_manifest_to_upload/AndroidManifest.xml"
h2o_junit_manifest_output =
"${target_gen_dir}/junit_manifest/AndroidManifest.xml"
# GN breaks with a mysterious error if the target has the word "junit" in it.
h2o_junit_manifest_target_name = "h2o_j_unit_manifest_target"
android_resources("new_splash_resources") {
custom_package = "org.chromium.webapk.shell_apk.h2o"
resource_dirs = [ "res_h2o" ]
deps = []
}
# Stamped out copy of the runtime-library, used for fail-safe code in when using an
# old copy of the runtime library.
android_library("compiled_in_runtime_library_java") {
chromium_code = false
java_files = [ "src/org/chromium/webapk/lib/runtime_library/IWebApkApi.java" ]
}
# Split out as a separate target so that it can be tested from chrome_public_test_apk
android_library("dex_loader_java") {
java_files = [ "src/org/chromium/webapk/shell_apk/DexLoader.java" ]
}
template("webapk_java") {
android_library(target_name) {
forward_variables_from(invoker,
[
"android_manifest_for_lint",
"deps",
])
java_files = [
"src/org/chromium/webapk/shell_apk/HostBrowserClassLoader.java",
"src/org/chromium/webapk/shell_apk/HostBrowserLauncher.java",
"src/org/chromium/webapk/shell_apk/HostBrowserLauncherParams.java",
"src/org/chromium/webapk/shell_apk/ChooseHostBrowserDialog.java",
"src/org/chromium/webapk/shell_apk/HostBrowserUtils.java",
"src/org/chromium/webapk/shell_apk/IdentityService.java",
"src/org/chromium/webapk/shell_apk/InstallHostBrowserDialog.java",
"src/org/chromium/webapk/shell_apk/LaunchHostBrowserSelector.java",
"src/org/chromium/webapk/shell_apk/MainActivity.java",
"src/org/chromium/webapk/shell_apk/TransparentLauncherActivity.java",
"src/org/chromium/webapk/shell_apk/WebApkServiceFactory.java",
"src/org/chromium/webapk/shell_apk/WebApkServiceImplWrapper.java",
"src/org/chromium/webapk/shell_apk/WebApkSharedPreferences.java",
"src/org/chromium/webapk/shell_apk/WebApkUtils.java",
]
deps += [
":compiled_in_runtime_library_java",
":dex_loader_java",
"//chrome/android/webapk/libs/common:common_java",
]
if (invoker.use_new_splash) {
java_files += [
"src/org/chromium/webapk/shell_apk/h2o/H2OLauncher.java",
"src/org/chromium/webapk/shell_apk/h2o/H2OMainActivity.java",
"src/org/chromium/webapk/shell_apk/h2o/H2OOpaqueMainActivity.java",
"src/org/chromium/webapk/shell_apk/h2o/H2OTransparentLauncherActivity.java",
"src/org/chromium/webapk/shell_apk/h2o/OverlaySplashActivity.java",
"src/org/chromium/webapk/shell_apk/h2o/SplashActivity.java",
]
deps += [ "//chrome/android/webapk/libs/common:splash_java" ]
}
}
}
template("webapk_tmpl") {
_manifest_to_upload_target_name = "${target_name}_manifest_to_upload"
_manifest_to_upload_output =
"${target_gen_dir}/${_manifest_to_upload_target_name}/AndroidManifest.xml"
_manifest_target_name = "${target_name}_generate_manifest"
_manifest_output =
"${target_gen_dir}/${_manifest_target_name}/AndroidManifest.xml"
_java_target_name = "${target_name}_java"
_resources_target_name = "${target_name}_resources"
_use_new_splash = false
if (defined(invoker.use_new_splash)) {
_use_new_splash = invoker.use_new_splash
}
if (defined(invoker.manifest_to_upload_output)) {
_manifest_to_upload_output = invoker.manifest_to_upload_output
}
if (defined(invoker.manifest_output)) {
_manifest_output = invoker.manifest_output
}
if (defined(invoker.manifest_target_name)) {
_manifest_target_name = invoker.manifest_target_name
}
# Generate manifest to upload to WebAPK server. Fills in all of the fields
# that the server cannot customize on a per-site basis.
manifest_mustache_pass(_manifest_to_upload_target_name) {
input = "AndroidManifest.xml"
output = _manifest_to_upload_output
extra_variables = [
"shell_apk_version=$current_shell_apk_version",
"use_new_splash=$_use_new_splash",
]
}
# Generate manifest with test values.
manifest_mustache_pass(_manifest_target_name) {
forward_variables_from(invoker,
[
"apk_package_name",
"config_file",
"delta_config_file",
])
input = _manifest_to_upload_output
output = _manifest_output
extra_variables = [ "manifest_package=$apk_package_name" ]
deps = [
":$_manifest_to_upload_target_name",
]
}
android_resources(_resources_target_name) {
custom_package = "org.chromium.webapk.shell_apk"
resource_dirs = [ "res" ]
deps = [
":webapk_strings_grd",
]
if (_use_new_splash) {
deps += [ ":new_splash_resources" ]
}
}
webapk_java(_java_target_name) {
android_manifest_for_lint = _manifest_output
use_new_splash = _use_new_splash
deps = [
":$_manifest_target_name",
":$_resources_target_name",
]
}
android_apk(target_name) {
forward_variables_from(invoker, [ "apk_name" ])
deps = [
":$_java_target_name",
]
android_manifest = _manifest_output
android_manifest_dep = ":$_manifest_target_name"
never_incremental = true
# Force 32 bit mode on 64 bit devices.
native_lib_placeholders = [ "libfoo.so" ]
if (!is_java_debug) {
if (defined(webapk_proguard_jar_path)) {
proguard_jar_path = webapk_proguard_jar_path
}
proguard_enabled = true
proguard_configs = [
"//chrome/android/webapk/shell_apk/proguard.flags",
"//chrome/android/java/proguard.flags",
"//base/android/proguard/chromium_apk.flags",
"//base/android/proguard/chromium_code.flags",
]
}
}
}
java_strings_grd("webapk_strings_grd") {
grd_file = "//chrome/android/webapk/strings/android_webapk_strings.grd"
outputs = [
"values-am/android_webapk_strings.xml",
"values-ar/android_webapk_strings.xml",
"values-bg/android_webapk_strings.xml",
"values-ca/android_webapk_strings.xml",
"values-cs/android_webapk_strings.xml",
"values-da/android_webapk_strings.xml",
"values-de/android_webapk_strings.xml",
"values-el/android_webapk_strings.xml",
"values/android_webapk_strings.xml",
"values-en-rGB/android_webapk_strings.xml",
"values-es/android_webapk_strings.xml",
"values-es-rUS/android_webapk_strings.xml",
"values-fa/android_webapk_strings.xml",
"values-fi/android_webapk_strings.xml",
"values-tl/android_webapk_strings.xml",
"values-fr/android_webapk_strings.xml",
"values-hi/android_webapk_strings.xml",
"values-hr/android_webapk_strings.xml",
"values-hu/android_webapk_strings.xml",
"values-in/android_webapk_strings.xml",
"values-it/android_webapk_strings.xml",
"values-iw/android_webapk_strings.xml",
"values-ja/android_webapk_strings.xml",
"values-ko/android_webapk_strings.xml",
"values-lt/android_webapk_strings.xml",
"values-lv/android_webapk_strings.xml",
"values-nl/android_webapk_strings.xml",
"values-nb/android_webapk_strings.xml",
"values-pl/android_webapk_strings.xml",
"values-pt-rBR/android_webapk_strings.xml",
"values-pt-rPT/android_webapk_strings.xml",
"values-ro/android_webapk_strings.xml",
"values-ru/android_webapk_strings.xml",
"values-sk/android_webapk_strings.xml",
"values-sl/android_webapk_strings.xml",
"values-sr/android_webapk_strings.xml",
"values-sv/android_webapk_strings.xml",
"values-sw/android_webapk_strings.xml",
"values-th/android_webapk_strings.xml",
"values-tr/android_webapk_strings.xml",
"values-uk/android_webapk_strings.xml",
"values-vi/android_webapk_strings.xml",
"values-zh-rCN/android_webapk_strings.xml",
"values-zh-rTW/android_webapk_strings.xml",
]
}
# Template for WebAPK. When a WebAPK is generated:
# - Android manifest is customized to the website.
# - App icon is extracted from the website and added to the APK's resources.
webapk_tmpl("webapk") {
config_file = "manifest/bound_manifest_config.json"
apk_name = "WebApk"
apk_package_name = "org.chromium.webapk"
manifest_to_upload_output = webapk_manifest_to_upload_output
}
webapk_tmpl("maps_go_webapk") {
config_file = "manifest/maps_go_manifest_config.json"
apk_name = "MapsWebApk"
apk_package_name = "org.chromium.maps_go_webapk"
}
webapk_tmpl("unbound_webapk") {
config_file = "manifest/unbound_manifest_config.json"
apk_name = "UnboundWebApk"
apk_package_name = "org.chromium.arbitrarypackage"
}
webapk_tmpl("new_splash_webapk") {
use_new_splash = true
config_file = "manifest/bound_manifest_config.json"
apk_name = "NewSplashWebApk"
apk_package_name = "org.chromium.webapk.new.splash"
}
# Used by webapk_shell_apk_h2o_junit_tests
webapk_tmpl("h2o_j_unit_webapk") {
use_new_splash = true
config_file = "manifest/bound_manifest_config.json"
apk_name = "H2OJUnitWebApk"
apk_package_name = "org.chromium.webapk.h2o.junit_webapk"
manifest_output = h2o_junit_manifest_output
manifest_target_name = h2o_junit_manifest_target_name
}
android_library("shell_apk_javatests") {
testonly = true
java_files =
[ "javatests/src/org/chromium/webapk/shell_apk/DexLoaderTest.java" ]
deps = [
":dex_loader_java",
"//base:base_java",
"//base:base_java_test_support",
"//chrome/android/webapk/libs/common:common_java",
"//content/public/test/android:content_java_test_support",
"//third_party/android_support_test_runner:runner_java",
"//third_party/junit",
]
srcjar_deps = [ "javatests/dex_optimizer:dex_optimizer_service_aidl" ]
}
junit_binary("webapk_shell_apk_junit_tests") {
java_files = [
"junit/src/org/chromium/webapk/shell_apk/HostBrowserClassLoaderTest.java",
"junit/src/org/chromium/webapk/shell_apk/HostBrowserLauncherParamsTest.java",
"junit/src/org/chromium/webapk/shell_apk/HostBrowserUtilsTest.java",
"junit/src/org/chromium/webapk/shell_apk/MainActivityTest.java",
"junit/src/org/chromium/webapk/shell_apk/WebApkServiceImplWrapperTest.java",
"junit/src/org/chromium/webapk/shell_apk/WebApkUtilsTest.java",
]
deps = [
":compiled_in_runtime_library_java",
":dex_loader_java",
":webapk_java",
"//chrome/android/webapk/libs/common:common_java",
"//chrome/android/webapk/libs/runtime_library:runtime_library_for_tests_java",
"//chrome/android/webapk/test:junit_test_support",
]
}
junit_binary("webapk_shell_apk_h2o_junit_tests") {
java_files = [ "junit/src/org/chromium/webapk/shell_apk/h2o/LaunchTest.java" ]
deps = [
":${h2o_junit_manifest_target_name}",
":h2o_j_unit_webapk_java",
"//chrome/android/webapk/libs/common:common_java",
"//chrome/android/webapk/test:junit_test_support",
]
data_deps = [
":${h2o_junit_manifest_target_name}",
]
android_manifest_path = h2o_junit_manifest_output
}