Remove the dependency on a number of env vars.
This is so that the way soong_build is invoked is simpler, which is in turn useful so that it can be invoked multiple times within a single build, which in turn will be used to invoke bp2build routinely (as opposed to manually when needed) Test: Presubmits. Change-Id: Iddaebb05ff7bcedc0db8273192bb31284b739920
This commit is contained in:
@@ -75,8 +75,8 @@ func newContext(configuration android.Config, prepareBuildActions bool) *android
|
|||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConfig(srcDir string) android.Config {
|
func newConfig(srcDir, outDir string) android.Config {
|
||||||
configuration, err := android.NewConfig(srcDir, bootstrap.CmdlineBuildDir(), bootstrap.CmdlineModuleListFile())
|
configuration, err := android.NewConfig(srcDir, outDir, bootstrap.CmdlineModuleListFile())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%s", err)
|
fmt.Fprintf(os.Stderr, "%s", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -127,7 +127,7 @@ func runSoongDocs(configuration android.Config, extraNinjaDeps []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func writeMetrics(configuration android.Config) {
|
func writeMetrics(configuration android.Config) {
|
||||||
metricsFile := filepath.Join(bootstrap.CmdlineBuildDir(), "soong_build_metrics.pb")
|
metricsFile := filepath.Join(configuration.BuildDir(), "soong_build_metrics.pb")
|
||||||
err := android.WriteMetrics(configuration, metricsFile)
|
err := android.WriteMetrics(configuration, metricsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error writing soong_build metrics %s: %s", metricsFile, err)
|
fmt.Fprintf(os.Stderr, "error writing soong_build metrics %s: %s", metricsFile, err)
|
||||||
@@ -193,7 +193,7 @@ func main() {
|
|||||||
usedVariablesFile := shared.JoinPath(outDir, "soong.environment.used")
|
usedVariablesFile := shared.JoinPath(outDir, "soong.environment.used")
|
||||||
// The top-level Blueprints file is passed as the first argument.
|
// The top-level Blueprints file is passed as the first argument.
|
||||||
srcDir := filepath.Dir(flag.Arg(0))
|
srcDir := filepath.Dir(flag.Arg(0))
|
||||||
configuration := newConfig(srcDir)
|
configuration := newConfig(srcDir, outDir)
|
||||||
extraNinjaDeps := []string{
|
extraNinjaDeps := []string{
|
||||||
configuration.ProductVariablesFileName,
|
configuration.ProductVariablesFileName,
|
||||||
shared.JoinPath(outDir, "soong.environment.used"),
|
shared.JoinPath(outDir, "soong.environment.used"),
|
||||||
@@ -203,10 +203,6 @@ func main() {
|
|||||||
configuration.SetAllowMissingDependencies()
|
configuration.SetAllowMissingDependencies()
|
||||||
}
|
}
|
||||||
|
|
||||||
// These two are here so that we restart a non-debugged soong_build when the
|
|
||||||
// user sets SOONG_DELVE the first time.
|
|
||||||
configuration.Getenv("SOONG_DELVE")
|
|
||||||
configuration.Getenv("SOONG_DELVE_PATH")
|
|
||||||
if shared.IsDebugging() {
|
if shared.IsDebugging() {
|
||||||
// Add a non-existent file to the dependencies so that soong_build will rerun when the debugger is
|
// Add a non-existent file to the dependencies so that soong_build will rerun when the debugger is
|
||||||
// enabled even if it completed successfully.
|
// enabled even if it completed successfully.
|
||||||
|
@@ -104,6 +104,11 @@ func bootstrapBlueprint(ctx Context, config Config) {
|
|||||||
args.GlobFile = shared.JoinPath(config.SoongOutDir(), ".bootstrap/soong-build-globs.ninja")
|
args.GlobFile = shared.JoinPath(config.SoongOutDir(), ".bootstrap/soong-build-globs.ninja")
|
||||||
args.GeneratingPrimaryBuilder = true
|
args.GeneratingPrimaryBuilder = true
|
||||||
|
|
||||||
|
args.DelveListen = os.Getenv("SOONG_DELVE")
|
||||||
|
if args.DelveListen != "" {
|
||||||
|
args.DelvePath = shared.ResolveDelveBinary()
|
||||||
|
}
|
||||||
|
|
||||||
blueprintCtx := blueprint.NewContext()
|
blueprintCtx := blueprint.NewContext()
|
||||||
blueprintCtx.SetIgnoreUnknownModuleTypes(true)
|
blueprintCtx.SetIgnoreUnknownModuleTypes(true)
|
||||||
blueprintConfig := BlueprintConfig{
|
blueprintConfig := BlueprintConfig{
|
||||||
@@ -138,11 +143,6 @@ func runSoong(ctx Context, config Config) {
|
|||||||
|
|
||||||
soongBuildEnv := config.Environment().Copy()
|
soongBuildEnv := config.Environment().Copy()
|
||||||
soongBuildEnv.Set("TOP", os.Getenv("TOP"))
|
soongBuildEnv.Set("TOP", os.Getenv("TOP"))
|
||||||
// These two dependencies are read from bootstrap.go, but also need to be here
|
|
||||||
// so that soong_build can declare a dependency on them
|
|
||||||
soongBuildEnv.Set("SOONG_DELVE", os.Getenv("SOONG_DELVE"))
|
|
||||||
soongBuildEnv.Set("SOONG_DELVE_PATH", os.Getenv("SOONG_DELVE_PATH"))
|
|
||||||
soongBuildEnv.Set("SOONG_OUTDIR", config.SoongOutDir())
|
|
||||||
// For Bazel mixed builds.
|
// For Bazel mixed builds.
|
||||||
soongBuildEnv.Set("BAZEL_PATH", "./tools/bazel")
|
soongBuildEnv.Set("BAZEL_PATH", "./tools/bazel")
|
||||||
soongBuildEnv.Set("BAZEL_HOME", filepath.Join(config.BazelOutDir(), "bazelhome"))
|
soongBuildEnv.Set("BAZEL_HOME", filepath.Join(config.BazelOutDir(), "bazelhome"))
|
||||||
@@ -215,13 +215,6 @@ func runSoong(ctx Context, config Config) {
|
|||||||
// This is currently how the command line to invoke soong_build finds the
|
// This is currently how the command line to invoke soong_build finds the
|
||||||
// root of the source tree and the output root
|
// root of the source tree and the output root
|
||||||
ninjaEnv.Set("TOP", os.Getenv("TOP"))
|
ninjaEnv.Set("TOP", os.Getenv("TOP"))
|
||||||
ninjaEnv.Set("SOONG_OUTDIR", config.SoongOutDir())
|
|
||||||
|
|
||||||
// For debugging
|
|
||||||
if os.Getenv("SOONG_DELVE") != "" {
|
|
||||||
ninjaEnv.Set("SOONG_DELVE", os.Getenv("SOONG_DELVE"))
|
|
||||||
ninjaEnv.Set("SOONG_DELVE_PATH", shared.ResolveDelveBinary())
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.Environment = &ninjaEnv
|
cmd.Environment = &ninjaEnv
|
||||||
cmd.Sandbox = soongSandbox
|
cmd.Sandbox = soongSandbox
|
||||||
|
Reference in New Issue
Block a user