From fb6ae5bc73ecaf00e5b2be1ed9640bdd1f21c22e Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 30 Sep 2020 15:17:25 +0100 Subject: [PATCH] Add support for using sdk_version: "module_" Fixes a panic when trying to build something with sdk_version: "module_30". Test: m nothing Change-Id: I9b2ce50957f59e2bead335ffa58888e15cda1f78 --- java/java_test.go | 13 +++++++++++++ java/sdk.go | 2 +- java/testing.go | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/java/java_test.go b/java/java_test.go index 9e6357792..f16639aa8 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -1487,6 +1487,12 @@ func TestJavaSdkLibrary(t *testing.T) { libs: ["foo"], sdk_version: "system_29", } + java_library { + name: "baz-module-30", + srcs: ["c.java"], + libs: ["foo"], + sdk_version: "module_30", + } `) // check the existence of the internal modules @@ -1533,6 +1539,13 @@ func TestJavaSdkLibrary(t *testing.T) { "prebuilts/sdk/29/system/foo.jar") } + bazModule30Javac := ctx.ModuleForTests("baz-module-30", "android_common").Rule("javac") + // tests if "baz-module-30" is actually linked to the module 30 stubs lib + if !strings.Contains(bazModule30Javac.Args["classpath"], "prebuilts/sdk/30/module-lib/foo.jar") { + t.Errorf("baz-module-30 javac classpath %v does not contain %q", bazModule30Javac.Args["classpath"], + "prebuilts/sdk/30/module-lib/foo.jar") + } + // test if baz has exported SDK lib names foo and bar to qux qux := ctx.ModuleForTests("qux", "android_common") if quxLib, ok := qux.Module().(*Library); ok { diff --git a/java/sdk.go b/java/sdk.go index f59926502..971791f4a 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -222,7 +222,7 @@ func (s sdkSpec) usePrebuilt(ctx android.EarlyModuleContext) bool { return ctx.Config().AlwaysUsePrebuiltSdks() } else if s.version.isNumbered() { // validation check - if s.kind != sdkPublic && s.kind != sdkSystem && s.kind != sdkTest { + if s.kind != sdkPublic && s.kind != sdkSystem && s.kind != sdkTest && s.kind != sdkModule { panic(fmt.Errorf("prebuilt SDK is not not available for sdkKind=%q", s.kind)) return false } diff --git a/java/testing.go b/java/testing.go index a47241323..461fd3f9f 100644 --- a/java/testing.go +++ b/java/testing.go @@ -55,6 +55,8 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string "prebuilts/sdk/30/public/framework.aidl": nil, "prebuilts/sdk/30/system/android.jar": nil, "prebuilts/sdk/30/system/foo.jar": nil, + "prebuilts/sdk/30/module-lib/android.jar": nil, + "prebuilts/sdk/30/module-lib/foo.jar": nil, "prebuilts/sdk/30/public/core-for-system-modules.jar": nil, "prebuilts/sdk/current/core/android.jar": nil, "prebuilts/sdk/current/public/android.jar": nil,