Add the ability for a java_sdk_library to depend on another.
This simply exports all of the uses_libs: [] libraries into a "dependency=''" statement in the generated XML file (with the <library> stanza in it). Test: `go test` in java/ Bug: 184396657 NOTE FOR REVIEWERS - original patch and result patch are not identical. PLEASE REVIEW CAREFULLY. Diffs between the patches: func formattedDependenciesAttribute(dependencies []string) string { > + if dependencies == nil { > + return "" > + } > + return fmt.Sprintf(` dependency=\"%s\"\n`, strings.Join(dependencies, ":")) > +} > + > + dependenciesAttr := formattedDependenciesAttribute(module.properties.Uses_libs_dependencies) > + dependenciesAttr, > --- java/sdk_library_test.go > +++ java/sdk_library_test.go > + > +func TestSdkLibraryDependency(t *testing.T) { > + result := android.GroupFixturePreparers( > + prepareForJavaTest, > + PrepareForTestWithJavaSdkLibraryFiles, > + FixtureWithPrebuiltApis(map[string][]string{ > + "30": {"bar", "foo"}, > + }), > + ).RunTestWithBp(t, > + ` > + java_sdk_library { > + name: "foo", > + srcs: ["a.java", "b.java"], > + api_packages: ["foo"], > + } > + > + java_sdk_library { > + name: "bar", > + srcs: ["c.java", "b.java"], > + libs: [ > + "foo", > + ], > + uses_libs: [ > + "foo", > + ], > + } > +`) > + > + barPermissions := result.ModuleForTests("bar.xml", "android_common").Rule("java_sdk_xml") > + > + android.AssertStringDoesContain(t, "bar.xml java_sdk_xml command", barPermissions.RuleParams.Command, `dependency=\"foo\"`) > +} Original patch: diff --git a/java/sdk_library.go b/java/sdk_library.go old mode 100644 new mode 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1993,6 +1993,7 @@ Min_device_sdk *string Max_device_sdk *string Sdk_library_min_api_level *string + Uses_libs_dependencies []string }{ Name: proptools.StringPtr(module.xmlPermissionsModuleName()), Lib_name: proptools.StringPtr(module.BaseModuleName()), @@ -2002,6 +2003,7 @@ Min_device_sdk: module.commonSdkLibraryProperties.Min_device_sdk, Max_device_sdk: module.commonSdkLibraryProperties.Max_device_sdk, Sdk_library_min_api_level: &moduleMinApiLevelStr, + Uses_libs_dependencies: module.usesLibraryProperties.Uses_libs, } mctx.CreateModule(sdkLibraryXmlFactory, &props) @@ -2968,6 +2970,11 @@ // // This value comes from the ApiLevel of the MinSdkVersion property. Sdk_library_min_api_level *string + + // Uses-libs dependencies that the shared libra [[[Original patch trimmed due to size. Decoded string size: 3559. Decoded string SHA1: 67fbd040aa818732a686514c4556850c8c36dc8d.]]] Result patch: diff --git a/java/sdk_library.go b/java/sdk_library.go index fb27812..fbfe509 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1993,6 +1993,7 @@ Min_device_sdk *string Max_device_sdk *string Sdk_library_min_api_level *string + Uses_libs_dependencies []string }{ Name: proptools.StringPtr(module.xmlPermissionsModuleName()), Lib_name: proptools.StringPtr(module.BaseModuleName()), @@ -2002,6 +2003,7 @@ Min_device_sdk: module.commonSdkLibraryProperties.Min_device_sdk, Max_device_sdk: module.commonSdkLibraryProperties.Max_device_sdk, Sdk_library_min_api_level: &moduleMinApiLevelStr, + Uses_libs_dependencies: module.usesLibraryProperties.Uses_libs, } mctx.CreateModule(sdkLibraryXmlFactory, &props) @@ -2968,6 +2970,11 @@ // // This value comes from the ApiLevel of the MinSdkVersion property. Sdk_library_min_api_level *string + + // Uses-libs dependencies that the shared library [[[Result patch trimmed due to size. Decoded string size: 3614. Decoded string SHA1: b5730ecbeeaad420439ddb67eaaa9150ede94585.]]] Change-Id: I73f69e2a4573e416492f68e083fe739f3f75b721
Loading
Please register or sign in to comment