From bfb2362cded1cd92c917c611391e54697082fb2a Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Wed, 22 Feb 2023 10:42:15 -0800 Subject: [PATCH] Only apply apex transition to DCLA libs for now. Bug: 270339610 Test: mixed_droid.sh Change-Id: I6a8b7fdefeb504a25256e92647de9b487d5b65a3 --- android/bazel_handler.go | 16 +++++++++++++++- cc/cc.go | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/android/bazel_handler.go b/android/bazel_handler.go index 3a459f181..e7ff08f72 100644 --- a/android/bazel_handler.go +++ b/android/bazel_handler.go @@ -201,6 +201,8 @@ type BazelContext interface { // (for example, that it is MixedBuildBuildable). IsModuleNameAllowed(moduleName string, withinApex bool) bool + IsModuleDclaAllowed(moduleName string) bool + // Returns the bazel output base (the root directory for all bazel intermediate outputs). OutputBase() string @@ -341,6 +343,10 @@ func (m MockBazelContext) IsModuleNameAllowed(_ string, _ bool) bool { return true } +func (m MockBazelContext) IsModuleDclaAllowed(_ string) bool { + return true +} + func (m MockBazelContext) OutputBase() string { return m.OutputBaseDir } func (m MockBazelContext) BuildStatementsToRegister() []*bazel.BuildStatement { @@ -483,6 +489,10 @@ func (n noopBazelContext) IsModuleNameAllowed(_ string, _ bool) bool { return false } +func (n noopBazelContext) IsModuleDclaAllowed(_ string) bool { + return false +} + func (m noopBazelContext) BuildStatementsToRegister() []*bazel.BuildStatement { return []*bazel.BuildStatement{} } @@ -619,13 +629,17 @@ func (context *mixedBuildBazelContext) IsModuleNameAllowed(moduleName string, wi if context.bazelEnabledModules[moduleName] { return true } - if withinApex && context.bazelDclaEnabledModules[moduleName] { + if withinApex && context.IsModuleDclaAllowed(moduleName) { return true } return context.modulesDefaultToBazel } +func (context *mixedBuildBazelContext) IsModuleDclaAllowed(moduleName string) bool { + return context.bazelDclaEnabledModules[moduleName] +} + func pwdPrefix() string { // Darwin doesn't have /proc if runtime.GOOS != "darwin" { diff --git a/cc/cc.go b/cc/cc.go index 5bb13ffff..c07d836a6 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -1920,6 +1920,9 @@ func isUbsanEnabled(c *Module) bool { func GetApexConfigKey(ctx android.BaseModuleContext) *android.ApexConfigKey { apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo) if !apexInfo.IsForPlatform() { + if !ctx.Config().BazelContext.IsModuleDclaAllowed(ctx.Module().Name()) { + return nil + } apexKey := android.ApexConfigKey{ WithinApex: true, ApexSdkVersion: findApexSdkVersion(ctx, apexInfo).String(),