Merge "Create sanitizer variants of APEX only when SANITIZE_TARGET is set"
diff --git a/apex/apex.go b/apex/apex.go
index 46c9dcf..321e2e8 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -483,9 +483,17 @@
}
}
-func (a *apexBundle) IsSanitizerEnabled() bool {
- // APEX can be mutated for sanitizers
- return true
+func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
+ globalSanitizerNames := []string{}
+ if a.Host() {
+ globalSanitizerNames = ctx.Config().SanitizeHost()
+ } else {
+ arches := ctx.Config().SanitizeDeviceArch()
+ if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
+ globalSanitizerNames = ctx.Config().SanitizeDevice()
+ }
+ }
+ return android.InList(sanitizerName, globalSanitizerNames)
}
func getCopyManifestForNativeLibrary(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 90656da..b95e2a8 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -820,7 +820,7 @@
type Sanitizeable interface {
android.Module
- IsSanitizerEnabled() bool
+ IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool
}
// Create sanitized variants for modules that need them
@@ -924,7 +924,7 @@
}
}
c.sanitize.Properties.SanitizeDep = false
- } else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok && sanitizeable.IsSanitizerEnabled() {
+ } else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok && sanitizeable.IsSanitizerEnabled(mctx, t.String()) {
// APEX modules fall here
mctx.CreateVariations(t.String())
}