From a603c2382ffcc49f344eee73dfcd65aa2332f64f Mon Sep 17 00:00:00 2001 From: tedx Date: Tue, 19 Apr 2022 12:04:07 -0700 Subject: [PATCH] Automated rollback of commit b93f828133e74cb3589ba7ffcfe74d2fe72430cd. *** Reason for rollback *** Breaks a subset of //src/test/java/com/google/devtools/build/android/r8:AllTests. See b/229725674 *** Original change description *** Switch to using the d8 jar from maven.google.com instead of the jar from the Android SDK. Also fixes #13989 RELNOTES: Bazel uses the D8 jar from Maven instead of the SDK. PiperOrigin-RevId: 442875035 --- WORKSPACE | 20 +----- src/BUILD | 1 - .../android/android_remote_tools.WORKSPACE | 9 +-- .../lib/analysis/mock/BazelAnalysisMock.java | 14 ----- .../packages/BazelPackageLoaderTest.java | 3 - .../bazel/android/android_integration_test.sh | 61 ------------------- src/test/shell/testenv.sh.tmpl | 1 - .../android_sdk_repository_template.bzl | 10 ++- 8 files changed, 6 insertions(+), 113 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index bde40256ee148f..be90748f1ce8b7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,6 +1,6 @@ workspace(name = "io_bazel") -load("//tools/build_defs/repo:http.bzl", "http_archive", "http_file", "http_jar") +load("//tools/build_defs/repo:http.bzl", "http_archive", "http_file") load("//:distdir.bzl", "dist_http_archive", "dist_http_file", "distdir_tar") load("//:distdir_deps.bzl", "DIST_DEPS") @@ -119,22 +119,16 @@ distdir_tar( # Keep in sync with the archives fetched as part of building bazel. archives = [ "android_tools_pkg-0.23.0.tar.gz", - # for android_gmaven_r8 - "r8-3.3.28.jar", ], dirname = "derived/distdir", dist_deps = {dep: attrs for dep, attrs in DIST_DEPS.items() if "additional_distfiles" in attrs["used_in"]}, sha256 = { "android_tools_pkg-0.23.0.tar.gz": "ed5290594244c2eeab41f0104519bcef51e27c699ff4b379fcbd25215270513e", - "r8-3.3.28.jar": "8626ca32fb47aba7fddd2c897615e2e8ffcdb4d4b213572a2aefb3f838f01972", }, urls = { "android_tools_pkg-0.23.0.tar.gz": [ "https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.23.0.tar.gz", ], - "r8-3.3.28.jar": [ - "https://maven.google.com/com/android/tools/r8/3.3.28/r8-3.3.28.jar", - ], }, ) @@ -352,21 +346,16 @@ distdir_tar( name = "test_WORKSPACE_files", archives = [ "android_tools_pkg-0.23.0.tar.gz", - "r8-3.3.28.jar", ], dirname = "test_WORKSPACE/distdir", dist_deps = {dep: attrs for dep, attrs in DIST_DEPS.items() if "test_WORKSPACE_files" in attrs["used_in"]}, sha256 = { "android_tools_pkg-0.23.0.tar.gz": "ed5290594244c2eeab41f0104519bcef51e27c699ff4b379fcbd25215270513e", - "r8-3.3.28.jar": "8626ca32fb47aba7fddd2c897615e2e8ffcdb4d4b213572a2aefb3f838f01972", }, urls = { "android_tools_pkg-0.23.0.tar.gz": [ "https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.23.0.tar.gz", ], - "r8-3.3.28.jar": [ - "https://maven.google.com/com/android/tools/r8/3.3.28/r8-3.3.28.jar", - ], }, ) @@ -408,13 +397,6 @@ http_archive( url = "https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.23.0.tar.gz", ) -# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_remote_tools.WORKSPACE -http_jar( - name = "android_gmaven_r8_for_testing", - sha256 = "8626ca32fb47aba7fddd2c897615e2e8ffcdb4d4b213572a2aefb3f838f01972", - url = "https://maven.google.com/com/android/tools/r8/3.3.28/r8-3.3.28.jar", -) - dist_http_archive( name = "remote_coverage_tools", patch_cmds = EXPORT_WORKSPACE_IN_BUILD_FILE, diff --git a/src/BUILD b/src/BUILD index 2fa0cc5f7f7d76..99835599bba582 100644 --- a/src/BUILD +++ b/src/BUILD @@ -646,7 +646,6 @@ release_archive( filegroup( name = "test_repos", srcs = [ - "@android_gmaven_r8_for_testing//jar:file", "@android_tools_for_testing//:WORKSPACE", "@bazel_skylib//:WORKSPACE", "@com_google_protobuf//:WORKSPACE", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_remote_tools.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_remote_tools.WORKSPACE index c5fcf94fee340f..5f3972b6beaec6 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_remote_tools.WORKSPACE +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_remote_tools.WORKSPACE @@ -1,4 +1,4 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_jar") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # This must be kept in sync with the top-level WORKSPACE file. http_archive( @@ -6,10 +6,3 @@ http_archive( sha256 = "ed5290594244c2eeab41f0104519bcef51e27c699ff4b379fcbd25215270513e", url = "https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.23.0.tar.gz", ) - -# This must be kept in sync with the top-level WORKSPACE file. -http_jar( - name = "android_gmaven_r8", - sha256 = "8626ca32fb47aba7fddd2c897615e2e8ffcdb4d4b213572a2aefb3f838f01972", - url = "https://maven.google.com/com/android/tools/r8/3.3.28/r8-3.3.28.jar", -) diff --git a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java index 6b5d0d57517c62..e9df17e390de80 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java @@ -57,7 +57,6 @@ public ImmutableList getWorkspaceContents(MockToolsConfig config) { String bazelToolWorkspace = config.getPath("embedded_tools").getPathString(); String bazelPlatformsWorkspace = config.getPath("platforms_workspace").getPathString(); String rulesJavaWorkspace = config.getPath("rules_java_workspace").getPathString(); - String androidGmavenR8Workspace = config.getPath("android_gmaven_r8").getPathString(); String localConfigPlatformWorkspace = config.getPath("local_config_platform_workspace").getPathString(); @@ -67,7 +66,6 @@ public ImmutableList getWorkspaceContents(MockToolsConfig config) { "local_repository(name = 'local_config_xcode', path = '" + xcodeWorkspace + "')", "local_repository(name = 'com_google_protobuf', path = '" + protobufWorkspace + "')", "local_repository(name = 'rules_java', path = '" + rulesJavaWorkspace + "')", - "local_repository(name = 'android_gmaven_r8', path = '" + androidGmavenR8Workspace + "')", "register_toolchains('@rules_java//java/toolchains/runtime:all')", "register_toolchains('@rules_java//java/toolchains/javac:all')", "bind(name = 'android/sdk', actual='@bazel_tools//tools/android:sdk')", @@ -87,7 +85,6 @@ public ImmutableList getWorkspaceContents(MockToolsConfig config) { @Override public ImmutableList getWorkspaceRepos() { return ImmutableList.of( - "android_gmaven_r8", "bazel_tools", "com_google_protobuf", "local_config_platform", @@ -231,9 +228,6 @@ public void setupMockClient(MockToolsConfig config, List workspaceConten ImmutableList androidBuildContents = createAndroidBuildContents(); config.create( "embedded_tools/tools/android/BUILD", androidBuildContents.toArray(new String[0])); - config.create( - "embedded_tools/src/tools/android/java/com/google/devtools/build/android/r8/BUILD", - "java_library(name='r8')\n"); config.create( "embedded_tools/tools/android/emulator/BUILD", Iterables.toArray(createToolsAndroidEmulatorContents(), String.class)); @@ -274,11 +268,6 @@ public void setupMockClient(MockToolsConfig config, List workspaceConten " zipalign = ':empty_binary',", " tags = ['__ANDROID_RULES_MIGRATION__'],", ")"); - config.create( - "android_gmaven_r8/jar/BUILD", - "java_import(name = 'jar', jars=['r8.jar'])", - "filegroup(name = 'file', srcs=[])"); - config.create("android_gmaven_r8/WORKSPACE"); MockGenruleSupport.setup(config); @@ -511,9 +500,6 @@ public void setupMockToolsRepository(MockToolsConfig config) throws IOException " pass", "", "def http_file(**kwargs):", - " pass", - "", - "def http_jar(**kwargs):", " pass"); config.create( "embedded_tools/tools/jdk/local_java_repository.bzl", diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/packages/BazelPackageLoaderTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/packages/BazelPackageLoaderTest.java index 2236c2934caf17..1059d3025cd443 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/packages/BazelPackageLoaderTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/packages/BazelPackageLoaderTest.java @@ -86,9 +86,6 @@ private static void mockEmbeddedTools(Path embeddedBinaries) throws IOException " pass", "", "def http_file(**kwargs):", - " pass", - "", - "def http_jar(**kwargs):", " pass"); FileSystemUtils.writeIsoLatin1( tools.getRelative("tools/build_defs/repo/utils.bzl"), diff --git a/src/test/shell/bazel/android/android_integration_test.sh b/src/test/shell/bazel/android/android_integration_test.sh index 60de0cee1a9355..d7d9db06db4374 100755 --- a/src/test/shell/bazel/android/android_integration_test.sh +++ b/src/test/shell/bazel/android/android_integration_test.sh @@ -84,67 +84,6 @@ EOF assert_build //java/bazel/multidex:bin } -function write_hello_android_files() { - mkdir -p java/com/example/hello - mkdir -p java/com/example/hello/res/values - cat > java/com/example/hello/res/values/strings.xml <<'EOF' - - HelloWorld - Hello Main - -EOF - - cat > java/com/example/hello/AndroidManifest.xml <<'EOF' - - - - - - - - - - - - - -EOF - - cat > java/com/example/hello/MainActivity.java <<'EOF' -package com.example.hello; - -import android.app.Activity; - -public class MainActivity extends Activity { -} -EOF - -} - -function test_d8_compiles_hello_android() { - write_hello_android_files - setup_android_sdk_support - cat > java/com/example/hello/BUILD <<'EOF' -android_binary( - name = 'hello', - manifest = "AndroidManifest.xml", - srcs = ['MainActivity.java'], - resource_files = glob(["res/**"]), -) -EOF - - bazel clean - bazel build --define=android_standalone_dexing_tool=d8_compat_dx \ - //java/com/example/hello:hello || fail "build failed" -} - function test_android_tools_version() { create_new_workspace setup_android_sdk_support diff --git a/src/test/shell/testenv.sh.tmpl b/src/test/shell/testenv.sh.tmpl index c78bec45b8937b..e80f10a589ff5f 100755 --- a/src/test/shell/testenv.sh.tmpl +++ b/src/test/shell/testenv.sh.tmpl @@ -282,7 +282,6 @@ EOF repos=( "android_tools_for_testing" - "android_gmaven_r8_for_testing" "bazel_skylib" "bazel_toolchains" "com_google_protobuf" diff --git a/tools/android/android_sdk_repository_template.bzl b/tools/android/android_sdk_repository_template.bzl index 833b54c09eaca0..170d97ab0532eb 100644 --- a/tools/android/android_sdk_repository_template.bzl +++ b/tools/android/android_sdk_repository_template.bzl @@ -298,14 +298,12 @@ def create_android_sdk_rules( ) java_binary( name = "d8_compat_dx", - main_class = "com.google.devtools.build.android.r8.CompatDx", - runtime_deps = [ - "@bazel_tools//src/tools/android/java/com/google/devtools/build/android/r8:r8", - ], + main_class = "com.android.tools.r8.compatdx.CompatDx", + runtime_deps = [":d8_jar_import"], ) - native.alias( + java_import( name = "d8_jar_import", - actual = "@android_gmaven_r8//jar", + jars = ["build-tools/%s/lib/d8.jar" % build_tools_directory], ) TAGDIR_TO_TAG_MAP = {