Loading cmd/soong_build/main.go +15 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package main import ( "bytes" "errors" "flag" "fmt" "os" Loading Loading @@ -135,12 +136,24 @@ func runMixedModeBuild(ctx *android.Context, extraNinjaDeps []string) string { writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps) if ctx.Config().IsEnvTrue("SOONG_GENERATES_NINJA_HINT") { if needToWriteNinjaHint(ctx) { writeNinjaHint(ctx) } return cmdlineArgs.OutFile } func needToWriteNinjaHint(ctx *android.Context) bool { switch ctx.Config().GetenvWithDefault("SOONG_GENERATES_NINJA_HINT", "") { case "always": return true case "depend": if _, err := os.Stat(filepath.Join(ctx.Config().OutDir(), ".ninja_log")); errors.Is(err, os.ErrNotExist) { return true } } return false } // Run the code-generation phase to convert BazelTargetModules to BUILD files. func runQueryView(queryviewDir, queryviewMarker string, ctx *android.Context) { ctx.EventHandler.Begin("queryview") Loading Loading @@ -460,7 +473,7 @@ func runSoongOnlyBuild(ctx *android.Context, extraNinjaDeps []string) string { // The actual output (build.ninja) was written in the RunBlueprint() call // above writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps) if ctx.Config().IsEnvTrue("SOONG_GENERATES_NINJA_HINT") { if needToWriteNinjaHint(ctx) { writeNinjaHint(ctx) } return cmdlineArgs.OutFile Loading ui/build/config.go +19 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package build import ( "encoding/json" "errors" "fmt" "io/ioutil" "math/rand" Loading Loading @@ -136,6 +137,9 @@ const ( EXTERNAL_FILE // ninja uses a prioritized module list from Soong HINT_FROM_SOONG // If ninja log exists, use NINJA_LOG, if not, use HINT_FROM_SOONG instead. // We can assume it is an incremental build if ninja log exists. DEFAULT ) const srcDirFileCheck = "build/soong/root.bp" Loading Loading @@ -233,7 +237,7 @@ func NewConfig(ctx Context, args ...string) Config { ret := &configImpl{ environ: OsEnvironment(), sandboxConfig: &SandboxConfig{}, ninjaWeightListSource: NINJA_LOG, ninjaWeightListSource: DEFAULT, } // Default matching ninja Loading @@ -244,8 +248,21 @@ func NewConfig(ctx Context, args ...string) Config { ret.parseArgs(ctx, args) if ret.ninjaWeightListSource == HINT_FROM_SOONG { ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "true") ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "always") } else if ret.ninjaWeightListSource == DEFAULT { defaultNinjaWeightListSource := NINJA_LOG if _, err := os.Stat(filepath.Join(ret.OutDir(), ninjaLogFileName)); errors.Is(err, os.ErrNotExist) { ctx.Verboseln("$OUT/.ninja_log doesn't exist, use HINT_FROM_SOONG instead") defaultNinjaWeightListSource = HINT_FROM_SOONG } else { ctx.Verboseln("$OUT/.ninja_log exist, use NINJA_LOG") } ret.ninjaWeightListSource = defaultNinjaWeightListSource // soong_build generates ninja hint depending on ninja log existence. // Set it "depend" to avoid soong re-run due to env variable change. ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "depend") } // Make sure OUT_DIR is set appropriately if outDir, ok := ret.environ.Get("OUT_DIR"); ok { ret.environ.Set("OUT_DIR", filepath.Clean(outDir)) Loading Loading
cmd/soong_build/main.go +15 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package main import ( "bytes" "errors" "flag" "fmt" "os" Loading Loading @@ -135,12 +136,24 @@ func runMixedModeBuild(ctx *android.Context, extraNinjaDeps []string) string { writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps) if ctx.Config().IsEnvTrue("SOONG_GENERATES_NINJA_HINT") { if needToWriteNinjaHint(ctx) { writeNinjaHint(ctx) } return cmdlineArgs.OutFile } func needToWriteNinjaHint(ctx *android.Context) bool { switch ctx.Config().GetenvWithDefault("SOONG_GENERATES_NINJA_HINT", "") { case "always": return true case "depend": if _, err := os.Stat(filepath.Join(ctx.Config().OutDir(), ".ninja_log")); errors.Is(err, os.ErrNotExist) { return true } } return false } // Run the code-generation phase to convert BazelTargetModules to BUILD files. func runQueryView(queryviewDir, queryviewMarker string, ctx *android.Context) { ctx.EventHandler.Begin("queryview") Loading Loading @@ -460,7 +473,7 @@ func runSoongOnlyBuild(ctx *android.Context, extraNinjaDeps []string) string { // The actual output (build.ninja) was written in the RunBlueprint() call // above writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps) if ctx.Config().IsEnvTrue("SOONG_GENERATES_NINJA_HINT") { if needToWriteNinjaHint(ctx) { writeNinjaHint(ctx) } return cmdlineArgs.OutFile Loading
ui/build/config.go +19 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package build import ( "encoding/json" "errors" "fmt" "io/ioutil" "math/rand" Loading Loading @@ -136,6 +137,9 @@ const ( EXTERNAL_FILE // ninja uses a prioritized module list from Soong HINT_FROM_SOONG // If ninja log exists, use NINJA_LOG, if not, use HINT_FROM_SOONG instead. // We can assume it is an incremental build if ninja log exists. DEFAULT ) const srcDirFileCheck = "build/soong/root.bp" Loading Loading @@ -233,7 +237,7 @@ func NewConfig(ctx Context, args ...string) Config { ret := &configImpl{ environ: OsEnvironment(), sandboxConfig: &SandboxConfig{}, ninjaWeightListSource: NINJA_LOG, ninjaWeightListSource: DEFAULT, } // Default matching ninja Loading @@ -244,8 +248,21 @@ func NewConfig(ctx Context, args ...string) Config { ret.parseArgs(ctx, args) if ret.ninjaWeightListSource == HINT_FROM_SOONG { ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "true") ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "always") } else if ret.ninjaWeightListSource == DEFAULT { defaultNinjaWeightListSource := NINJA_LOG if _, err := os.Stat(filepath.Join(ret.OutDir(), ninjaLogFileName)); errors.Is(err, os.ErrNotExist) { ctx.Verboseln("$OUT/.ninja_log doesn't exist, use HINT_FROM_SOONG instead") defaultNinjaWeightListSource = HINT_FROM_SOONG } else { ctx.Verboseln("$OUT/.ninja_log exist, use NINJA_LOG") } ret.ninjaWeightListSource = defaultNinjaWeightListSource // soong_build generates ninja hint depending on ninja log existence. // Set it "depend" to avoid soong re-run due to env variable change. ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "depend") } // Make sure OUT_DIR is set appropriately if outDir, ok := ret.environ.Get("OUT_DIR"); ok { ret.environ.Set("OUT_DIR", filepath.Clean(outDir)) Loading