summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/bazel.go3
-rw-r--r--android/config.go12
-rw-r--r--android/test_config.go1
3 files changed, 15 insertions, 1 deletions
diff --git a/android/bazel.go b/android/bazel.go
index 60989f64d..3731dfee1 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -383,6 +383,9 @@ func MixedBuildsEnabled(ctx BaseModuleContext) bool {
// mixedBuildPossible returns true if a module is ready to be replaced by a
// converted or handcrafted Bazel target.
func mixedBuildPossible(ctx BaseModuleContext) bool {
+ if !ctx.Config().IsMixedBuildsEnabled() {
+ return false
+ }
if ctx.Os() == Windows {
// Windows toolchains are not currently supported.
return false
diff --git a/android/config.go b/android/config.go
index 1deb7d4ae..52a8f13f8 100644
--- a/android/config.go
+++ b/android/config.go
@@ -536,7 +536,17 @@ func (c *config) mockFileSystem(bp string, fs map[string][]byte) {
// Returns true if "Bazel builds" is enabled. In this mode, part of build
// analysis is handled by Bazel.
func (c *config) IsMixedBuildsEnabled() bool {
- return c.BuildMode == BazelProdMode || c.BuildMode == BazelDevMode || c.BuildMode == BazelStagingMode
+ globalMixedBuildsSupport := c.Once(OnceKey{"globalMixedBuildsSupport"}, func() interface{} {
+ if c.productVariables.DeviceArch != nil && *c.productVariables.DeviceArch == "riscv64" {
+ fmt.Fprintln(os.Stderr, "unsupported device arch 'riscv64' for Bazel: falling back to non-mixed build")
+ return false
+ }
+ // TODO(b/253664931): Add other fallback criteria below.
+ return true
+ }).(bool)
+
+ bazelModeEnabled := c.BuildMode == BazelProdMode || c.BuildMode == BazelDevMode || c.BuildMode == BazelStagingMode
+ return globalMixedBuildsSupport && bazelModeEnabled
}
func (c *config) SetAllowMissingDependencies() {
diff --git a/android/test_config.go b/android/test_config.go
index de546c42f..70c319a59 100644
--- a/android/test_config.go
+++ b/android/test_config.go
@@ -62,6 +62,7 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
TestAllowNonExistentPaths: true,
BazelContext: noopBazelContext{},
+ BuildMode: BazelProdMode,
mixedBuildDisabledModules: make(map[string]struct{}),
mixedBuildEnabledModules: make(map[string]struct{}),
}