Merge changes I67589bcc,Ibcfae390

* changes:
  Replace boot image with bootclasspath fragment in sdk package
  bootclasspath_fragment must only depend on source contents
This commit is contained in:
Paul Duffin
2021-04-22 14:02:43 +00:00
committed by Gerrit Code Review
5 changed files with 69 additions and 29 deletions

View File

@@ -53,7 +53,7 @@ func RegisterBootImageBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("prebuilt_bootclasspath_fragment", prebuiltBootImageFactory)
}
type bootImageContentDependencyTag struct {
type bootclasspathFragmentContentDependencyTag struct {
blueprint.BaseDependencyTag
}
@@ -62,16 +62,22 @@ type bootImageContentDependencyTag struct {
// This is a temporary workaround to make it easier to migrate to boot image modules with proper
// dependencies.
// TODO(b/177892522): Remove this and add needed visibility.
func (b bootImageContentDependencyTag) ExcludeFromVisibilityEnforcement() {
func (b bootclasspathFragmentContentDependencyTag) ExcludeFromVisibilityEnforcement() {
}
// The bootclasspath_fragment contents must never depend on prebuilts.
func (b bootclasspathFragmentContentDependencyTag) ReplaceSourceWithPrebuilt() bool {
return false
}
// The tag used for the dependency between the boot image module and its contents.
var bootImageContentDepTag = bootImageContentDependencyTag{}
var bootclasspathFragmentContentDepTag = bootclasspathFragmentContentDependencyTag{}
var _ android.ExcludeFromVisibilityEnforcementTag = bootImageContentDepTag
var _ android.ExcludeFromVisibilityEnforcementTag = bootclasspathFragmentContentDepTag
var _ android.ReplaceSourceWithPrebuilt = bootclasspathFragmentContentDepTag
func IsbootImageContentDepTag(tag blueprint.DependencyTag) bool {
return tag == bootImageContentDepTag
func IsBootclasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool {
return tag == bootclasspathFragmentContentDepTag
}
type bootImageProperties struct {
@@ -187,7 +193,7 @@ func (i BootImageInfo) AndroidBootImageFilesByArchType() map[android.ArchType]an
func (b *BootImageModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
tag := ctx.OtherModuleDependencyTag(dep)
if tag == bootImageContentDepTag {
if IsBootclasspathFragmentContentDepTag(tag) {
// Boot image contents are automatically added to apex.
return true
}
@@ -202,8 +208,26 @@ func (b *BootImageModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
return nil
}
// ComponentDepsMutator adds dependencies onto modules before any prebuilt modules without a
// corresponding source module are renamed. This means that adding a dependency using a name without
// a prebuilt_ prefix will always resolve to a source module and when using a name with that prefix
// it will always resolve to a prebuilt module.
func (b *BootImageModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
module := ctx.Module()
_, isSourceModule := module.(*BootImageModule)
for _, name := range b.properties.Contents {
// A bootclasspath_fragment must depend only on other source modules, while the
// prebuilt_bootclasspath_fragment must only depend on other prebuilt modules.
if !isSourceModule {
name = android.PrebuiltNameFromSource(name)
}
ctx.AddDependency(module, bootclasspathFragmentContentDepTag, name)
}
}
func (b *BootImageModule) DepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddDependency(ctx.Module(), bootImageContentDepTag, b.properties.Contents...)
if SkipDexpreoptBootJars(ctx) {
return