Add bazel paths to ninja deps.
Test: m nothing Test: m nothing --bazel-mode-dev Change-Id: I120e62ac3f2aa066aedaecf2a5d16c79f7097c76
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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" {
|
||||
|
Reference in New Issue
Block a user