Merge "apex_set is force disabled when necessary" am: f70ceecc4c
am: 005a5724ca
am: 615d01cae9
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1364697 Change-Id: I2fbfb75e05beffc6b79ff7760e5982ad8d2f6c05
This commit is contained in:
commit
bd13ffdc35
2 changed files with 65 additions and 45 deletions
|
@ -2207,7 +2207,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
case android.PrebuiltDepTag:
|
||||
// If the prebuilt is force disabled, remember to delete the prebuilt file
|
||||
// that might have been installed in the previous builds
|
||||
if prebuilt, ok := child.(*Prebuilt); ok && prebuilt.isForceDisabled() {
|
||||
if prebuilt, ok := child.(prebuilt); ok && prebuilt.isForceDisabled() {
|
||||
a.prebuiltFileToDelete = prebuilt.InstallFilename()
|
||||
}
|
||||
}
|
||||
|
|
108
apex/prebuilt.go
108
apex/prebuilt.go
|
@ -40,9 +40,55 @@ var (
|
|||
"abis", "allow-prereleased", "sdk-version")
|
||||
)
|
||||
|
||||
type prebuilt interface {
|
||||
isForceDisabled() bool
|
||||
InstallFilename() string
|
||||
}
|
||||
|
||||
type prebuiltCommon struct {
|
||||
prebuilt android.Prebuilt
|
||||
properties prebuiltCommonProperties
|
||||
}
|
||||
|
||||
type prebuiltCommonProperties struct {
|
||||
ForceDisable bool `blueprint:"mutated"`
|
||||
}
|
||||
|
||||
func (p *prebuiltCommon) Prebuilt() *android.Prebuilt {
|
||||
return &p.prebuilt
|
||||
}
|
||||
|
||||
func (p *prebuiltCommon) isForceDisabled() bool {
|
||||
return p.properties.ForceDisable
|
||||
}
|
||||
|
||||
func (p *prebuiltCommon) checkForceDisable(ctx android.ModuleContext) bool {
|
||||
// If the device is configured to use flattened APEX, force disable the prebuilt because
|
||||
// the prebuilt is a non-flattened one.
|
||||
forceDisable := ctx.Config().FlattenApex()
|
||||
|
||||
// Force disable the prebuilts when we are doing unbundled build. We do unbundled build
|
||||
// to build the prebuilts themselves.
|
||||
forceDisable = forceDisable || ctx.Config().UnbundledBuild()
|
||||
|
||||
// Force disable the prebuilts when coverage is enabled.
|
||||
forceDisable = forceDisable || ctx.DeviceConfig().NativeCoverageEnabled()
|
||||
forceDisable = forceDisable || ctx.Config().IsEnvTrue("EMMA_INSTRUMENT")
|
||||
|
||||
// b/137216042 don't use prebuilts when address sanitizer is on
|
||||
forceDisable = forceDisable || android.InList("address", ctx.Config().SanitizeDevice()) ||
|
||||
android.InList("hwaddress", ctx.Config().SanitizeDevice())
|
||||
|
||||
if forceDisable && p.prebuilt.SourceExists() {
|
||||
p.properties.ForceDisable = true
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type Prebuilt struct {
|
||||
android.ModuleBase
|
||||
prebuilt android.Prebuilt
|
||||
prebuiltCommon
|
||||
|
||||
properties PrebuiltProperties
|
||||
|
||||
|
@ -58,8 +104,7 @@ type Prebuilt struct {
|
|||
|
||||
type PrebuiltProperties struct {
|
||||
// the path to the prebuilt .apex file to import.
|
||||
Source string `blueprint:"mutated"`
|
||||
ForceDisable bool `blueprint:"mutated"`
|
||||
Source string `blueprint:"mutated"`
|
||||
|
||||
Src *string
|
||||
Arch struct {
|
||||
|
@ -94,10 +139,6 @@ func (p *Prebuilt) installable() bool {
|
|||
return p.properties.Installable == nil || proptools.Bool(p.properties.Installable)
|
||||
}
|
||||
|
||||
func (p *Prebuilt) isForceDisabled() bool {
|
||||
return p.properties.ForceDisable
|
||||
}
|
||||
|
||||
func (p *Prebuilt) OutputFiles(tag string) (android.Paths, error) {
|
||||
switch tag {
|
||||
case "":
|
||||
|
@ -111,12 +152,8 @@ func (p *Prebuilt) InstallFilename() string {
|
|||
return proptools.StringDefault(p.properties.Filename, p.BaseModuleName()+imageApexSuffix)
|
||||
}
|
||||
|
||||
func (p *Prebuilt) Prebuilt() *android.Prebuilt {
|
||||
return &p.prebuilt
|
||||
}
|
||||
|
||||
func (p *Prebuilt) Name() string {
|
||||
return p.prebuilt.Name(p.ModuleBase.Name())
|
||||
return p.prebuiltCommon.prebuilt.Name(p.ModuleBase.Name())
|
||||
}
|
||||
|
||||
// prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex.
|
||||
|
@ -129,27 +166,6 @@ func PrebuiltFactory() android.Module {
|
|||
}
|
||||
|
||||
func (p *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
// If the device is configured to use flattened APEX, force disable the prebuilt because
|
||||
// the prebuilt is a non-flattened one.
|
||||
forceDisable := ctx.Config().FlattenApex()
|
||||
|
||||
// Force disable the prebuilts when we are doing unbundled build. We do unbundled build
|
||||
// to build the prebuilts themselves.
|
||||
forceDisable = forceDisable || ctx.Config().UnbundledBuild()
|
||||
|
||||
// Force disable the prebuilts when coverage is enabled.
|
||||
forceDisable = forceDisable || ctx.DeviceConfig().NativeCoverageEnabled()
|
||||
forceDisable = forceDisable || ctx.Config().IsEnvTrue("EMMA_INSTRUMENT")
|
||||
|
||||
// b/137216042 don't use prebuilts when address sanitizer is on
|
||||
forceDisable = forceDisable || android.InList("address", ctx.Config().SanitizeDevice()) ||
|
||||
android.InList("hwaddress", ctx.Config().SanitizeDevice())
|
||||
|
||||
if forceDisable && p.prebuilt.SourceExists() {
|
||||
p.properties.ForceDisable = true
|
||||
return
|
||||
}
|
||||
|
||||
// This is called before prebuilt_select and prebuilt_postdeps mutators
|
||||
// The mutators requires that src to be set correctly for each arch so that
|
||||
// arch variants are disabled when src is not provided for the arch.
|
||||
|
@ -178,10 +194,6 @@ func (p *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||
}
|
||||
|
||||
func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
if p.properties.ForceDisable {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO(jungjw): Check the key validity.
|
||||
p.inputApex = p.Prebuilt().SingleSourcePath(ctx)
|
||||
p.installDir = android.PathForModuleInstall(ctx, "apex")
|
||||
|
@ -195,6 +207,12 @@ func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
Input: p.inputApex,
|
||||
Output: p.outputApex,
|
||||
})
|
||||
|
||||
if p.prebuiltCommon.checkForceDisable(ctx) {
|
||||
p.SkipInstall()
|
||||
return
|
||||
}
|
||||
|
||||
if p.installable() {
|
||||
ctx.InstallFile(p.installDir, p.installFilename, p.inputApex)
|
||||
}
|
||||
|
@ -228,7 +246,7 @@ func (p *Prebuilt) AndroidMkEntries() []android.AndroidMkEntries {
|
|||
|
||||
type ApexSet struct {
|
||||
android.ModuleBase
|
||||
prebuilt android.Prebuilt
|
||||
prebuiltCommon
|
||||
|
||||
properties ApexSetProperties
|
||||
|
||||
|
@ -274,12 +292,8 @@ func (a *ApexSet) InstallFilename() string {
|
|||
return proptools.StringDefault(a.properties.Filename, a.BaseModuleName()+imageApexSuffix)
|
||||
}
|
||||
|
||||
func (a *ApexSet) Prebuilt() *android.Prebuilt {
|
||||
return &a.prebuilt
|
||||
}
|
||||
|
||||
func (a *ApexSet) Name() string {
|
||||
return a.prebuilt.Name(a.ModuleBase.Name())
|
||||
return a.prebuiltCommon.prebuilt.Name(a.ModuleBase.Name())
|
||||
}
|
||||
|
||||
func (a *ApexSet) Overrides() []string {
|
||||
|
@ -301,7 +315,7 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
ctx.ModuleErrorf("filename should end in %s for apex_set", imageApexSuffix)
|
||||
}
|
||||
|
||||
apexSet := a.prebuilt.SingleSourcePath(ctx)
|
||||
apexSet := a.prebuiltCommon.prebuilt.SingleSourcePath(ctx)
|
||||
a.outputApex = android.PathForModuleOut(ctx, a.installFilename)
|
||||
ctx.Build(pctx,
|
||||
android.BuildParams{
|
||||
|
@ -315,6 +329,12 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
"sdk-version": ctx.Config().PlatformSdkVersion(),
|
||||
},
|
||||
})
|
||||
|
||||
if a.prebuiltCommon.checkForceDisable(ctx) {
|
||||
a.SkipInstall()
|
||||
return
|
||||
}
|
||||
|
||||
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
||||
if a.installable() {
|
||||
ctx.InstallFile(a.installDir, a.installFilename, a.outputApex)
|
||||
|
|
Loading…
Reference in a new issue