Avoid loss of ninja_deps events am: 780a185ede
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2287715 Change-Id: I0a0d5eda168a48271e7d073725e0e06c1b3e76dc Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
bd0b8f72c5
2 changed files with 14 additions and 14 deletions
|
@ -62,7 +62,7 @@ func (soongMetricsSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectMetrics(config Config, eventHandler metrics.EventHandler) *soong_metrics_proto.SoongBuildMetrics {
|
func collectMetrics(config Config, eventHandler *metrics.EventHandler) *soong_metrics_proto.SoongBuildMetrics {
|
||||||
metrics := &soong_metrics_proto.SoongBuildMetrics{}
|
metrics := &soong_metrics_proto.SoongBuildMetrics{}
|
||||||
|
|
||||||
soongMetrics, ok := readSoongMetrics(config)
|
soongMetrics, ok := readSoongMetrics(config)
|
||||||
|
@ -107,7 +107,7 @@ func collectMetrics(config Config, eventHandler metrics.EventHandler) *soong_met
|
||||||
return metrics
|
return metrics
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteMetrics(config Config, eventHandler metrics.EventHandler, metricsFile string) error {
|
func WriteMetrics(config Config, eventHandler *metrics.EventHandler, metricsFile string) error {
|
||||||
metrics := collectMetrics(config, eventHandler)
|
metrics := collectMetrics(config, eventHandler)
|
||||||
|
|
||||||
buf, err := proto.Marshal(metrics)
|
buf, err := proto.Marshal(metrics)
|
||||||
|
|
|
@ -187,7 +187,7 @@ func runMixedModeBuild(configuration android.Config, ctx *android.Context, extra
|
||||||
globListFiles := writeBuildGlobsNinjaFile(ctx, configuration.SoongOutDir(), configuration)
|
globListFiles := writeBuildGlobsNinjaFile(ctx, configuration.SoongOutDir(), configuration)
|
||||||
ninjaDeps = append(ninjaDeps, globListFiles...)
|
ninjaDeps = append(ninjaDeps, globListFiles...)
|
||||||
|
|
||||||
writeDepFile(cmdlineArgs.OutFile, *ctx.EventHandler, ninjaDeps)
|
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the code-generation phase to convert BazelTargetModules to BUILD files.
|
// Run the code-generation phase to convert BazelTargetModules to BUILD files.
|
||||||
|
@ -266,7 +266,7 @@ func runApiBp2build(configuration android.Config, extraNinjaDeps []string) strin
|
||||||
ninjaDeps = append(ninjaDeps, symlinkDeps...)
|
ninjaDeps = append(ninjaDeps, symlinkDeps...)
|
||||||
|
|
||||||
workspaceMarkerFile := workspace + ".marker"
|
workspaceMarkerFile := workspace + ".marker"
|
||||||
writeDepFile(workspaceMarkerFile, *ctx.EventHandler, ninjaDeps)
|
writeDepFile(workspaceMarkerFile, ctx.EventHandler, ninjaDeps)
|
||||||
touch(shared.JoinPath(topDir, workspaceMarkerFile))
|
touch(shared.JoinPath(topDir, workspaceMarkerFile))
|
||||||
return workspaceMarkerFile
|
return workspaceMarkerFile
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ func apiBuildFileExcludes() []string {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeMetrics(configuration android.Config, eventHandler metrics.EventHandler, metricsDir string) {
|
func writeMetrics(configuration android.Config, eventHandler *metrics.EventHandler, metricsDir string) {
|
||||||
if len(metricsDir) < 1 {
|
if len(metricsDir) < 1 {
|
||||||
fmt.Fprintf(os.Stderr, "\nMissing required env var for generating soong metrics: LOG_DIR\n")
|
fmt.Fprintf(os.Stderr, "\nMissing required env var for generating soong metrics: LOG_DIR\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -333,7 +333,7 @@ func writeBuildGlobsNinjaFile(ctx *android.Context, buildDir string, config inte
|
||||||
return bootstrap.GlobFileListFiles(globDir)
|
return bootstrap.GlobFileListFiles(globDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeDepFile(outputFile string, eventHandler metrics.EventHandler, ninjaDeps []string) {
|
func writeDepFile(outputFile string, eventHandler *metrics.EventHandler, ninjaDeps []string) {
|
||||||
eventHandler.Begin("ninja_deps")
|
eventHandler.Begin("ninja_deps")
|
||||||
defer eventHandler.End("ninja_deps")
|
defer eventHandler.End("ninja_deps")
|
||||||
depFile := shared.JoinPath(topDir, outputFile+".d")
|
depFile := shared.JoinPath(topDir, outputFile+".d")
|
||||||
|
@ -380,11 +380,11 @@ func doChosenActivity(ctx *android.Context, configuration android.Config, extraN
|
||||||
if configuration.BuildMode == android.GenerateQueryView {
|
if configuration.BuildMode == android.GenerateQueryView {
|
||||||
queryviewMarkerFile := bazelQueryViewDir + ".marker"
|
queryviewMarkerFile := bazelQueryViewDir + ".marker"
|
||||||
runQueryView(bazelQueryViewDir, queryviewMarkerFile, configuration, ctx)
|
runQueryView(bazelQueryViewDir, queryviewMarkerFile, configuration, ctx)
|
||||||
writeDepFile(queryviewMarkerFile, *ctx.EventHandler, ninjaDeps)
|
writeDepFile(queryviewMarkerFile, ctx.EventHandler, ninjaDeps)
|
||||||
return queryviewMarkerFile
|
return queryviewMarkerFile
|
||||||
} else if configuration.BuildMode == android.GenerateModuleGraph {
|
} else if configuration.BuildMode == android.GenerateModuleGraph {
|
||||||
writeJsonModuleGraphAndActions(ctx, moduleGraphFile, moduleActionsFile)
|
writeJsonModuleGraphAndActions(ctx, moduleGraphFile, moduleActionsFile)
|
||||||
writeDepFile(moduleGraphFile, *ctx.EventHandler, ninjaDeps)
|
writeDepFile(moduleGraphFile, ctx.EventHandler, ninjaDeps)
|
||||||
return moduleGraphFile
|
return moduleGraphFile
|
||||||
} else if configuration.BuildMode == android.GenerateDocFile {
|
} else if configuration.BuildMode == android.GenerateDocFile {
|
||||||
// TODO: we could make writeDocs() return the list of documentation files
|
// TODO: we could make writeDocs() return the list of documentation files
|
||||||
|
@ -394,12 +394,12 @@ func doChosenActivity(ctx *android.Context, configuration android.Config, extraN
|
||||||
fmt.Fprintf(os.Stderr, "error building Soong documentation: %s\n", err)
|
fmt.Fprintf(os.Stderr, "error building Soong documentation: %s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
writeDepFile(docFile, *ctx.EventHandler, ninjaDeps)
|
writeDepFile(docFile, ctx.EventHandler, ninjaDeps)
|
||||||
return docFile
|
return docFile
|
||||||
} else {
|
} else {
|
||||||
// The actual output (build.ninja) was written in the RunBlueprint() call
|
// The actual output (build.ninja) was written in the RunBlueprint() call
|
||||||
// above
|
// above
|
||||||
writeDepFile(cmdlineArgs.OutFile, *ctx.EventHandler, ninjaDeps)
|
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ func main() {
|
||||||
finalOutputFile := doChosenActivity(ctx, configuration, extraNinjaDeps)
|
finalOutputFile := doChosenActivity(ctx, configuration, extraNinjaDeps)
|
||||||
|
|
||||||
ctx.EventHandler.End("soong_build")
|
ctx.EventHandler.End("soong_build")
|
||||||
writeMetrics(configuration, *ctx.EventHandler, logDir)
|
writeMetrics(configuration, ctx.EventHandler, logDir)
|
||||||
|
|
||||||
writeUsedEnvironmentFile(configuration, finalOutputFile)
|
writeUsedEnvironmentFile(configuration, finalOutputFile)
|
||||||
}
|
}
|
||||||
|
@ -615,7 +615,7 @@ func bazelArtifacts() []string {
|
||||||
// symlink tree creation binary. Then the latter would not need to depend on
|
// symlink tree creation binary. Then the latter would not need to depend on
|
||||||
// the very heavy-weight machinery of soong_build .
|
// the very heavy-weight machinery of soong_build .
|
||||||
func runSymlinkForestCreation(configuration android.Config, extraNinjaDeps []string) {
|
func runSymlinkForestCreation(configuration android.Config, extraNinjaDeps []string) {
|
||||||
eventHandler := metrics.EventHandler{}
|
eventHandler := &metrics.EventHandler{}
|
||||||
|
|
||||||
var ninjaDeps []string
|
var ninjaDeps []string
|
||||||
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
|
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
|
||||||
|
@ -668,7 +668,7 @@ func runSymlinkForestCreation(configuration android.Config, extraNinjaDeps []str
|
||||||
// Bazel BUILD files instead of Ninja files.
|
// Bazel BUILD files instead of Ninja files.
|
||||||
func runBp2Build(configuration android.Config, extraNinjaDeps []string) {
|
func runBp2Build(configuration android.Config, extraNinjaDeps []string) {
|
||||||
var codegenMetrics *bp2build.CodegenMetrics
|
var codegenMetrics *bp2build.CodegenMetrics
|
||||||
eventHandler := metrics.EventHandler{}
|
eventHandler := &metrics.EventHandler{}
|
||||||
eventHandler.Do("bp2build", func() {
|
eventHandler.Do("bp2build", func() {
|
||||||
|
|
||||||
// Register an alternate set of singletons and mutators for bazel
|
// Register an alternate set of singletons and mutators for bazel
|
||||||
|
@ -721,7 +721,7 @@ func runBp2Build(configuration android.Config, extraNinjaDeps []string) {
|
||||||
|
|
||||||
// Write Bp2Build metrics into $LOG_DIR
|
// Write Bp2Build metrics into $LOG_DIR
|
||||||
func writeBp2BuildMetrics(codegenMetrics *bp2build.CodegenMetrics,
|
func writeBp2BuildMetrics(codegenMetrics *bp2build.CodegenMetrics,
|
||||||
configuration android.Config, eventHandler metrics.EventHandler) {
|
configuration android.Config, eventHandler *metrics.EventHandler) {
|
||||||
for _, event := range eventHandler.CompletedEvents() {
|
for _, event := range eventHandler.CompletedEvents() {
|
||||||
codegenMetrics.AddEvent(&bp2build_metrics_proto.Event{
|
codegenMetrics.AddEvent(&bp2build_metrics_proto.Event{
|
||||||
Name: event.Id,
|
Name: event.Id,
|
||||||
|
|
Loading…
Reference in a new issue