Make GENERATE_BAZEL_FILES=true correct.

This is achieved by writing soong.environment.used in Main() instead of
as a side effect of a singleton. This makes a difference because build
actions are not generated when GENERATE_BAZEL_FILES=true is set,
therefore the side effect did not happen.

Arguably, Main() is made worse by this change, but I don't want to
tackle the problem of readably determining which mode soong_build is
running in in this change.

Test: Presubmits + the additional test.
Change-Id: I66af2429aedf008762173eaaa55b828b4cf4328b
This commit is contained in:
Lukacs T. Berki
2021-03-23 11:46:47 +01:00
parent c29088b727
commit f0b3b94bb3
5 changed files with 143 additions and 50 deletions

View File

@@ -401,9 +401,6 @@ func (ctx *TestContext) Register() {
globalOrder.mutatorOrder.enforceOrdering(mutators)
mutators.registerAll(ctx.Context)
// Register the env singleton with this context before sorting.
ctx.RegisterSingletonType("env", EnvSingleton)
// Ensure that the singletons used in the test are in the same order as they are used at runtime.
globalOrder.singletonOrder.enforceOrdering(ctx.singletons)
ctx.singletons.registerAll(ctx.Context)