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