Collect aconfig_declarations of the dependent java_aconfig_library modules
droidstubs module require aconfig_declarations modules to be specified when the module depends on the java_aconfig_library module in order to generate the "exportable" stubs. This adds burden to the droidstubs or java_sdk_library module owners, as module should specify both the java_aconfig_library and aconfig_declarations modules to genreate the "exportable" stubs, although the necessary information from the aconfig_declarations module can be provided from the java_aconfig_library modules. In order to resolve such burden, this change enables the intermediate cache files from the associated aconfig_declarations module of a java_aconfig_library module to be propagated to its reverse dependencies without having the specify the aconfig_declarations modules in the droidstubs or java_sdk_library modules definitions. This does not mean that the intermediate cache files of every transitive dependencies of the java_sdk_library or the droidstubs will be passed to aconfig to retrieve the state of the aconfig flags. Specifically, only the java_aconfig_library modules or the java_library modules that have static dependency on java_aconfig_library modules that are passed to droidstubs via `libs` or `srcs` (using ":module_name{.tag}" syntax) will provide the intermediate cache files to generate the "exportable" stubs. For java_sdk_library, all modules listed as `libs`, `static_libs`, `stub_only_libs`, and `apiScope.libs` are passed as `libs` and all modules listed as `api_srcs` and `srcs` are passed as `srcs` to the droidstubs modules dynamically generated in java_sdk_library module per api scope, thus these properties will be affected. Note that the test is being added in the apex package. This is because trying to register the codegen package build components in the java package leads to circular dependency between the codegen and the java package, as codegen package imports the java package. Test: m nothing --no-skip-soong-tests Bug: 329284345 Change-Id: I7953ab64776f6947808321ce8a3598154501bcfe
This commit is contained in:
@@ -11930,3 +11930,121 @@ func TestInstallationRulesForMultipleApexPrebuilts(t *testing.T) {
|
||||
checkHideFromMake(t, ctx, tc.expectedVisibleModuleName, tc.expectedHiddenModuleNames)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAconfifDeclarationsValidation(t *testing.T) {
|
||||
aconfigDeclarationLibraryString := func(moduleNames []string) (ret string) {
|
||||
for _, moduleName := range moduleNames {
|
||||
ret += fmt.Sprintf(`
|
||||
aconfig_declarations {
|
||||
name: "%[1]s",
|
||||
package: "com.example.package",
|
||||
srcs: [
|
||||
"%[1]s.aconfig",
|
||||
],
|
||||
}
|
||||
java_aconfig_library {
|
||||
name: "%[1]s-lib",
|
||||
aconfig_declarations: "%[1]s",
|
||||
}
|
||||
`, moduleName)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForApexTest,
|
||||
java.PrepareForTestWithJavaSdkLibraryFiles,
|
||||
java.FixtureWithLastReleaseApis("foo"),
|
||||
android.FixtureModifyConfig(func(config android.Config) {
|
||||
config.SetApiLibraries([]string{"foo"})
|
||||
}),
|
||||
).RunTestWithBp(t, `
|
||||
java_library {
|
||||
name: "baz-java-lib",
|
||||
static_libs: [
|
||||
"baz-lib",
|
||||
],
|
||||
}
|
||||
filegroup {
|
||||
name: "qux-filegroup",
|
||||
srcs: [
|
||||
":qux-lib{.generated_srcjars}",
|
||||
],
|
||||
}
|
||||
filegroup {
|
||||
name: "qux-another-filegroup",
|
||||
srcs: [
|
||||
":qux-filegroup",
|
||||
],
|
||||
}
|
||||
java_library {
|
||||
name: "quux-java-lib",
|
||||
srcs: [
|
||||
"a.java",
|
||||
],
|
||||
libs: [
|
||||
"quux-lib",
|
||||
],
|
||||
}
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: [
|
||||
":qux-another-filegroup",
|
||||
],
|
||||
api_packages: ["foo"],
|
||||
system: {
|
||||
enabled: true,
|
||||
},
|
||||
module_lib: {
|
||||
enabled: true,
|
||||
},
|
||||
test: {
|
||||
enabled: true,
|
||||
},
|
||||
static_libs: [
|
||||
"bar-lib",
|
||||
],
|
||||
libs: [
|
||||
"baz-java-lib",
|
||||
"quux-java-lib",
|
||||
],
|
||||
aconfig_declarations: [
|
||||
"bar",
|
||||
],
|
||||
}
|
||||
`+aconfigDeclarationLibraryString([]string{"bar", "baz", "qux", "quux"}))
|
||||
|
||||
m := result.ModuleForTests("foo.stubs.source", "android_common")
|
||||
outDir := "out/soong/.intermediates"
|
||||
|
||||
// Arguments passed to aconfig to retrieve the state of the flags defined in the
|
||||
// textproto files
|
||||
aconfigFlagArgs := m.Output("released-flagged-apis-exportable.txt").Args["flags_path"]
|
||||
|
||||
// "bar-lib" is a static_lib of "foo" and is passed to metalava as classpath. Thus the
|
||||
// cache file provided by the associated aconfig_declarations module "bar" should be passed
|
||||
// to aconfig.
|
||||
android.AssertStringDoesContain(t, "cache file of a java_aconfig_library static_lib "+
|
||||
"passed as an input",
|
||||
aconfigFlagArgs, fmt.Sprintf("%s/%s/intermediate.pb", outDir, "bar"))
|
||||
|
||||
// "baz-java-lib", which statically depends on "baz-lib", is a lib of "foo" and is passed
|
||||
// to metalava as classpath. Thus the cache file provided by the associated
|
||||
// aconfig_declarations module "baz" should be passed to aconfig.
|
||||
android.AssertStringDoesContain(t, "cache file of a lib that statically depends on "+
|
||||
"java_aconfig_library passed as an input",
|
||||
aconfigFlagArgs, fmt.Sprintf("%s/%s/intermediate.pb", outDir, "baz"))
|
||||
|
||||
// "qux-lib" is passed to metalava as src via the filegroup, thus the cache file provided by
|
||||
// the associated aconfig_declarations module "qux" should be passed to aconfig.
|
||||
android.AssertStringDoesContain(t, "cache file of srcs java_aconfig_library passed as an "+
|
||||
"input",
|
||||
aconfigFlagArgs, fmt.Sprintf("%s/%s/intermediate.pb", outDir, "qux"))
|
||||
|
||||
// "quux-java-lib" is a lib of "foo" and is passed to metalava as classpath, but does not
|
||||
// statically depend on "quux-lib". Therefore, the cache file provided by the associated
|
||||
// aconfig_declarations module "quux" should not be passed to aconfig.
|
||||
android.AssertStringDoesNotContain(t, "cache file of a lib that does not statically "+
|
||||
"depend on java_aconfig_library not passed as an input",
|
||||
aconfigFlagArgs, fmt.Sprintf("%s/%s/intermediate.pb", outDir, "quux"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user