Fix variables in recipes, prefix expansion, and -a switch behavior

This commit is contained in:
Daniel Jones 2013-03-18 20:37:01 -07:00
parent 82ec5bfab4
commit 913af90c60
5 changed files with 15 additions and 6 deletions

View file

@ -234,9 +234,10 @@ func expandSuffixes(input string, stem string) string {
}
c, w := utf8.DecodeRuneInString(input[j:])
expanded = append(expanded, input[i:j]...)
if c == '%' {
expanded = append(expanded, stem...)
i += w
i = j + w
} else {
j += w
c, w := utf8.DecodeRuneInString(input[j:])

View file

@ -72,6 +72,10 @@ func (u *node) updateTimestamp() {
mkError(err.Error())
}
}
if rebuildall {
u.flags |= nodeFlagProbable
}
}
// Create a new node

6
mk.go
View file

@ -97,7 +97,7 @@ func mkNode(g *graph, u *node) {
if len(u.prereqs) == 0 {
if !(u.r != nil && u.r.attributes.virtual) && !u.exists {
wd, _ := os.Getwd()
mkError(fmt.Sprintf("don't know how to make %s in %s", u.name, wd))
mkError(fmt.Sprintf("don't know how to make %s in %s\n", u.name, wd))
}
return
}
@ -200,11 +200,11 @@ func mkPrintRecipe(target string, recipe string) {
if nocolor {
fmt.Printf("%s: ", target)
} else {
fmt.Printf("%s%s%s →\n%s",
fmt.Printf("%s%s%s → %s",
ansiTermBlue+ansiTermBright+ansiTermUnderline, target,
ansiTermDefault, ansiTermBlue)
}
printIndented(os.Stdout, recipe, 4)
printIndented(os.Stdout, recipe, len(target)+3)
if len(recipe) == 0 {
os.Stdout.WriteString("\n")
}

View file

@ -347,7 +347,7 @@ func parseRecipe(p *parser, t token) parserStateFun {
}
if t.typ == tokenRecipe {
r.recipe = stripIndentation(t.val, t.col)
r.recipe = expandRecipeSigils(stripIndentation(t.val, t.col), p.rules.vars)
}
p.rules.add(r)

View file

@ -46,15 +46,19 @@ func stripIndentation(s string, mincol int) string {
func printIndented(out io.Writer, s string, ind int) {
indentation := strings.Repeat(" ", ind)
reader := bufio.NewReader(strings.NewReader(s))
firstline := true
for {
line, err := reader.ReadString('\n')
if len(line) > 0 {
io.WriteString(out, indentation)
if !firstline {
io.WriteString(out, indentation)
}
io.WriteString(out, line)
}
if err != nil {
break
}
firstline = false
}
}