cosmetic: fail fast on empty module list am: 71ce3eae12

Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2219405

Change-Id: I465597ab21dd852102a3fe09d7c751a6e1530621
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
usta 2022-09-20 05:49:17 +00:00 committed by Automerger Merge Worker
commit 9bc4b27cef

View file

@ -74,22 +74,22 @@ func RunBlueprint(args Args, stopBefore StopBefore, ctx *blueprint.Context, conf
defer trace.Stop()
}
srcDir := "."
ninjaDeps := make([]string, 0)
if args.ModuleListFile != "" {
ctx.SetModuleListFile(args.ModuleListFile)
ninjaDeps = append(ninjaDeps, args.ModuleListFile)
} else {
if args.ModuleListFile == "" {
fatalf("-l <moduleListFile> is required and must be nonempty")
}
ctx.SetModuleListFile(args.ModuleListFile)
var ninjaDeps []string
ninjaDeps = append(ninjaDeps, args.ModuleListFile)
ctx.BeginEvent("list_modules")
filesToParse, err := ctx.ListModulePaths(srcDir)
ctx.EndEvent("list_modules")
if err != nil {
var filesToParse []string
if f, err := ctx.ListModulePaths("."); err != nil {
fatalf("could not enumerate files: %v\n", err.Error())
} else {
filesToParse = f
}
ctx.EndEvent("list_modules")
ctx.RegisterBottomUpMutator("bootstrap_plugin_deps", pluginDeps)
ctx.RegisterModuleType("bootstrap_go_package", newGoPackageModuleFactory())
@ -97,37 +97,34 @@ func RunBlueprint(args Args, stopBefore StopBefore, ctx *blueprint.Context, conf
ctx.RegisterSingletonType("bootstrap", newSingletonFactory())
ctx.BeginEvent("parse_bp")
blueprintFiles, errs := ctx.ParseFileList(".", filesToParse, config)
if len(errs) > 0 {
if blueprintFiles, errs := ctx.ParseFileList(".", filesToParse, config); len(errs) > 0 {
fatalErrors(errs)
} else {
ctx.EndEvent("parse_bp")
ninjaDeps = append(ninjaDeps, blueprintFiles...)
}
ctx.EndEvent("parse_bp")
// Add extra ninja file dependencies
ninjaDeps = append(ninjaDeps, blueprintFiles...)
extraDeps, errs := ctx.ResolveDependencies(config)
if len(errs) > 0 {
if resolvedDeps, errs := ctx.ResolveDependencies(config); len(errs) > 0 {
fatalErrors(errs)
} else {
ninjaDeps = append(ninjaDeps, resolvedDeps...)
}
ninjaDeps = append(ninjaDeps, extraDeps...)
if stopBefore == StopBeforePrepareBuildActions {
return ninjaDeps
}
if ctx.BeforePrepareBuildActionsHook != nil {
err := ctx.BeforePrepareBuildActionsHook()
if err != nil {
if err := ctx.BeforePrepareBuildActionsHook(); err != nil {
fatalErrors([]error{err})
}
}
extraDeps, errs = ctx.PrepareBuildActions(config)
if len(errs) > 0 {
if buildActionsDeps, errs := ctx.PrepareBuildActions(config); len(errs) > 0 {
fatalErrors(errs)
} else {
ninjaDeps = append(ninjaDeps, buildActionsDeps...)
}
ninjaDeps = append(ninjaDeps, extraDeps...)
if stopBefore == StopBeforeWriteNinja {
return ninjaDeps
@ -147,7 +144,7 @@ func RunBlueprint(args Args, stopBefore StopBefore, ctx *blueprint.Context, conf
}
if !args.EmptyNinjaFile {
f, err = os.OpenFile(joinPath(ctx.SrcDir(), args.OutFile), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, outFilePermissions)
f, err := os.OpenFile(joinPath(ctx.SrcDir(), args.OutFile), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, outFilePermissions)
if err != nil {
fatalf("error opening Ninja file: %s", err)
}
@ -157,21 +154,18 @@ func RunBlueprint(args Args, stopBefore StopBefore, ctx *blueprint.Context, conf
out = io.Discard.(io.StringWriter)
}
err = ctx.WriteBuildFile(out)
if err != nil {
if err := ctx.WriteBuildFile(out); err != nil {
fatalf("error writing Ninja file contents: %s", err)
}
if buf != nil {
err = buf.Flush()
if err != nil {
if err := buf.Flush(); err != nil {
fatalf("error flushing Ninja file contents: %s", err)
}
}
if f != nil {
err = f.Close()
if err != nil {
if err := f.Close(); err != nil {
fatalf("error closing Ninja file: %s", err)
}
}