2017-01-20 23:10:01 +01:00
|
|
|
// Copyright 2017 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
2017-05-20 01:39:04 +02:00
|
|
|
"io/ioutil"
|
2017-01-20 23:10:01 +01:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
|
|
|
"strings"
|
|
|
|
"sync"
|
2017-12-11 23:35:23 +01:00
|
|
|
"syscall"
|
2017-03-30 04:26:09 +02:00
|
|
|
"time"
|
2017-01-20 23:10:01 +01:00
|
|
|
|
|
|
|
"android/soong/ui/build"
|
|
|
|
"android/soong/ui/logger"
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
"android/soong/ui/status"
|
|
|
|
"android/soong/ui/terminal"
|
2016-08-22 00:17:17 +02:00
|
|
|
"android/soong/ui/tracer"
|
2017-11-07 20:23:27 +01:00
|
|
|
"android/soong/zip"
|
2017-01-20 23:10:01 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// We default to number of cpus / 4, which seems to be the sweet spot for my
|
|
|
|
// system. I suspect this is mostly due to memory or disk bandwidth though, and
|
|
|
|
// may depend on the size ofthe source tree, so this probably isn't a great
|
|
|
|
// default.
|
|
|
|
func detectNumJobs() int {
|
|
|
|
if runtime.NumCPU() < 4 {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
return runtime.NumCPU() / 4
|
|
|
|
}
|
|
|
|
|
|
|
|
var numJobs = flag.Int("j", detectNumJobs(), "number of parallel kati jobs")
|
|
|
|
|
2017-11-07 20:23:27 +01:00
|
|
|
var keepArtifacts = flag.Bool("keep", false, "keep archives of artifacts")
|
2017-01-20 23:10:01 +01:00
|
|
|
|
|
|
|
var outDir = flag.String("out", "", "path to store output directories (defaults to tmpdir under $OUT when empty)")
|
2017-05-20 01:39:04 +02:00
|
|
|
var alternateResultDir = flag.Bool("dist", false, "write select results to $DIST_DIR (or <out>/dist when empty)")
|
2017-01-20 23:10:01 +01:00
|
|
|
|
|
|
|
var onlyConfig = flag.Bool("only-config", false, "Only run product config (not Soong or Kati)")
|
|
|
|
var onlySoong = flag.Bool("only-soong", false, "Only run product config and Soong (not Kati)")
|
|
|
|
|
2017-05-07 20:40:30 +02:00
|
|
|
var buildVariant = flag.String("variant", "eng", "build variant to use")
|
|
|
|
|
2017-10-07 00:05:05 +02:00
|
|
|
var skipProducts = flag.String("skip-products", "", "comma-separated list of products to skip (known failures, etc)")
|
2017-10-26 00:02:45 +02:00
|
|
|
var includeProducts = flag.String("products", "", "comma-separated list of products to build")
|
2017-10-07 00:05:05 +02:00
|
|
|
|
2017-05-20 01:39:04 +02:00
|
|
|
const errorLeadingLines = 20
|
|
|
|
const errorTrailingLines = 20
|
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
type Product struct {
|
2017-05-20 01:39:04 +02:00
|
|
|
ctx build.Context
|
|
|
|
config build.Config
|
|
|
|
logFile string
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
action *status.Action
|
2017-01-20 23:10:01 +01:00
|
|
|
}
|
|
|
|
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
func errMsgFromLog(filename string) string {
|
|
|
|
if filename == "" {
|
|
|
|
return ""
|
2017-05-07 01:58:26 +02:00
|
|
|
}
|
|
|
|
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
data, err := ioutil.ReadFile(filename)
|
|
|
|
if err != nil {
|
|
|
|
return ""
|
2017-05-20 01:39:04 +02:00
|
|
|
}
|
|
|
|
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
lines := strings.Split(strings.TrimSpace(string(data)), "\n")
|
|
|
|
if len(lines) > errorLeadingLines+errorTrailingLines+1 {
|
|
|
|
lines[errorLeadingLines] = fmt.Sprintf("... skipping %d lines ...",
|
|
|
|
len(lines)-errorLeadingLines-errorTrailingLines)
|
2017-05-07 01:58:26 +02:00
|
|
|
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
lines = append(lines[:errorLeadingLines+1],
|
|
|
|
lines[len(lines)-errorTrailingLines:]...)
|
2017-05-07 01:58:26 +02:00
|
|
|
}
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
var buf strings.Builder
|
|
|
|
for _, line := range lines {
|
|
|
|
buf.WriteString("> ")
|
|
|
|
buf.WriteString(line)
|
|
|
|
buf.WriteString("\n")
|
2017-05-07 01:58:26 +02:00
|
|
|
}
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
return buf.String()
|
2017-05-07 01:58:26 +02:00
|
|
|
}
|
|
|
|
|
2017-12-11 23:35:23 +01:00
|
|
|
// TODO(b/70370883): This tool uses a lot of open files -- over the default
|
|
|
|
// soft limit of 1024 on some systems. So bump up to the hard limit until I fix
|
|
|
|
// the algorithm.
|
|
|
|
func setMaxFiles(log logger.Logger) {
|
|
|
|
var limits syscall.Rlimit
|
|
|
|
|
|
|
|
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limits)
|
|
|
|
if err != nil {
|
|
|
|
log.Println("Failed to get file limit:", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Verbosef("Current file limits: %d soft, %d hard", limits.Cur, limits.Max)
|
|
|
|
if limits.Cur == limits.Max {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
limits.Cur = limits.Max
|
|
|
|
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limits)
|
|
|
|
if err != nil {
|
|
|
|
log.Println("Failed to increase file limit:", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-26 00:02:45 +02:00
|
|
|
func inList(str string, list []string) bool {
|
|
|
|
for _, other := range list {
|
|
|
|
if str == other {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
func main() {
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
writer := terminal.NewWriter(terminal.StdioImpl{})
|
|
|
|
defer writer.Finish()
|
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
log := logger.New(os.Stderr)
|
|
|
|
defer log.Cleanup()
|
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
2016-08-22 00:17:17 +02:00
|
|
|
trace := tracer.New(log)
|
|
|
|
defer trace.Close()
|
2017-01-20 23:10:01 +01:00
|
|
|
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
stat := &status.Status{}
|
|
|
|
defer stat.Finish()
|
|
|
|
stat.AddOutput(terminal.NewStatusOutput(writer, ""))
|
|
|
|
|
2016-08-22 00:17:17 +02:00
|
|
|
build.SetupSignals(log, cancel, func() {
|
|
|
|
trace.Close()
|
|
|
|
log.Cleanup()
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
stat.Finish()
|
2016-08-22 00:17:17 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
buildCtx := build.Context{&build.ContextImpl{
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
Context: ctx,
|
|
|
|
Logger: log,
|
|
|
|
Tracer: trace,
|
|
|
|
Writer: writer,
|
|
|
|
Status: stat,
|
2016-08-22 00:17:17 +02:00
|
|
|
}}
|
2017-01-20 23:10:01 +01:00
|
|
|
|
|
|
|
config := build.NewConfig(buildCtx)
|
|
|
|
if *outDir == "" {
|
2017-03-30 04:26:09 +02:00
|
|
|
name := "multiproduct-" + time.Now().Format("20060102150405")
|
|
|
|
|
|
|
|
*outDir = filepath.Join(config.OutDir(), name)
|
|
|
|
|
2017-05-20 01:39:04 +02:00
|
|
|
// Ensure the empty files exist in the output directory
|
|
|
|
// containing our output directory too. This is mostly for
|
|
|
|
// safety, but also triggers the ninja_build file so that our
|
|
|
|
// build servers know that they can parse the output as if it
|
|
|
|
// was ninja output.
|
|
|
|
build.SetupOutDir(buildCtx, config)
|
|
|
|
|
2017-03-30 04:26:09 +02:00
|
|
|
if err := os.MkdirAll(*outDir, 0777); err != nil {
|
2017-01-20 23:10:01 +01:00
|
|
|
log.Fatalf("Failed to create tempdir: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
config.Environment().Set("OUT_DIR", *outDir)
|
|
|
|
log.Println("Output directory:", *outDir)
|
|
|
|
|
2017-11-07 20:23:27 +01:00
|
|
|
logsDir := filepath.Join(config.OutDir(), "logs")
|
|
|
|
os.MkdirAll(logsDir, 0777)
|
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
build.SetupOutDir(buildCtx, config)
|
2017-05-20 01:39:04 +02:00
|
|
|
if *alternateResultDir {
|
2017-11-07 20:23:27 +01:00
|
|
|
distLogsDir := filepath.Join(config.DistDir(), "logs")
|
|
|
|
os.MkdirAll(distLogsDir, 0777)
|
|
|
|
log.SetOutput(filepath.Join(distLogsDir, "soong.log"))
|
|
|
|
trace.SetOutput(filepath.Join(distLogsDir, "build.trace"))
|
2017-05-20 01:39:04 +02:00
|
|
|
} else {
|
|
|
|
log.SetOutput(filepath.Join(config.OutDir(), "soong.log"))
|
|
|
|
trace.SetOutput(filepath.Join(config.OutDir(), "build.trace"))
|
|
|
|
}
|
2017-01-20 23:10:01 +01:00
|
|
|
|
2017-12-11 23:35:23 +01:00
|
|
|
setMaxFiles(log)
|
|
|
|
|
2018-05-15 09:52:29 +02:00
|
|
|
finder := build.NewSourceFinder(buildCtx, config)
|
|
|
|
defer finder.Shutdown()
|
|
|
|
|
|
|
|
build.FindSources(buildCtx, config, finder)
|
|
|
|
|
2017-07-14 02:24:44 +02:00
|
|
|
vars, err := build.DumpMakeVars(buildCtx, config, nil, []string{"all_named_products"})
|
2017-01-20 23:10:01 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2017-10-26 00:02:45 +02:00
|
|
|
var productsList []string
|
|
|
|
allProducts := strings.Fields(vars["all_named_products"])
|
|
|
|
|
|
|
|
if *includeProducts != "" {
|
|
|
|
missingProducts := []string{}
|
|
|
|
for _, product := range strings.Split(*includeProducts, ",") {
|
|
|
|
if inList(product, allProducts) {
|
|
|
|
productsList = append(productsList, product)
|
|
|
|
} else {
|
|
|
|
missingProducts = append(missingProducts, product)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(missingProducts) > 0 {
|
|
|
|
log.Fatalf("Products don't exist: %s\n", missingProducts)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
productsList = allProducts
|
|
|
|
}
|
2017-10-07 00:05:05 +02:00
|
|
|
|
|
|
|
products := make([]string, 0, len(productsList))
|
|
|
|
skipList := strings.Split(*skipProducts, ",")
|
|
|
|
skipProduct := func(p string) bool {
|
|
|
|
for _, s := range skipList {
|
|
|
|
if p == s {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
for _, product := range productsList {
|
|
|
|
if !skipProduct(product) {
|
|
|
|
products = append(products, product)
|
|
|
|
} else {
|
|
|
|
log.Verbose("Skipping: ", product)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Verbose("Got product list: ", products)
|
2017-01-20 23:10:01 +01:00
|
|
|
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
s := buildCtx.Status.StartTool()
|
|
|
|
s.SetTotalActions(len(products))
|
2017-05-07 01:58:26 +02:00
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
var wg sync.WaitGroup
|
|
|
|
productConfigs := make(chan Product, len(products))
|
|
|
|
|
|
|
|
// Run the product config for every product in parallel
|
|
|
|
for _, product := range products {
|
|
|
|
wg.Add(1)
|
|
|
|
go func(product string) {
|
2017-05-20 01:39:04 +02:00
|
|
|
var stdLog string
|
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
defer wg.Done()
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
|
|
|
|
action := &status.Action{
|
|
|
|
Description: product,
|
|
|
|
Outputs: []string{product},
|
|
|
|
}
|
|
|
|
s.StartAction(action)
|
2017-01-20 23:10:01 +01:00
|
|
|
defer logger.Recover(func(err error) {
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
s.FinishAction(status.ActionResult{
|
|
|
|
Action: action,
|
|
|
|
Error: err,
|
|
|
|
Output: errMsgFromLog(stdLog),
|
|
|
|
})
|
2017-01-20 23:10:01 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
productOutDir := filepath.Join(config.OutDir(), product)
|
2017-11-07 20:23:27 +01:00
|
|
|
productLogDir := filepath.Join(logsDir, product)
|
2017-01-20 23:10:01 +01:00
|
|
|
|
|
|
|
if err := os.MkdirAll(productOutDir, 0777); err != nil {
|
|
|
|
log.Fatalf("Error creating out directory: %v", err)
|
|
|
|
}
|
2017-11-07 20:23:27 +01:00
|
|
|
if err := os.MkdirAll(productLogDir, 0777); err != nil {
|
|
|
|
log.Fatalf("Error creating log directory: %v", err)
|
|
|
|
}
|
2017-01-20 23:10:01 +01:00
|
|
|
|
2017-05-20 01:39:04 +02:00
|
|
|
stdLog = filepath.Join(productLogDir, "std.log")
|
|
|
|
f, err := os.Create(stdLog)
|
2017-01-20 23:10:01 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Error creating std.log: %v", err)
|
|
|
|
}
|
|
|
|
|
2017-11-12 00:44:51 +01:00
|
|
|
productLog := logger.New(f)
|
2017-05-20 01:39:04 +02:00
|
|
|
productLog.SetOutput(filepath.Join(productLogDir, "soong.log"))
|
2017-01-20 23:10:01 +01:00
|
|
|
|
2016-08-22 00:17:17 +02:00
|
|
|
productCtx := build.Context{&build.ContextImpl{
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
Context: ctx,
|
|
|
|
Logger: productLog,
|
|
|
|
Tracer: trace,
|
|
|
|
Writer: terminal.NewWriter(terminal.NewCustomStdio(nil, f, f)),
|
|
|
|
Thread: trace.NewThread(product),
|
|
|
|
Status: &status.Status{},
|
2016-08-22 00:17:17 +02:00
|
|
|
}}
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
productCtx.Status.AddOutput(terminal.NewStatusOutput(productCtx.Writer, ""))
|
2017-01-20 23:10:01 +01:00
|
|
|
|
|
|
|
productConfig := build.NewConfig(productCtx)
|
|
|
|
productConfig.Environment().Set("OUT_DIR", productOutDir)
|
2017-08-17 23:09:23 +02:00
|
|
|
build.FindSources(productCtx, productConfig, finder)
|
2017-05-07 20:40:30 +02:00
|
|
|
productConfig.Lunch(productCtx, product, *buildVariant)
|
2017-01-20 23:10:01 +01:00
|
|
|
|
|
|
|
build.Build(productCtx, productConfig, build.BuildProductConfig)
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
productConfigs <- Product{productCtx, productConfig, stdLog, action}
|
2017-01-20 23:10:01 +01:00
|
|
|
}(product)
|
|
|
|
}
|
|
|
|
go func() {
|
|
|
|
defer close(productConfigs)
|
|
|
|
wg.Wait()
|
|
|
|
}()
|
|
|
|
|
|
|
|
var wg2 sync.WaitGroup
|
|
|
|
// Then run up to numJobs worth of Soong and Kati
|
|
|
|
for i := 0; i < *numJobs; i++ {
|
|
|
|
wg2.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer wg2.Done()
|
|
|
|
for product := range productConfigs {
|
|
|
|
func() {
|
|
|
|
defer logger.Recover(func(err error) {
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
s.FinishAction(status.ActionResult{
|
|
|
|
Action: product.action,
|
|
|
|
Error: err,
|
|
|
|
Output: errMsgFromLog(product.logFile),
|
|
|
|
})
|
2017-01-20 23:10:01 +01:00
|
|
|
})
|
|
|
|
|
2017-11-07 20:23:27 +01:00
|
|
|
defer func() {
|
|
|
|
if *keepArtifacts {
|
|
|
|
args := zip.ZipArgs{
|
|
|
|
FileArgs: []zip.FileArg{
|
|
|
|
{
|
|
|
|
GlobDir: product.config.OutDir(),
|
|
|
|
SourcePrefixToStrip: product.config.OutDir(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
OutputFilePath: filepath.Join(config.OutDir(), product.config.TargetProduct()+".zip"),
|
|
|
|
NumParallelJobs: runtime.NumCPU(),
|
|
|
|
CompressionLevel: 5,
|
|
|
|
}
|
|
|
|
if err := zip.Run(args); err != nil {
|
|
|
|
log.Fatalf("Error zipping artifacts: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
os.RemoveAll(product.config.OutDir())
|
|
|
|
}()
|
|
|
|
|
2017-01-20 23:10:01 +01:00
|
|
|
buildWhat := 0
|
|
|
|
if !*onlyConfig {
|
|
|
|
buildWhat |= build.BuildSoong
|
|
|
|
if !*onlySoong {
|
|
|
|
buildWhat |= build.BuildKati
|
|
|
|
}
|
|
|
|
}
|
|
|
|
build.Build(product.ctx, product.config, buildWhat)
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
s.FinishAction(status.ActionResult{
|
|
|
|
Action: product.action,
|
|
|
|
})
|
2017-01-20 23:10:01 +01:00
|
|
|
}()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|
2017-05-07 01:58:26 +02:00
|
|
|
wg2.Wait()
|
2017-01-20 23:10:01 +01:00
|
|
|
|
2017-11-07 20:23:27 +01:00
|
|
|
if *alternateResultDir {
|
|
|
|
args := zip.ZipArgs{
|
|
|
|
FileArgs: []zip.FileArg{
|
|
|
|
{GlobDir: logsDir, SourcePrefixToStrip: logsDir},
|
|
|
|
},
|
|
|
|
OutputFilePath: filepath.Join(config.DistDir(), "logs.zip"),
|
|
|
|
NumParallelJobs: runtime.NumCPU(),
|
|
|
|
CompressionLevel: 5,
|
|
|
|
}
|
|
|
|
if err := zip.Run(args); err != nil {
|
|
|
|
log.Fatalf("Error zipping logs: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add a unified status reporting UI
This adds a new status package that merges the running of "actions"
(ninja calls them edges) of multiple tools into one view of the current
state, and gives that to a number of different outputs.
For inputs:
Kati's output parser has been rewritten (and moved) to map onto the
StartAction/FinishAction API. A byproduct of this is that the build
servers should be able to extract errors from Kati better, since they
look like the errors that Ninja used to write.
Ninja is no longer directly connected to the terminal, but its output is
read via the protobuf frontend API, so it's just another tool whose
output becomes merged together.
multiproduct_kati loses its custom status routines, and uses the common
one instead.
For outputs:
The primary output is the ui/terminal.Status type, which along with
ui/terminal.Writer now controls everything about the terminal output.
Today, this doesn't really change any behaviors, but having all terminal
output going through here allows a more complicated (multi-line / full
window) status display in the future.
The tracer acts as an output of the status package, tracing all the
action start / finish events. This replaces reading the .ninja_log file,
so it now properly handles multiple output files from a single action.
A new rotated log file (out/error.log, or out/dist/logs/error.log) just
contains a description of all of the errors that happened during the
current build.
Another new compressed and rotated log file (out/verbose.log.gz, or
out/dist/logs/verbose.log.gz) contains the full verbose (showcommands)
log of every execution run by the build. Since this is now written on
every build, the showcommands argument is now ignored -- if you want to
get the commands run, look at the log file after the build.
Test: m
Test: <built-in tests>
Test: NINJA_ARGS="-t list" m
Test: check the build.trace.gz
Test: check the new log files
Change-Id: If1d8994890d43ef68f65aa10ddd8e6e06dc7013a
2018-05-18 01:37:09 +02:00
|
|
|
s.Finish()
|
2017-01-20 23:10:01 +01:00
|
|
|
}
|