Fix variables in recipes, prefix expansion, and -a switch behavior
This commit is contained in:
parent
82ec5bfab4
commit
913af90c60
5 changed files with 15 additions and 6 deletions
|
|
@ -234,9 +234,10 @@ func expandSuffixes(input string, stem string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
c, w := utf8.DecodeRuneInString(input[j:])
|
c, w := utf8.DecodeRuneInString(input[j:])
|
||||||
|
expanded = append(expanded, input[i:j]...)
|
||||||
if c == '%' {
|
if c == '%' {
|
||||||
expanded = append(expanded, stem...)
|
expanded = append(expanded, stem...)
|
||||||
i += w
|
i = j + w
|
||||||
} else {
|
} else {
|
||||||
j += w
|
j += w
|
||||||
c, w := utf8.DecodeRuneInString(input[j:])
|
c, w := utf8.DecodeRuneInString(input[j:])
|
||||||
|
|
|
||||||
4
graph.go
4
graph.go
|
|
@ -72,6 +72,10 @@ func (u *node) updateTimestamp() {
|
||||||
mkError(err.Error())
|
mkError(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rebuildall {
|
||||||
|
u.flags |= nodeFlagProbable
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new node
|
// Create a new node
|
||||||
|
|
|
||||||
6
mk.go
6
mk.go
|
|
@ -97,7 +97,7 @@ func mkNode(g *graph, u *node) {
|
||||||
if len(u.prereqs) == 0 {
|
if len(u.prereqs) == 0 {
|
||||||
if !(u.r != nil && u.r.attributes.virtual) && !u.exists {
|
if !(u.r != nil && u.r.attributes.virtual) && !u.exists {
|
||||||
wd, _ := os.Getwd()
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -200,11 +200,11 @@ func mkPrintRecipe(target string, recipe string) {
|
||||||
if nocolor {
|
if nocolor {
|
||||||
fmt.Printf("%s: ", target)
|
fmt.Printf("%s: ", target)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s%s%s →\n%s",
|
fmt.Printf("%s%s%s → %s",
|
||||||
ansiTermBlue+ansiTermBright+ansiTermUnderline, target,
|
ansiTermBlue+ansiTermBright+ansiTermUnderline, target,
|
||||||
ansiTermDefault, ansiTermBlue)
|
ansiTermDefault, ansiTermBlue)
|
||||||
}
|
}
|
||||||
printIndented(os.Stdout, recipe, 4)
|
printIndented(os.Stdout, recipe, len(target)+3)
|
||||||
if len(recipe) == 0 {
|
if len(recipe) == 0 {
|
||||||
os.Stdout.WriteString("\n")
|
os.Stdout.WriteString("\n")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
parse.go
2
parse.go
|
|
@ -347,7 +347,7 @@ func parseRecipe(p *parser, t token) parserStateFun {
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.typ == tokenRecipe {
|
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)
|
p.rules.add(r)
|
||||||
|
|
|
||||||
|
|
@ -46,15 +46,19 @@ func stripIndentation(s string, mincol int) string {
|
||||||
func printIndented(out io.Writer, s string, ind int) {
|
func printIndented(out io.Writer, s string, ind int) {
|
||||||
indentation := strings.Repeat(" ", ind)
|
indentation := strings.Repeat(" ", ind)
|
||||||
reader := bufio.NewReader(strings.NewReader(s))
|
reader := bufio.NewReader(strings.NewReader(s))
|
||||||
|
firstline := true
|
||||||
for {
|
for {
|
||||||
line, err := reader.ReadString('\n')
|
line, err := reader.ReadString('\n')
|
||||||
if len(line) > 0 {
|
if len(line) > 0 {
|
||||||
|
if !firstline {
|
||||||
io.WriteString(out, indentation)
|
io.WriteString(out, indentation)
|
||||||
|
}
|
||||||
io.WriteString(out, line)
|
io.WriteString(out, line)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
firstline = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue