Add --empty-ninja-file for test usecases
In cases that we want to run blueprint-based builds in many configurations to verify all of the logic works without errors, but don't care about running the final ninja file, writing it out only wastes time and disk space. So add a --empty-ninja-file option that writes out an empty ninja file instead. Our specific use case (Soong's build_test / multiproduct_kati) runs Soong several hundred times for different configurations, and the ninja files are around 1GB, which leads to several hundred gigabytes of disk writes (and persistent use during incremental generation). Change-Id: I0198dfb2f744ce22284c05d5214dac2ab5dc9700
This commit is contained in:
parent
19099e68bb
commit
dac90d33ca
4 changed files with 17 additions and 0 deletions
|
@ -93,6 +93,11 @@ done
|
||||||
# If RUN_TESTS is set, behave like -t was passed in as an option.
|
# If RUN_TESTS is set, behave like -t was passed in as an option.
|
||||||
[ ! -z "$RUN_TESTS" ] && EXTRA_ARGS="${EXTRA_ARGS} -t"
|
[ ! -z "$RUN_TESTS" ] && EXTRA_ARGS="${EXTRA_ARGS} -t"
|
||||||
|
|
||||||
|
# If EMPTY_NINJA_FILE is set, have the primary build write out a 0-byte ninja
|
||||||
|
# file instead of a full length one. Useful if you don't plan on executing the
|
||||||
|
# build, but want to verify the primary builder execution.
|
||||||
|
[ ! -z "$EMPTY_NINJA_FILE" ] && EXTRA_ARGS="${EXTRA_ARGS} --empty-ninja-file"
|
||||||
|
|
||||||
# Allow the caller to pass in a list of module files
|
# Allow the caller to pass in a list of module files
|
||||||
if [ -z "${BLUEPRINT_LIST_FILE}" ]; then
|
if [ -z "${BLUEPRINT_LIST_FILE}" ]; then
|
||||||
BLUEPRINT_LIST_FILE="${BUILDDIR}/.bootstrap/bplist"
|
BLUEPRINT_LIST_FILE="${BUILDDIR}/.bootstrap/bplist"
|
||||||
|
|
|
@ -650,6 +650,9 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
||||||
if s.config.moduleListFile != "" {
|
if s.config.moduleListFile != "" {
|
||||||
extraSharedFlagArray = append(extraSharedFlagArray, "-l", s.config.moduleListFile)
|
extraSharedFlagArray = append(extraSharedFlagArray, "-l", s.config.moduleListFile)
|
||||||
}
|
}
|
||||||
|
if s.config.emptyNinjaFile {
|
||||||
|
extraSharedFlagArray = append(extraSharedFlagArray, "--empty-ninja-file")
|
||||||
|
}
|
||||||
extraSharedFlagString := strings.Join(extraSharedFlagArray, " ")
|
extraSharedFlagString := strings.Join(extraSharedFlagArray, " ")
|
||||||
|
|
||||||
var primaryBuilderName, primaryBuilderExtraFlags string
|
var primaryBuilderName, primaryBuilderExtraFlags string
|
||||||
|
|
|
@ -41,6 +41,7 @@ var (
|
||||||
runGoTests bool
|
runGoTests bool
|
||||||
noGC bool
|
noGC bool
|
||||||
moduleListFile string
|
moduleListFile string
|
||||||
|
emptyNinjaFile bool
|
||||||
|
|
||||||
BuildDir string
|
BuildDir string
|
||||||
NinjaBuildDir string
|
NinjaBuildDir string
|
||||||
|
@ -60,6 +61,7 @@ func init() {
|
||||||
flag.BoolVar(&noGC, "nogc", false, "turn off GC for debugging")
|
flag.BoolVar(&noGC, "nogc", false, "turn off GC for debugging")
|
||||||
flag.BoolVar(&runGoTests, "t", false, "build and run go tests during bootstrap")
|
flag.BoolVar(&runGoTests, "t", false, "build and run go tests during bootstrap")
|
||||||
flag.StringVar(&moduleListFile, "l", "", "file that lists filepaths to parse")
|
flag.StringVar(&moduleListFile, "l", "", "file that lists filepaths to parse")
|
||||||
|
flag.BoolVar(&emptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...string) {
|
func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...string) {
|
||||||
|
@ -122,7 +124,9 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri
|
||||||
|
|
||||||
bootstrapConfig := &Config{
|
bootstrapConfig := &Config{
|
||||||
stage: stage,
|
stage: stage,
|
||||||
|
|
||||||
topLevelBlueprintsFile: flag.Arg(0),
|
topLevelBlueprintsFile: flag.Arg(0),
|
||||||
|
emptyNinjaFile: emptyNinjaFile,
|
||||||
runGoTests: runGoTests,
|
runGoTests: runGoTests,
|
||||||
moduleListFile: moduleListFile,
|
moduleListFile: moduleListFile,
|
||||||
}
|
}
|
||||||
|
@ -175,6 +179,10 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri
|
||||||
fatalf("error generating Ninja file contents: %s", err)
|
fatalf("error generating Ninja file contents: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if stage == StageMain && emptyNinjaFile {
|
||||||
|
buf.Reset()
|
||||||
|
}
|
||||||
|
|
||||||
const outFilePermissions = 0666
|
const outFilePermissions = 0666
|
||||||
err = ioutil.WriteFile(outFile, buf.Bytes(), outFilePermissions)
|
err = ioutil.WriteFile(outFile, buf.Bytes(), outFilePermissions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -105,6 +105,7 @@ type Config struct {
|
||||||
|
|
||||||
topLevelBlueprintsFile string
|
topLevelBlueprintsFile string
|
||||||
|
|
||||||
|
emptyNinjaFile bool
|
||||||
runGoTests bool
|
runGoTests bool
|
||||||
moduleListFile string
|
moduleListFile string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue