Improve soong_ui main.go comments.
And do a minor cleanup while we're there. Test: TreeHugger Bug: 173557448 Change-Id: Id1736f82f64c1a0a4b29749f73d3a3724fc501a7
This commit is contained in:
@@ -125,27 +125,35 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Create a terminal output that mimics Ninja's.
|
||||
output := terminal.NewStatusOutput(c.stdio().Stdout(), os.Getenv("NINJA_STATUS"), c.simpleOutput,
|
||||
build.OsEnvironment().IsEnvTrue("ANDROID_QUIET_BUILD"))
|
||||
|
||||
// Attach a new logger instance to the terminal output.
|
||||
log := logger.New(output)
|
||||
defer log.Cleanup()
|
||||
|
||||
// Create a context to simplify the program termination process.
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
// Create a new trace file writer, making it log events to the log instance.
|
||||
trace := tracer.New(log)
|
||||
defer trace.Close()
|
||||
|
||||
// Create and start a new metric record.
|
||||
met := metrics.New()
|
||||
met.SetBuildDateTime(buildStarted)
|
||||
met.SetBuildCommand(os.Args)
|
||||
|
||||
// Create a new Status instance, which manages action counts and event output channels.
|
||||
stat := &status.Status{}
|
||||
defer stat.Finish()
|
||||
// Hook up the terminal output and tracer to Status.
|
||||
stat.AddOutput(output)
|
||||
stat.AddOutput(trace.StatusTracer())
|
||||
|
||||
// Set up a cleanup procedure in case the normal termination process doesn't work.
|
||||
build.SetupSignals(log, cancel, func() {
|
||||
trace.Close()
|
||||
log.Cleanup()
|
||||
@@ -165,6 +173,7 @@ func main() {
|
||||
|
||||
build.SetupOutDir(buildCtx, config)
|
||||
|
||||
// Set up files to be outputted in the log directory.
|
||||
logsDir := config.OutDir()
|
||||
if config.Dist() {
|
||||
logsDir = filepath.Join(config.DistDir(), "logs")
|
||||
@@ -192,7 +201,10 @@ func main() {
|
||||
defer met.Dump(soongMetricsFile)
|
||||
defer build.DumpRBEMetrics(buildCtx, config, rbeMetricsFile)
|
||||
|
||||
// Read the time at the starting point.
|
||||
if start, ok := os.LookupEnv("TRACE_BEGIN_SOONG"); ok {
|
||||
// soong_ui.bash uses the date command's %N (nanosec) flag when getting the start time,
|
||||
// which Darwin doesn't support. Check if it was executed properly before parsing the value.
|
||||
if !strings.HasSuffix(start, "N") {
|
||||
if start_time, err := strconv.ParseUint(start, 10, 64); err == nil {
|
||||
log.Verbosef("Took %dms to start up.",
|
||||
@@ -211,6 +223,7 @@ func main() {
|
||||
fixBadDanglingLink(buildCtx, "hardware/qcom/sdm710/Android.bp")
|
||||
fixBadDanglingLink(buildCtx, "hardware/qcom/sdm710/Android.mk")
|
||||
|
||||
// Create a source finder.
|
||||
f := build.NewSourceFinder(buildCtx, config)
|
||||
defer f.Shutdown()
|
||||
build.FindSources(buildCtx, config, f)
|
||||
@@ -354,6 +367,8 @@ func stdio() terminal.StdioInterface {
|
||||
return terminal.StdioImpl{}
|
||||
}
|
||||
|
||||
// dumpvar and dumpvars use stdout to output variable values, so use stderr instead of stdout when
|
||||
// reporting events to keep stdout clean from noise.
|
||||
func customStdio() terminal.StdioInterface {
|
||||
return terminal.NewCustomStdio(os.Stdin, os.Stderr, os.Stderr)
|
||||
}
|
||||
@@ -493,16 +508,6 @@ func getCommand(args []string) (*command, []string, error) {
|
||||
if c.flag == args[1] {
|
||||
return &c, args[2:], nil
|
||||
}
|
||||
|
||||
// special case for --make-mode: if soong_ui was called from
|
||||
// build/make/core/main.mk, the makeparallel with --ninja
|
||||
// option specified puts the -j<num> before --make-mode.
|
||||
// TODO: Remove this hack once it has been fixed.
|
||||
if c.flag == makeModeFlagName {
|
||||
if inList(makeModeFlagName, args) {
|
||||
return &c, args[1:], nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// command not found
|
||||
|
Reference in New Issue
Block a user