Merge "Allow platform_bootclasspath to specify contributing fragments" am: 49ab1d38de
am: 75e90d6974
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1670067 Change-Id: Ib3304ee0007baf2518219472703407186e0bb95a
This commit is contained in:
@@ -127,10 +127,28 @@ func TestPlatformBootclasspathDependencies(t *testing.T) {
|
|||||||
|
|
||||||
platform_bootclasspath {
|
platform_bootclasspath {
|
||||||
name: "myplatform-bootclasspath",
|
name: "myplatform-bootclasspath",
|
||||||
|
|
||||||
|
fragments: [
|
||||||
|
{
|
||||||
|
apex: "com.android.art",
|
||||||
|
module: "art-bootclasspath-fragment",
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
java.CheckPlatformBootclasspathModules(t, result, "myplatform-bootclasspath", []string{
|
||||||
|
"com.android.art:baz",
|
||||||
|
"com.android.art:quuz",
|
||||||
|
"platform:foo",
|
||||||
|
"myapex:bar",
|
||||||
|
})
|
||||||
|
|
||||||
|
java.CheckPlatformBootclasspathFragments(t, result, "myplatform-bootclasspath", []string{
|
||||||
|
`com.android.art:art-bootclasspath-fragment`,
|
||||||
|
})
|
||||||
|
|
||||||
// Make sure that the myplatform-bootclasspath has the correct dependencies.
|
// Make sure that the myplatform-bootclasspath has the correct dependencies.
|
||||||
CheckModuleDependencies(t, result.TestContext, "myplatform-bootclasspath", "android_common", []string{
|
CheckModuleDependencies(t, result.TestContext, "myplatform-bootclasspath", "android_common", []string{
|
||||||
`platform:dex2oatd`,
|
`platform:dex2oatd`,
|
||||||
@@ -138,6 +156,7 @@ func TestPlatformBootclasspathDependencies(t *testing.T) {
|
|||||||
`com.android.art:quuz`,
|
`com.android.art:quuz`,
|
||||||
`platform:foo`,
|
`platform:foo`,
|
||||||
`myapex:bar`,
|
`myapex:bar`,
|
||||||
|
`com.android.art:art-bootclasspath-fragment`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ import (
|
|||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/dexpreopt"
|
"android/soong/dexpreopt"
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -49,19 +50,49 @@ func (t platformBootclasspathDependencyTag) ExcludeFromVisibilityEnforcement() {
|
|||||||
// The tag used for the dependency between the platform bootclasspath and any configured boot jars.
|
// The tag used for the dependency between the platform bootclasspath and any configured boot jars.
|
||||||
var platformBootclasspathModuleDepTag = platformBootclasspathDependencyTag{name: "module"}
|
var platformBootclasspathModuleDepTag = platformBootclasspathDependencyTag{name: "module"}
|
||||||
|
|
||||||
|
// The tag used for the dependency between the platform bootclasspath and bootclasspath_fragments.
|
||||||
|
var platformBootclasspathFragmentDepTag = platformBootclasspathDependencyTag{name: "fragment"}
|
||||||
|
|
||||||
var _ android.ExcludeFromVisibilityEnforcementTag = platformBootclasspathDependencyTag{}
|
var _ android.ExcludeFromVisibilityEnforcementTag = platformBootclasspathDependencyTag{}
|
||||||
|
|
||||||
type platformBootclasspathModule struct {
|
type platformBootclasspathModule struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
|
|
||||||
|
properties platformBootclasspathProperties
|
||||||
|
|
||||||
// The apex:module pairs obtained from the configured modules.
|
// The apex:module pairs obtained from the configured modules.
|
||||||
//
|
//
|
||||||
// Currently only for testing.
|
// Currently only for testing.
|
||||||
configuredModules []android.Module
|
configuredModules []android.Module
|
||||||
|
|
||||||
|
// The apex:module pairs obtained from the fragments.
|
||||||
|
//
|
||||||
|
// Currently only for testing.
|
||||||
|
fragments []android.Module
|
||||||
|
}
|
||||||
|
|
||||||
|
// ApexVariantReference specifies a particular apex variant of a module.
|
||||||
|
type ApexVariantReference struct {
|
||||||
|
// The name of the module apex variant, i.e. the apex containing the module variant.
|
||||||
|
//
|
||||||
|
// If this is not specified then it defaults to "platform" which will cause a dependency to be
|
||||||
|
// added to the module's platform variant.
|
||||||
|
Apex *string
|
||||||
|
|
||||||
|
// The name of the module.
|
||||||
|
Module *string
|
||||||
|
}
|
||||||
|
|
||||||
|
type platformBootclasspathProperties struct {
|
||||||
|
|
||||||
|
// The names of the bootclasspath_fragment modules that form part of this
|
||||||
|
// platform_bootclasspath.
|
||||||
|
Fragments []ApexVariantReference
|
||||||
}
|
}
|
||||||
|
|
||||||
func platformBootclasspathFactory() android.Module {
|
func platformBootclasspathFactory() android.Module {
|
||||||
m := &platformBootclasspathModule{}
|
m := &platformBootclasspathModule{}
|
||||||
|
m.AddProperties(&m.properties)
|
||||||
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
|
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
@@ -91,6 +122,23 @@ func platformBootclasspathDepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
// Add dependencies on all the updatable modules.
|
// Add dependencies on all the updatable modules.
|
||||||
updatableModules := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars
|
updatableModules := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars
|
||||||
addDependenciesOntoBootImageModules(ctx, updatableModules)
|
addDependenciesOntoBootImageModules(ctx, updatableModules)
|
||||||
|
|
||||||
|
// Add dependencies on all the fragments.
|
||||||
|
addDependencyOntoApexVariants(ctx, "fragments", p.properties.Fragments, platformBootclasspathFragmentDepTag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func addDependencyOntoApexVariants(ctx android.BottomUpMutatorContext, propertyName string, refs []ApexVariantReference, tag blueprint.DependencyTag) {
|
||||||
|
for i, ref := range refs {
|
||||||
|
apex := proptools.StringDefault(ref.Apex, "platform")
|
||||||
|
|
||||||
|
if ref.Module == nil {
|
||||||
|
ctx.PropertyErrorf(propertyName, "missing module name at position %d", i)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
name := proptools.String(ref.Module)
|
||||||
|
|
||||||
|
addDependencyOntoApexModulePair(ctx, apex, name, tag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +186,8 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo
|
|||||||
tag := ctx.OtherModuleDependencyTag(module)
|
tag := ctx.OtherModuleDependencyTag(module)
|
||||||
if tag == platformBootclasspathModuleDepTag {
|
if tag == platformBootclasspathModuleDepTag {
|
||||||
b.configuredModules = append(b.configuredModules, module)
|
b.configuredModules = append(b.configuredModules, module)
|
||||||
|
} else if tag == platformBootclasspathFragmentDepTag {
|
||||||
|
b.fragments = append(b.fragments, module)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -331,6 +331,15 @@ func apexNamePairFromModule(ctx *android.TestContext, module android.Module) str
|
|||||||
return fmt.Sprintf("%s:%s", apex, name)
|
return fmt.Sprintf("%s:%s", apex, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckPlatformBootclasspathFragments returns the apex:module pair for the fragments depended upon
|
||||||
|
// by the platform-bootclasspath module.
|
||||||
|
func CheckPlatformBootclasspathFragments(t *testing.T, result *android.TestResult, name string, expected []string) {
|
||||||
|
t.Helper()
|
||||||
|
platformBootclasspath := result.Module(name, "android_common").(*platformBootclasspathModule)
|
||||||
|
pairs := ApexNamePairsFromModules(result.TestContext, platformBootclasspath.fragments)
|
||||||
|
android.AssertDeepEquals(t, fmt.Sprintf("%s fragments", "platform-bootclasspath"), expected, pairs)
|
||||||
|
}
|
||||||
|
|
||||||
func CheckHiddenAPIRuleInputs(t *testing.T, expected string, hiddenAPIRule android.TestingBuildParams) {
|
func CheckHiddenAPIRuleInputs(t *testing.T, expected string, hiddenAPIRule android.TestingBuildParams) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
actual := strings.TrimSpace(strings.Join(android.NormalizePathsForTesting(hiddenAPIRule.Implicits), "\n"))
|
actual := strings.TrimSpace(strings.Join(android.NormalizePathsForTesting(hiddenAPIRule.Implicits), "\n"))
|
||||||
|
Reference in New Issue
Block a user