Stop java_sdk_library_import from depending on source modules am: 44f1d8404b
am: ad18b5c676
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1351595 Change-Id: I98193c398be14e639aae36983ce3cb30c81a7b6e
This commit is contained in:
@@ -228,6 +228,16 @@ type Module interface {
|
|||||||
// For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go
|
// For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go
|
||||||
GenerateAndroidBuildActions(ModuleContext)
|
GenerateAndroidBuildActions(ModuleContext)
|
||||||
|
|
||||||
|
// Add dependencies to the components of a module, i.e. modules that are created
|
||||||
|
// by the module and which are considered to be part of the creating module.
|
||||||
|
//
|
||||||
|
// This is called before prebuilts are renamed so as to allow a dependency to be
|
||||||
|
// added directly to a prebuilt child module instead of depending on a source module
|
||||||
|
// and relying on prebuilt processing to switch to the prebuilt module if preferred.
|
||||||
|
//
|
||||||
|
// A dependency on a prebuilt must include the "prebuilt_" prefix.
|
||||||
|
ComponentDepsMutator(ctx BottomUpMutatorContext)
|
||||||
|
|
||||||
DepsMutator(BottomUpMutatorContext)
|
DepsMutator(BottomUpMutatorContext)
|
||||||
|
|
||||||
base() *ModuleBase
|
base() *ModuleBase
|
||||||
@@ -770,6 +780,8 @@ type ModuleBase struct {
|
|||||||
prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
|
prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ModuleBase) ComponentDepsMutator(BottomUpMutatorContext) {}
|
||||||
|
|
||||||
func (m *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
|
func (m *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
|
||||||
|
|
||||||
func (m *ModuleBase) AddProperties(props ...interface{}) {
|
func (m *ModuleBase) AddProperties(props ...interface{}) {
|
||||||
|
@@ -115,6 +115,18 @@ var preArch = []RegisterMutatorFunc{
|
|||||||
// a DefaultableHook.
|
// a DefaultableHook.
|
||||||
RegisterDefaultsPreArchMutators,
|
RegisterDefaultsPreArchMutators,
|
||||||
|
|
||||||
|
// Add dependencies on any components so that any component references can be
|
||||||
|
// resolved within the deps mutator.
|
||||||
|
//
|
||||||
|
// Must be run after defaults so it can be used to create dependencies on the
|
||||||
|
// component modules that are creating in a DefaultableHook.
|
||||||
|
//
|
||||||
|
// Must be run before RegisterPrebuiltsPreArchMutators, i.e. before prebuilts are
|
||||||
|
// renamed. That is so that if a module creates components using a prebuilt module
|
||||||
|
// type that any dependencies (which must use prebuilt_ prefixes) are resolved to
|
||||||
|
// the prebuilt module and not the source module.
|
||||||
|
RegisterComponentsMutator,
|
||||||
|
|
||||||
// Create an association between prebuilt modules and their corresponding source
|
// Create an association between prebuilt modules and their corresponding source
|
||||||
// modules (if any).
|
// modules (if any).
|
||||||
//
|
//
|
||||||
@@ -252,8 +264,21 @@ func (mutator *mutator) Parallel() MutatorHandle {
|
|||||||
return mutator
|
return mutator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RegisterComponentsMutator(ctx RegisterMutatorsContext) {
|
||||||
|
ctx.BottomUp("component-deps", componentDepsMutator).Parallel()
|
||||||
|
}
|
||||||
|
|
||||||
|
// A special mutator that runs just prior to the deps mutator to allow the dependencies
|
||||||
|
// on component modules to be added so that they can depend directly on a prebuilt
|
||||||
|
// module.
|
||||||
|
func componentDepsMutator(ctx BottomUpMutatorContext) {
|
||||||
|
if m := ctx.Module(); m.Enabled() {
|
||||||
|
m.ComponentDepsMutator(ctx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func depsMutator(ctx BottomUpMutatorContext) {
|
func depsMutator(ctx BottomUpMutatorContext) {
|
||||||
if m, ok := ctx.Module().(Module); ok && m.Enabled() {
|
if m := ctx.Module(); m.Enabled() {
|
||||||
m.DepsMutator(ctx)
|
m.DepsMutator(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -233,6 +233,7 @@ func testApexContext(_ *testing.T, bp string, handlers ...testCustomizer) (*andr
|
|||||||
ctx.RegisterModuleType("apex_set", apexSetFactory)
|
ctx.RegisterModuleType("apex_set", apexSetFactory)
|
||||||
|
|
||||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||||
|
ctx.PreArchMutators(android.RegisterComponentsMutator)
|
||||||
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
|
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
|
||||||
|
|
||||||
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
||||||
|
@@ -86,6 +86,7 @@ func testContext() *android.TestContext {
|
|||||||
RegisterStubsBuildComponents(ctx)
|
RegisterStubsBuildComponents(ctx)
|
||||||
RegisterSdkLibraryBuildComponents(ctx)
|
RegisterSdkLibraryBuildComponents(ctx)
|
||||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||||
|
ctx.PreArchMutators(android.RegisterComponentsMutator)
|
||||||
|
|
||||||
RegisterPrebuiltApisBuildComponents(ctx)
|
RegisterPrebuiltApisBuildComponents(ctx)
|
||||||
|
|
||||||
@@ -684,11 +685,11 @@ func TestJavaSdkLibraryImport_WithSource(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
checkModuleDependencies(t, ctx, "prebuilt_sdklib", "android_common", []string{
|
checkModuleDependencies(t, ctx, "prebuilt_sdklib", "android_common", []string{
|
||||||
|
`prebuilt_sdklib.stubs`,
|
||||||
`sdklib.impl`,
|
`sdklib.impl`,
|
||||||
// This should be prebuilt_sdklib.stubs but is set to sdklib.stubs because the
|
// This should be prebuilt_sdklib.stubs but is set to sdklib.stubs because the
|
||||||
// dependency is added after prebuilts may have been renamed and so has to use
|
// dependency is added after prebuilts may have been renamed and so has to use
|
||||||
// the renamed name.
|
// the renamed name.
|
||||||
`sdklib.stubs`,
|
|
||||||
`sdklib.xml`,
|
`sdklib.xml`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -976,7 +976,8 @@ func IsXmlPermissionsFileDepTag(depTag blueprint.DependencyTag) bool {
|
|||||||
|
|
||||||
var implLibraryTag = sdkLibraryComponentTag{name: "impl-library"}
|
var implLibraryTag = sdkLibraryComponentTag{name: "impl-library"}
|
||||||
|
|
||||||
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
// Add the dependencies on the child modules in the component deps mutator.
|
||||||
|
func (module *SdkLibrary) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
for _, apiScope := range module.getGeneratedApiScopes(ctx) {
|
for _, apiScope := range module.getGeneratedApiScopes(ctx) {
|
||||||
// Add dependencies to the stubs library
|
// Add dependencies to the stubs library
|
||||||
ctx.AddVariationDependencies(nil, apiScope.stubsTag, module.stubsLibraryModuleName(apiScope))
|
ctx.AddVariationDependencies(nil, apiScope.stubsTag, module.stubsLibraryModuleName(apiScope))
|
||||||
@@ -1001,7 +1002,12 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
// Add dependency to the rule for generating the xml permissions file
|
// Add dependency to the rule for generating the xml permissions file
|
||||||
ctx.AddDependency(module, xmlPermissionsFileTag, module.xmlPermissionsModuleName())
|
ctx.AddDependency(module, xmlPermissionsFileTag, module.xmlPermissionsModuleName())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add other dependencies as normal.
|
||||||
|
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
|
if module.requiresRuntimeImplementationLibrary() {
|
||||||
// Only add the deps for the library if it is actually going to be built.
|
// Only add the deps for the library if it is actually going to be built.
|
||||||
module.Library.deps(ctx)
|
module.Library.deps(ctx)
|
||||||
}
|
}
|
||||||
@@ -1884,20 +1890,26 @@ func (module *SdkLibraryImport) createPrebuiltStubsSources(mctx android.Defaulta
|
|||||||
props.Prefer = proptools.BoolPtr(module.prebuilt.Prefer())
|
props.Prefer = proptools.BoolPtr(module.prebuilt.Prefer())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {
|
// Add the dependencies on the child module in the component deps mutator so that it
|
||||||
|
// creates references to the prebuilt and not the source modules.
|
||||||
|
func (module *SdkLibraryImport) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
for apiScope, scopeProperties := range module.scopeProperties {
|
for apiScope, scopeProperties := range module.scopeProperties {
|
||||||
if len(scopeProperties.Jars) == 0 {
|
if len(scopeProperties.Jars) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add dependencies to the prebuilt stubs library
|
// Add dependencies to the prebuilt stubs library
|
||||||
ctx.AddVariationDependencies(nil, apiScope.stubsTag, module.stubsLibraryModuleName(apiScope))
|
ctx.AddVariationDependencies(nil, apiScope.stubsTag, "prebuilt_"+module.stubsLibraryModuleName(apiScope))
|
||||||
|
|
||||||
if len(scopeProperties.Stub_srcs) > 0 {
|
if len(scopeProperties.Stub_srcs) > 0 {
|
||||||
// Add dependencies to the prebuilt stubs source library
|
// Add dependencies to the prebuilt stubs source library
|
||||||
ctx.AddVariationDependencies(nil, apiScope.stubsSourceTag, module.stubsSourceModuleName(apiScope))
|
ctx.AddVariationDependencies(nil, apiScope.stubsSourceTag, "prebuilt_"+module.stubsSourceModuleName(apiScope))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add other dependencies as normal.
|
||||||
|
func (module *SdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
|
|
||||||
implName := module.implLibraryModuleName()
|
implName := module.implLibraryModuleName()
|
||||||
if ctx.OtherModuleExists(implName) {
|
if ctx.OtherModuleExists(implName) {
|
||||||
|
@@ -84,6 +84,7 @@ func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, andr
|
|||||||
android.RegisterPackageBuildComponents(ctx)
|
android.RegisterPackageBuildComponents(ctx)
|
||||||
ctx.PreArchMutators(android.RegisterVisibilityRuleChecker)
|
ctx.PreArchMutators(android.RegisterVisibilityRuleChecker)
|
||||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||||
|
ctx.PreArchMutators(android.RegisterComponentsMutator)
|
||||||
ctx.PreArchMutators(android.RegisterVisibilityRuleGatherer)
|
ctx.PreArchMutators(android.RegisterVisibilityRuleGatherer)
|
||||||
ctx.PostDepsMutators(android.RegisterVisibilityRuleEnforcer)
|
ctx.PostDepsMutators(android.RegisterVisibilityRuleEnforcer)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user