summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/bazel_handler.go18
-rw-r--r--cmd/soong_build/main.go18
-rw-r--r--ui/build/soong.go1
3 files changed, 30 insertions, 7 deletions
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index e81086d7d..308827c11 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -172,12 +172,13 @@ type bazelRunner interface {
}
type bazelPaths struct {
- homeDir string
- bazelPath string
- outputBase string
- workspaceDir string
- soongOutDir string
- metricsDir string
+ homeDir string
+ bazelPath string
+ outputBase string
+ workspaceDir string
+ soongOutDir string
+ metricsDir string
+ bazelDepsFile string
}
// A context object which tracks queued requests that need to be made to Bazel,
@@ -424,6 +425,11 @@ func bazelPathsFromConfig(c *config) (*bazelPaths, error) {
} else {
missingEnvVars = append(missingEnvVars, "BAZEL_METRICS_DIR")
}
+ if len(c.Getenv("BAZEL_DEPS_FILE")) > 1 {
+ p.bazelDepsFile = c.Getenv("BAZEL_DEPS_FILE")
+ } else {
+ missingEnvVars = append(missingEnvVars, "BAZEL_DEPS_FILE")
+ }
if len(missingEnvVars) > 0 {
return nil, errors.New(fmt.Sprintf("missing required env vars to use bazel: %s", missingEnvVars))
} else {
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 9f00fc338..0ba25c884 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -167,10 +167,15 @@ func runMixedModeBuild(configuration android.Config, ctx *android.Context, extra
return configuration.BazelContext.InvokeBazel(configuration)
}
ctx.SetBeforePrepareBuildActionsHook(bazelHook)
-
ninjaDeps := bootstrap.RunBlueprint(cmdlineArgs, bootstrap.DoEverything, ctx.Context, configuration)
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
+ bazelPaths, err := readBazelPaths(configuration)
+ if err != nil {
+ panic("Bazel deps file not found: " + err.Error())
+ }
+ ninjaDeps = append(ninjaDeps, bazelPaths...)
+
globListFiles := writeBuildGlobsNinjaFile(ctx, configuration.SoongOutDir(), configuration)
ninjaDeps = append(ninjaDeps, globListFiles...)
@@ -699,3 +704,14 @@ func writeBp2BuildMetrics(codegenMetrics *bp2build.CodegenMetrics,
}
codegenMetrics.Write(metricsDir)
}
+
+func readBazelPaths(configuration android.Config) ([]string, error) {
+ depsPath := configuration.Getenv("BAZEL_DEPS_FILE")
+
+ data, err := os.ReadFile(depsPath)
+ if err != nil {
+ return nil, err
+ }
+ paths := strings.Split(strings.TrimSpace(string(data)), "\n")
+ return paths, nil
+}
diff --git a/ui/build/soong.go b/ui/build/soong.go
index e0d67cc84..28c6ec937 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -404,6 +404,7 @@ func runSoong(ctx Context, config Config) {
soongBuildEnv.Set("BAZEL_WORKSPACE", absPath(ctx, "."))
soongBuildEnv.Set("BAZEL_METRICS_DIR", config.BazelMetricsDir())
soongBuildEnv.Set("LOG_DIR", config.LogsDir())
+ soongBuildEnv.Set("BAZEL_DEPS_FILE", filepath.Join(os.Getenv("TOP"), config.OutDir(), "tools", "bazel.list"))
// For Soong bootstrapping tests
if os.Getenv("ALLOW_MISSING_DEPENDENCIES") == "true" {