Skip to content

Commit

Permalink
Move BuildConfig.template to //build
Browse files Browse the repository at this point in the history
The rationale for this change is to decrease dependencies from //build
on to //base.

BUG=1189911

Change-Id: Icb166cfd2ec39f814c92966d4e900463611a7306
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2774858
Reviewed-by: Yaron Friedman <[email protected]>
Reviewed-by: Andrew Grieve <[email protected]>
Owners-Override: Yaron Friedman <[email protected]>
Commit-Queue: Peter Kotwicz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#867219}
  • Loading branch information
pkotwicz authored and Chromium LUCI CQ committed Mar 29, 2021
1 parent 375425b commit 87ccf2f
Show file tree
Hide file tree
Showing 43 changed files with 76 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.chromium.android_webview.common.AwSwitches;
import org.chromium.android_webview.gfx.AwDrawFnImpl;
import org.chromium.android_webview.variations.VariationsSeedLoader;
import org.chromium.base.BuildConfig;
import org.chromium.base.BuildInfo;
import org.chromium.base.BundleUtils;
import org.chromium.base.CommandLine;
Expand All @@ -49,6 +48,7 @@
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.ScopedSysTraceEvent;
import org.chromium.base.task.PostTask;
import org.chromium.build.BuildConfig;
import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.net.NetworkChangeNotifier;
import org.chromium.ui.base.ResourceBundle;
Expand Down
20 changes: 7 additions & 13 deletions base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3739,8 +3739,7 @@ if (is_android) {
"android/java/src/org/chromium/base/NativeLibraryLoadedStatus.java",
"android/java/src/org/chromium/base/annotations/NativeMethods.java",
]
srcjar_deps = [ ":base_build_config_gen" ]
jar_excluded_patterns = [ "*/BuildConfig.class" ]
deps = [ "//build/android:build_config_java" ]
}

java_cpp_strings("java_switches_srcjar") {
Expand All @@ -3753,7 +3752,6 @@ if (is_android) {
android_library("base_java") {
srcjar_deps = [
":base_android_java_enums_srcjar",
":base_build_config_gen",
":base_java_aidl",
":base_native_libraries_gen",
":java_switches_srcjar",
Expand All @@ -3767,13 +3765,17 @@ if (is_android) {
"//third_party/androidx:androidx_multidex_multidex_java",
]

public_deps = [ ":jni_java" ]
public_deps = [
":jni_java",
"//build/android:build_config_java",
]

sources = [
"android/java/src/org/chromium/base/ActivityState.java",
"android/java/src/org/chromium/base/ApiCompatibilityUtils.java",
"android/java/src/org/chromium/base/ApkAssets.java",
"android/java/src/org/chromium/base/ApplicationStatus.java",
"android/java/src/org/chromium/base/BuildConfig.java",
"android/java/src/org/chromium/base/BuildInfo.java",
"android/java/src/org/chromium/base/BundleUtils.java",
"android/java/src/org/chromium/base/ByteArrayGenerator.java",
Expand Down Expand Up @@ -3927,7 +3929,6 @@ if (is_android) {
# New versions of BuildConfig.java and NativeLibraries.java
# (with the actual correct values) will be created when creating an apk.
jar_excluded_patterns = [
"*/BuildConfig.class",
"*/NativeLibraries.class",
"*/NativeLibraries##*.class",
]
Expand Down Expand Up @@ -4126,10 +4127,7 @@ if (is_android) {

# Make sure robolectric tests have classes filtered out of base_java by
# jar_excluded_patterns.
srcjar_deps = [
":base_build_config_gen",
":base_native_libraries_gen",
]
srcjar_deps = [ ":base_native_libraries_gen" ]
deps = [
":base_java",
"//testing/android/junit:junit_test_support",
Expand Down Expand Up @@ -4226,10 +4224,6 @@ if (is_android) {
deps = [ "//base:base_java" ]
}

generate_build_config_srcjar("base_build_config_gen") {
use_final_fields = false
}

write_native_libraries_java("base_native_libraries_gen") {
use_final_fields = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.build.BuildConfig;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
Expand Down
11 changes: 11 additions & 0 deletions base/android/java/src/org/chromium/base/BuildConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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.

package org.chromium.base;

/**
* Temporary alias for org.chromium.build.BuildConfig to avoid breaking internal
* build.
*/
public class BuildConfig extends org.chromium.build.BuildConfig {}
1 change: 1 addition & 0 deletions base/android/java/src/org/chromium/base/BuildInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.compat.ApiHelperForP;
import org.chromium.build.BuildConfig;

/**
* BuildInfo is a utility class providing easy access to {@link PackageInfo} information. This is
Expand Down
1 change: 1 addition & 0 deletions base/android/java/src/org/chromium/base/BundleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.compat.ApiHelperForO;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.build.BuildConfig;

import java.lang.reflect.Field;
import java.util.Arrays;
Expand Down
1 change: 1 addition & 0 deletions base/android/java/src/org/chromium/base/ContextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.MainDex;
import org.chromium.base.compat.ApiHelperForM;
import org.chromium.build.BuildConfig;

/**
* This class provides Android application context related utility methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import androidx.annotation.VisibleForTesting;

import org.chromium.base.annotations.CheckDiscard;
import org.chromium.build.BuildConfig;

import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package org.chromium.base;

import org.chromium.build.BuildConfig;

/**
* Exposes native library loading status.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import org.chromium.build.BuildConfig;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import androidx.annotation.VisibleForTesting;

import org.chromium.base.BaseSwitches;
import org.chromium.base.BuildConfig;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
import org.chromium.base.JNIUtils;
Expand All @@ -35,6 +34,7 @@
import org.chromium.base.compat.ApiHelperForM;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.UmaRecorderHolder;
import org.chromium.build.BuildConfig;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import android.os.Process;
import android.os.UserHandle;

import org.chromium.base.BuildConfig;
import org.chromium.base.compat.ApiHelperForQ;
import org.chromium.build.BuildConfig;

import java.lang.reflect.Method;
import java.util.concurrent.Executor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import androidx.annotation.VisibleForTesting;

import org.chromium.base.BuildConfig;
import org.chromium.build.BuildConfig;

import java.lang.reflect.Field;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.junit.runner.RunWith;

import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.build.BuildConfig;

/**
* Test that ensures Java asserts are working.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Batch;
import org.chromium.build.BuildConfig;

/**
* Tests for {@link IntentUtils}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import org.chromium.base.BuildConfig;
import org.chromium.base.JniException;
import org.chromium.base.NativeLibraryLoadedStatus;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.MainDex;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.build.BuildConfig;

import java.util.concurrent.TimeoutException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.robolectric.annotation.Config;

import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.build.BuildConfig;

/**
* junit tests for {@link LifetimeAssert}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.chromium.base.task.PostTask;
import org.chromium.base.task.TaskTraits;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.build.BuildConfig;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.chromium.base.ActivityState;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.BuildConfig;
import org.chromium.base.ContextUtils;
import org.chromium.base.FileUtils;
import org.chromium.base.LifetimeAssert;
Expand All @@ -49,6 +48,7 @@
import org.chromium.base.test.util.InMemorySharedPreferences;
import org.chromium.base.test.util.InMemorySharedPreferencesContext;
import org.chromium.base.test.util.ScalableTimeout;
import org.chromium.build.BuildConfig;

import java.io.File;
import java.io.IOException;
Expand Down
10 changes: 10 additions & 0 deletions build/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ if (enable_java_templates) {
min_sdk_version = default_min_sdk_version
}
}

generate_build_config_srcjar("build_config_gen") {
use_final_fields = false
}

java_library("build_config_java") {
supports_android = true
srcjar_deps = [ ":build_config_gen" ]
jar_excluded_patterns = [ "*/build/BuildConfig.class" ]
}
}

python_library("devil_chromium_py") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.base;
package org.chromium.build;

#define Q(x) #x
#define QUOTE(x) Q(x)
Expand Down
11 changes: 6 additions & 5 deletions build/config/android/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ if (enable_java_templates) {
":$_jni_srcjar_target",

# This dep is required for any targets that depend on //base:base_java.
"//base:base_build_config_gen",
"//build/android:build_config_gen",
]
}

Expand Down Expand Up @@ -1901,7 +1901,7 @@ if (enable_java_templates) {
}
}

# Creates org/chromium/base/BuildConfig.java
# Creates org/chromium/build/BuildConfig.java
# This doesn't really belong in //build since it genates a file for //base.
# However, we don't currently have a better way to include this file in all
# apks that depend on //base:base_java.
Expand All @@ -1918,7 +1918,7 @@ if (enable_java_templates) {
template("generate_build_config_srcjar") {
java_cpp_template(target_name) {
forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
sources = [ "//base/android/java/templates/BuildConfig.template" ]
sources = [ "//build/android/java/templates/BuildConfig.template" ]
defines = []

# Set these even when !use_final_fields so that they have correct default
Expand Down Expand Up @@ -2047,7 +2047,7 @@ if (enable_java_templates) {
# the apk for the secondary ABI (optional).
# generate_buildconfig_java: If defined and false, skip generating the
# BuildConfig java class describing the build configuration. The default
# is true for non-test APKs.
# is true when building with Chromium for non-test APKs.
# generate_final_jni: If defined and false, skip generating the
# GEN_JNI srcjar.
# jni_registration_header: If specified, causes the
Expand Down Expand Up @@ -2323,7 +2323,8 @@ if (enable_java_templates) {
_rebased_build_config = rebase_path(_build_config, root_build_dir)
assert(_rebased_build_config != "") # Mark as used.

_generate_buildconfig_java = !defined(invoker.apk_under_test)
_generate_buildconfig_java =
build_with_chromium && !defined(invoker.apk_under_test)
if (defined(invoker.generate_buildconfig_java)) {
_generate_buildconfig_java = invoker.generate_buildconfig_java
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import org.junit.runner.RunWith;

import org.chromium.base.BaseSwitches;
import org.chromium.base.BuildConfig;
import org.chromium.base.Callback;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
Expand All @@ -90,6 +89,7 @@
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.build.BuildConfig;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.compositor.layouts.Layout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import org.chromium.base.BuildConfig;
import org.chromium.build.BuildConfig;
import org.chromium.chrome.browser.tasks.tab_groups.TabGroupUtils;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

import androidx.annotation.UiThread;

import org.chromium.base.BuildConfig;
import org.chromium.base.CommandLine;
import org.chromium.base.JavaExceptionReporter;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.build.BuildConfig;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.version.ChromeVersionInfo;
import org.chromium.components.strictmode.KnownViolations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import dalvik.system.DexFile;

import org.chromium.base.BuildConfig;
import org.chromium.base.BuildInfo;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
Expand All @@ -25,6 +24,7 @@
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.task.PostTask;
import org.chromium.base.task.TaskTraits;
import org.chromium.build.BuildConfig;
import org.chromium.chrome.browser.DeferredStartupHandler;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package org.chromium.chrome.browser.crash;

import org.chromium.base.BuildConfig;
import org.chromium.build.BuildConfig;
import org.chromium.components.version_info.Channel;
import org.chromium.components.version_info.VersionConstants;

Expand Down
Loading

0 comments on commit 87ccf2f

Please sign in to comment.