3921f0b356
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
65 lines
2.2 KiB
Go
65 lines
2.2 KiB
Go
// Copyright 2018 Google Inc. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package java
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"android/soong/android"
|
|
)
|
|
|
|
func JavaGenLibTestFactory() android.Module {
|
|
callbacks := &JavaGenLibTestCallbacks{}
|
|
return GeneratedJavaLibraryModuleFactory("test_java_gen_lib", callbacks, &callbacks.properties)
|
|
}
|
|
|
|
type JavaGenLibTestProperties struct {
|
|
Foo string
|
|
}
|
|
|
|
type JavaGenLibTestCallbacks struct {
|
|
properties JavaGenLibTestProperties
|
|
}
|
|
|
|
func (callbacks *JavaGenLibTestCallbacks) DepsMutator(module *GeneratedJavaLibraryModule, ctx android.BottomUpMutatorContext) {
|
|
}
|
|
|
|
func (callbacks *JavaGenLibTestCallbacks) GenerateSourceJarBuildActions(module *GeneratedJavaLibraryModule, ctx android.ModuleContext) (android.Path, android.Path) {
|
|
return android.PathForOutput(ctx, "blah.srcjar"), android.PathForOutput(ctx, "blah.pb")
|
|
}
|
|
|
|
func testGenLib(t *testing.T, errorHandler android.FixtureErrorHandler, bp string) *android.TestResult {
|
|
return android.GroupFixturePreparers(
|
|
PrepareForIntegrationTestWithJava,
|
|
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
|
|
ctx.RegisterModuleType("test_java_gen_lib", JavaGenLibTestFactory)
|
|
}),
|
|
).
|
|
ExtendWithErrorHandler(errorHandler).
|
|
RunTestWithBp(t, bp)
|
|
}
|
|
|
|
func TestGenLib(t *testing.T) {
|
|
bp := `
|
|
test_java_gen_lib {
|
|
name: "javagenlibtest",
|
|
foo: "bar", // Note: This won't parse if the property didn't get added
|
|
}
|
|
`
|
|
result := testGenLib(t, android.FixtureExpectsNoErrors, bp)
|
|
|
|
javagenlibtest := result.ModuleForTests("javagenlibtest", "android_common").Module().(*GeneratedJavaLibraryModule)
|
|
android.AssertPathsEndWith(t, "Generated_srcjars", []string{"/blah.srcjar"}, javagenlibtest.Library.properties.Generated_srcjars)
|
|
}
|