Add a '-q' option to not print recipes before executing.
This commit is contained in:
parent
53634f87d8
commit
73d1b31466
3 changed files with 23 additions and 9 deletions
4
graph.go
4
graph.go
|
|
@ -322,11 +322,11 @@ func (g *graph) ambiguous(u *node) {
|
||||||
} else {
|
} else {
|
||||||
if !le.r.equivRecipe(e.r) {
|
if !le.r.equivRecipe(e.r) {
|
||||||
if le.r.ismeta && !e.r.ismeta {
|
if le.r.ismeta && !e.r.ismeta {
|
||||||
mkPrintRecipe(u.name, le.r.recipe)
|
mkPrintRecipe(u.name, le.r.recipe, false)
|
||||||
le.togo = true
|
le.togo = true
|
||||||
le = e
|
le = e
|
||||||
} else if !le.r.ismeta && e.r.ismeta {
|
} else if !le.r.ismeta && e.r.ismeta {
|
||||||
mkPrintRecipe(u.name, e.r.recipe)
|
mkPrintRecipe(u.name, e.r.recipe, false)
|
||||||
e.togo = true
|
e.togo = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
mk.go
24
mk.go
|
|
@ -273,7 +273,7 @@ func mkPrintMessage(msg string) {
|
||||||
mkMsgMutex.Unlock()
|
mkMsgMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func mkPrintRecipe(target string, recipe string) {
|
func mkPrintRecipe(target string, recipe string, quiet bool) {
|
||||||
mkMsgMutex.Lock()
|
mkMsgMutex.Lock()
|
||||||
if nocolor {
|
if nocolor {
|
||||||
fmt.Printf("%s: ", target)
|
fmt.Printf("%s: ", target)
|
||||||
|
|
@ -282,9 +282,17 @@ func mkPrintRecipe(target string, recipe string) {
|
||||||
ansiTermBlue+ansiTermBright+ansiTermUnderline, target,
|
ansiTermBlue+ansiTermBright+ansiTermUnderline, target,
|
||||||
ansiTermDefault, ansiTermBlue)
|
ansiTermDefault, ansiTermBlue)
|
||||||
}
|
}
|
||||||
printIndented(os.Stdout, recipe, len(target)+3)
|
if quiet {
|
||||||
if len(recipe) == 0 {
|
if nocolor {
|
||||||
os.Stdout.WriteString("\n")
|
fmt.Println("...")
|
||||||
|
} else {
|
||||||
|
fmt.Println("…")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printIndented(os.Stdout, recipe, len(target)+3)
|
||||||
|
if len(recipe) == 0 {
|
||||||
|
os.Stdout.WriteString("\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !nocolor {
|
if !nocolor {
|
||||||
os.Stdout.WriteString(ansiTermDefault)
|
os.Stdout.WriteString(ansiTermDefault)
|
||||||
|
|
@ -297,6 +305,7 @@ func main() {
|
||||||
var interactive bool
|
var interactive bool
|
||||||
var dryrun bool
|
var dryrun bool
|
||||||
var shallowrebuild bool
|
var shallowrebuild bool
|
||||||
|
var quiet bool
|
||||||
|
|
||||||
flag.StringVar(&mkfilepath, "f", "mkfile", "use the given file as mkfile")
|
flag.StringVar(&mkfilepath, "f", "mkfile", "use the given file as mkfile")
|
||||||
flag.BoolVar(&dryrun, "n", false, "print commands without actually executing")
|
flag.BoolVar(&dryrun, "n", false, "print commands without actually executing")
|
||||||
|
|
@ -304,6 +313,7 @@ func main() {
|
||||||
flag.BoolVar(&rebuildall, "a", false, "force building of all dependencies")
|
flag.BoolVar(&rebuildall, "a", false, "force building of all dependencies")
|
||||||
flag.IntVar(&subprocsAllowed, "p", 4, "maximum number of jobs to execute in parallel")
|
flag.IntVar(&subprocsAllowed, "p", 4, "maximum number of jobs to execute in parallel")
|
||||||
flag.BoolVar(&interactive, "i", false, "prompt before executing rules")
|
flag.BoolVar(&interactive, "i", false, "prompt before executing rules")
|
||||||
|
flag.BoolVar(&quiet, "q", false, "don't print recipes before executing them")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
mkfile, err := os.Open(mkfilepath)
|
mkfile, err := os.Open(mkfilepath)
|
||||||
|
|
@ -319,6 +329,12 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
rs := parse(string(input), mkfilepath, abspath)
|
rs := parse(string(input), mkfilepath, abspath)
|
||||||
|
if quiet {
|
||||||
|
for i := range rs.rules {
|
||||||
|
rs.rules[i].attributes.quiet = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
targets := flag.Args()
|
targets := flag.Args()
|
||||||
|
|
||||||
// build the first non-meta rule in the makefile, if none are given explicitly
|
// build the first non-meta rule in the makefile, if none are given explicitly
|
||||||
|
|
|
||||||
|
|
@ -97,9 +97,7 @@ func dorecipe(target string, u *node, e *edge, dryrun bool) bool {
|
||||||
args = e.r.shell[1:]
|
args = e.r.shell[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
if !e.r.attributes.quiet {
|
mkPrintRecipe(target, input, e.r.attributes.quiet)
|
||||||
mkPrintRecipe(target, input)
|
|
||||||
}
|
|
||||||
|
|
||||||
if dryrun {
|
if dryrun {
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue