Commit d687ea10 authored by Fred Mello's avatar Fred Mello Committed by Commit Bot

Remove the need for srcjar_deps in module_installer

Moved logic from ModuleInstallerConfig to BuildConfig (template).

TBR=fredmello  #trivial refactor

Bug: 1005802
Change-Id: Iee0a409105c42bebac88d6d92ef227391697ff49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1841694
Commit-Queue: Fred Mello <fredmello@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703058}
parent 8e0e06f1
......@@ -68,4 +68,10 @@ public class BuildConfig {
#else
public static MAYBE_FINAL int MIN_SDK_VERSION = 1;
#endif
#if defined(_IS_BUNDLE)
public static MAYBE_FINAL boolean IS_BUNDLE = true;
#else
public static MAYBE_FINAL boolean IS_BUNDLE MAYBE_FALSE;
#endif
}
......@@ -1985,6 +1985,10 @@ if (enable_java_templates) {
defines += [ "_IS_CHROME_BRANDED" ]
}
if (defined(invoker.is_bundle_module) && invoker.is_bundle_module) {
defines += [ "_IS_BUNDLE" ]
}
if (invoker.use_final_fields) {
forward_variables_from(invoker,
[
......@@ -2698,7 +2702,11 @@ if (enable_java_templates) {
if (_generate_buildconfig_java) {
generate_build_config_srcjar("${_template_name}__build_config_srcjar") {
forward_variables_from(invoker, [ "min_sdk_version" ])
forward_variables_from(invoker,
[
"is_bundle_module",
"min_sdk_version",
])
use_final_fields = true
enable_multidex = _enable_multidex
if (defined(invoker.product_version_resources_dep)) {
......
......@@ -738,9 +738,6 @@ junit_binary("chrome_junit_tests") {
"//testing/buildbot/filters:chrome_junit_tests_filters",
]
srcjar_deps =
[ "//components/module_installer/android:module_installer_build_config" ]
package_name = chrome_public_manifest_package
}
......
......@@ -232,24 +232,18 @@ template("chrome_public_common_apk_or_module_tmpl") {
}
}
# Only bundles can install modules. Therefore, include stub implementation
# for all other targets to save some binary size.
if (_target_type == "android_app_bundle_module") {
srcjar_deps = [ "//components/module_installer/android:module_installer_bundle_build_config" ]
} else { # |_target_type| is "android_apk" or "instrumentation_test_apk".
if (dfmify_dev_ui) {
# Native resource split moves resources out of resources.pak, but this
# is a DFM feature, which APKs don't use. To make the resources split
# available for APKs, add dependencies to (1) Java classes, (2)
# resources of the resource split's DFM (e.g., DevUI DFM). The Java
# classes tells Chrome that the DFM is installed, which then causes the
# included resources to be loaded when needed.
deps += [
"//chrome/android/features/dev_ui:java", # (1) from above.
"//chrome/android/features/dev_ui:pak_assets", # (2) from above.
]
}
srcjar_deps = [ "//components/module_installer/android:module_installer_apk_build_config" ]
if (dfmify_dev_ui && (_target_type == "android_apk" ||
_target_type == "instrumentation_test_apk")) {
# Native resource split moves resources out of resources.pak, but this
# is a DFM feature, which APKs don't use. To make the resources split
# available for APKs, add dependencies to (1) Java classes, (2)
# resources of the resource split's DFM (e.g., DevUI DFM). The Java
# classes tells Chrome that the DFM is installed, which then causes the
# included resources to be loaded when needed.
deps += [
"//chrome/android/features/dev_ui:java", # (1) from above.
"//chrome/android/features/dev_ui:pak_assets", # (2) from above.
]
}
if (!is_java_debug) {
......
......@@ -102,7 +102,4 @@ junit_binary("keyboard_accessory_junit_tests") {
"//third_party/junit",
"//third_party/mockito:mockito_java",
]
srcjar_deps =
[ "//components/module_installer/android:module_installer_build_config" ]
}
......@@ -55,9 +55,6 @@ junit_binary("touch_to_fill_junit_tests") {
"//third_party/junit",
"//third_party/mockito:mockito_java",
]
srcjar_deps =
[ "//components/module_installer/android:module_installer_build_config" ]
}
android_library("test_java") {
......
......@@ -607,9 +607,6 @@ if (is_android) {
"android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsActivity.java",
"android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsApplication.java",
]
srcjar_deps = [
"//components/module_installer/android:module_installer_build_config",
]
}
jinja_template("android_browsertests_manifest") {
......@@ -3672,10 +3669,6 @@ test("unit_tests") {
"//chrome/android/modules/dev_ui/provider:java",
]
}
srcjar_deps = [
"//components/module_installer/android:module_installer_build_config",
]
} else {
# !is_android
sources += [
......
......@@ -37,8 +37,6 @@ android_library("module_installer_java") {
"//third_party/google_android_play_core:com_google_android_play_core_java",
]
srcjar_deps = [ ":module_installer_build_config" ]
jar_excluded_patterns = [ "*/ModuleInstallerConfig.class" ]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
......@@ -81,28 +79,13 @@ java_annotation_processor("module_interface_processor") {
# Use this one if your target needs to depend on ModuleInstallerConfig. The
# other two targets are automatically added to build targets.
java_cpp_template("module_installer_build_config") {
# TODO(fredmello): Temporary code to keep downstream unbroken.
package_path = "org/chromium/components/module_installer/builder"
sources = [
"build/ModuleInstallerConfig.template",
]
}
java_cpp_template("module_installer_bundle_build_config") {
package_path = "org/chromium/components/module_installer/builder"
sources = [
"build/ModuleInstallerConfig.template",
]
defines = [ "IS_BUNDLE_BUILD" ]
}
java_cpp_template("module_installer_apk_build_config") {
package_path = "org/chromium/components/module_installer/builder"
sources = [
"build/ModuleInstallerConfig.template",
]
defines = [ "IS_APK_BUILD" ]
}
source_set("native") {
sources = [
"module.cc",
......
......@@ -4,16 +4,8 @@
package org.chromium.components.module_installer.builder;
/** Build config for DFMs. */
public class ModuleInstallerConfig {
#if defined(IS_BUNDLE_BUILD)
public static final boolean IS_BUNDLE = true;
#elif defined(IS_APK_BUILD)
public static final boolean IS_BUNDLE = false;
#else
// This needs to not be final in order to avoid being inlined.
public static boolean IS_BUNDLE;
#endif
}
/**
* Build config for DFMs.
* TODO(fredmello): Temporary code to keep downstream unbroken
*/
public class ModuleInstallerConfig { }
......@@ -4,15 +4,15 @@
package org.chromium.components.module_installer.engine;
import org.chromium.base.BuildConfig;
import org.chromium.base.CommandLine;
import org.chromium.components.module_installer.builder.ModuleInstallerConfig;
/**
* Factory used to build concrete engines.
*/
public class EngineFactory {
public InstallEngine getEngine() {
if (!ModuleInstallerConfig.IS_BUNDLE) {
if (!BuildConfig.IS_BUNDLE) {
return new ApkEngine();
}
if (CommandLine.getInstance().hasSwitch("fake-feature-module-install")) {
......
......@@ -4,8 +4,8 @@
package org.chromium.components.module_installer.util;
import org.chromium.base.BuildConfig;
import org.chromium.base.annotations.MainDex;
import org.chromium.components.module_installer.builder.ModuleInstallerConfig;
import org.chromium.components.module_installer.logger.SplitAvailabilityLogger;
/**
......@@ -20,7 +20,7 @@ public class ModuleUtil {
* unnecessary code (modules are not supported in APKs).
*/
public static void recordStartupTime() {
if (!ModuleInstallerConfig.IS_BUNDLE) return;
if (!BuildConfig.IS_BUNDLE) return;
Timer.recordStartupTime();
}
......@@ -29,7 +29,7 @@ public class ModuleUtil {
* Records the start time in order to later report the install duration via UMA.
*/
public static void recordModuleAvailability() {
if (!ModuleInstallerConfig.IS_BUNDLE) return;
if (!BuildConfig.IS_BUNDLE) return;
try (Timer timer = new Timer()) {
initApplication();
......@@ -41,7 +41,7 @@ public class ModuleUtil {
* Updates the CrashKey report containing modules currently present.
*/
public static void updateCrashKeys() {
if (!ModuleInstallerConfig.IS_BUNDLE) return;
if (!BuildConfig.IS_BUNDLE) return;
try (Timer timer = new Timer()) {
CrashKeyRecorder.updateCrashKeys();
......@@ -52,7 +52,7 @@ public class ModuleUtil {
* Initializes the PlayCore SplitCompat framework.
*/
public static void initApplication() {
if (!ModuleInstallerConfig.IS_BUNDLE) return;
if (!BuildConfig.IS_BUNDLE) return;
try (Timer timer = new Timer()) {
SplitCompatInitializer.initApplication();
......
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