aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-07-22 22:12:44 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-07-22 22:12:44 +0000
commit02d76b9cd64d752d7a8cdd74afaad55db0d67040 (patch)
treee7c0cc2209fe0c13dccac37a6ab88be30969ac4f
parent0ce5d89d5730c1cb7075e6be6c5f97f0ebeff877 (diff)
parentd771592f830ef3d7ef62fb4f8fbc252ee43a951c (diff)
downloadbuild_soong-02d76b9cd64d752d7a8cdd74afaad55db0d67040.tar.gz
build_soong-02d76b9cd64d752d7a8cdd74afaad55db0d67040.tar.bz2
build_soong-02d76b9cd64d752d7a8cdd74afaad55db0d67040.zip
Change-Id: I131b23ebe4f88331ec4992fcc27ece8a0a064851
-rw-r--r--apex/apex.go2
-rw-r--r--apex/prebuilt.go108
2 files changed, 65 insertions, 45 deletions
diff --git a/apex/apex.go b/apex/apex.go
index f9c9b87f..b4fae341 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2112,7 +2112,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()
}
}
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 794799ee..37457e92 100644
--- a/apex/prebuilt.go
+++ b/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)