From 9154718303462596455221fda1034fb13f844b86 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 12 Nov 2019 19:39:36 +0000 Subject: Adds droidstubs support to sdk module Adds stubs_sources property to sdk and unzips the droidstubs srcjar into the snapshot directory. Adds an UnzipToSnapshot method to the SnapshotBuilder which creates a rule that uses zip2zip to repackage the supplied zip content into a temporary zip file that matches what the required snapshot structure. e.g. if the supplied zip contains foo/Foo.java and that needs to be in the snapshot directory java/foo/stubs then it will create a zip that contains java/foo/stubs/foo/Foo.java. The temporary zip that is the output of that rule is added to the zipsToMerge field for merging later. If the zipsToMerge is empty then the snapshot zip is created as before. Otherwise, a temporary zip file is created. That is then merged with the other zip files in zipsToMerge to create the final snapshot zip. Adds prebuilt_stubs_sources for use by the generated .bp module. Bug: 143678475 Test: added conscrypt sdk module and attempted to build it Change-Id: Ie274263af3a08e36a73c61c0dbf0c341fd6967e2 --- java/java_test.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'java/java_test.go') diff --git a/java/java_test.go b/java/java_test.go index 0f7e6dee8..71aba3ab1 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -89,6 +89,7 @@ func testContext(bp string, fs map[string][]byte) *android.TestContext { ctx.RegisterModuleType("droiddoc", android.ModuleFactoryAdaptor(DroiddocFactory)) ctx.RegisterModuleType("droiddoc_host", android.ModuleFactoryAdaptor(DroiddocHostFactory)) ctx.RegisterModuleType("droiddoc_template", android.ModuleFactoryAdaptor(ExportedDroiddocDirFactory)) + ctx.RegisterModuleType("prebuilt_stubs_sources", android.ModuleFactoryAdaptor(PrebuiltStubsSourcesFactory)) ctx.RegisterModuleType("java_sdk_library", android.ModuleFactoryAdaptor(SdkLibraryFactory)) ctx.RegisterModuleType("java_sdk_library_import", android.ModuleFactoryAdaptor(sdkLibraryImportFactory)) ctx.RegisterModuleType("override_android_app", android.ModuleFactoryAdaptor(OverrideAndroidAppModuleFactory)) @@ -207,6 +208,9 @@ func testContext(bp string, fs map[string][]byte) *android.TestContext { "cert/new_cert.pk8": nil, "testdata/data": nil, + + "stubs-sources/foo/Foo.java": nil, + "stubs/sources/foo/Foo.java": nil, } for k, v := range fs { @@ -415,7 +419,7 @@ func TestPrebuilts(t *testing.T) { ctx, _ := testJava(t, ` java_library { name: "foo", - srcs: ["a.java"], + srcs: ["a.java", ":stubs-source"], libs: ["bar", "sdklib"], static_libs: ["baz"], } @@ -439,6 +443,11 @@ func TestPrebuilts(t *testing.T) { name: "sdklib", jars: ["b.jar"], } + + prebuilt_stubs_sources { + name: "stubs-source", + srcs: ["stubs/sources/**/*.java"], + } `) javac := ctx.ModuleForTests("foo", "android_common").Rule("javac") @@ -447,6 +456,19 @@ func TestPrebuilts(t *testing.T) { bazJar := ctx.ModuleForTests("baz", "android_common").Rule("combineJar").Output sdklibStubsJar := ctx.ModuleForTests("sdklib.stubs", "android_common").Rule("combineJar").Output + inputs := []string{} + for _, p := range javac.BuildParams.Inputs { + inputs = append(inputs, p.String()) + } + + expected := []string{ + "a.java", + "stubs/sources/foo/Foo.java", + } + if !reflect.DeepEqual(expected, inputs) { + t.Errorf("foo inputs incorrect: expected %q, found %q", expected, inputs) + } + if !strings.Contains(javac.Args["classpath"], barJar.String()) { t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], barJar.String()) } -- cgit v1.2.3-59-g8ed1b