Skip to content

Commit

Permalink
Automated rollback of commit b93f828.
Browse files Browse the repository at this point in the history
*** 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
  • Loading branch information
ted-xie authored and Copybara-Service committed Apr 19, 2022
1 parent 16c4076 commit a603c23
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 113 deletions.
20 changes: 1 addition & 19 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -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")

Expand Down Expand Up @@ -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",
],
},
)

Expand Down Expand Up @@ -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",
],
},
)

Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
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(
name = "android_tools",
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",
)
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public ImmutableList<String> 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();

Expand All @@ -67,7 +66,6 @@ public ImmutableList<String> 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')",
Expand All @@ -87,7 +85,6 @@ public ImmutableList<String> getWorkspaceContents(MockToolsConfig config) {
@Override
public ImmutableList<String> getWorkspaceRepos() {
return ImmutableList.of(
"android_gmaven_r8",
"bazel_tools",
"com_google_protobuf",
"local_config_platform",
Expand Down Expand Up @@ -231,9 +228,6 @@ public void setupMockClient(MockToolsConfig config, List<String> workspaceConten
ImmutableList<String> 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));
Expand Down Expand Up @@ -274,11 +268,6 @@ public void setupMockClient(MockToolsConfig config, List<String> 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);

Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
61 changes: 0 additions & 61 deletions src/test/shell/bazel/android/android_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
<resources>
<string name="app_name">HelloWorld</string>
<string name="title_activity_main">Hello Main</string>
</resources>
EOF

cat > java/com/example/hello/AndroidManifest.xml <<'EOF'
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="18" />
<application android:label="@string/app_name">
<activity
android:name="com.example.hello.MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
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
Expand Down
1 change: 0 additions & 1 deletion src/test/shell/testenv.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ EOF

repos=(
"android_tools_for_testing"
"android_gmaven_r8_for_testing"
"bazel_skylib"
"bazel_toolchains"
"com_google_protobuf"
Expand Down
10 changes: 4 additions & 6 deletions tools/android/android_sdk_repository_template.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit a603c23

Please sign in to comment.