aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ast.go12
-rw-r--r--cmdline.go2
-rw-r--r--dep.go18
-rw-r--r--eval.go32
-rw-r--r--exec.go8
-rw-r--r--func.go42
-rw-r--r--log.go18
-rw-r--r--parser.go26
-rw-r--r--pathutil.go46
-rw-r--r--serialize.go10
-rw-r--r--shellutil.go24
-rw-r--r--strutil.go4
-rw-r--r--worker.go26
13 files changed, 134 insertions, 134 deletions
diff --git a/ast.go b/ast.go
index f30668a..17ad01a 100644
--- a/ast.go
+++ b/ast.go
@@ -83,7 +83,7 @@ func (ast *assignAST) evalRHS(ev *Evaluator, lhs string) Var {
}
func (ast *assignAST) show() {
- Logf("%s %s %s %q", ast.opt, ast.lhs, ast.op, ast.rhs)
+ logf("%s %s %s %q", ast.opt, ast.lhs, ast.op, ast.rhs)
}
// maybeRuleAST is an ast for rule line.
@@ -101,7 +101,7 @@ func (ast *maybeRuleAST) eval(ev *Evaluator) {
}
func (ast *maybeRuleAST) show() {
- Logf("%s", ast.expr)
+ logf("%s", ast.expr)
}
type commandAST struct {
@@ -114,7 +114,7 @@ func (ast *commandAST) eval(ev *Evaluator) {
}
func (ast *commandAST) show() {
- Logf("\t%s", strings.Replace(ast.cmd, "\n", `\n`, -1))
+ logf("\t%s", strings.Replace(ast.cmd, "\n", `\n`, -1))
}
type includeAST struct {
@@ -128,7 +128,7 @@ func (ast *includeAST) eval(ev *Evaluator) {
}
func (ast *includeAST) show() {
- Logf("include %s", ast.expr)
+ logf("include %s", ast.expr)
}
type ifAST struct {
@@ -146,7 +146,7 @@ func (ast *ifAST) eval(ev *Evaluator) {
func (ast *ifAST) show() {
// TODO
- Logf("if")
+ logf("if")
}
type exportAST struct {
@@ -161,5 +161,5 @@ func (ast *exportAST) eval(ev *Evaluator) {
func (ast *exportAST) show() {
// TODO
- Logf("export")
+ logf("export")
}
diff --git a/cmdline.go b/cmdline.go
index 05b0637..e87984a 100644
--- a/cmdline.go
+++ b/cmdline.go
@@ -35,7 +35,7 @@ func ParseCommandLine(cmdline []string) ([]string, []string) {
func initVars(vars Vars, kvlist []string, origin string) error {
for _, v := range kvlist {
kv := strings.SplitN(v, "=", 2)
- Logf("%s var %q", origin, v)
+ logf("%s var %q", origin, v)
if len(kv) < 2 {
return fmt.Errorf("A weird %s variable %q", origin, kv)
}
diff --git a/dep.go b/dep.go
index a728b87..6d3eb26 100644
--- a/dep.go
+++ b/dep.go
@@ -147,8 +147,8 @@ func (db *depBuilder) mergeImplicitRuleVars(outputs []string, vars Vars) Vars {
if len(outputs) != 1 {
panic(fmt.Sprintf("Implicit rule should have only one output but %q", outputs))
}
- Logf("merge? %q", db.ruleVars)
- Logf("merge? %q", outputs[0])
+ logf("merge? %q", db.ruleVars)
+ logf("merge? %q", outputs[0])
ivars, present := db.ruleVars[outputs[0]]
if !present {
return vars
@@ -156,7 +156,7 @@ func (db *depBuilder) mergeImplicitRuleVars(outputs []string, vars Vars) Vars {
if vars == nil {
return ivars
}
- Logf("merge!")
+ logf("merge!")
v := make(Vars)
v.Merge(ivars)
v.Merge(vars)
@@ -237,7 +237,7 @@ func (db *depBuilder) pickRule(output string) (*rule, Vars, bool) {
}
func (db *depBuilder) buildPlan(output string, neededBy string, tsvs Vars) (*DepNode, error) {
- Logf("Evaluating command: %s", output)
+ logf("Evaluating command: %s", output)
db.nodeCnt++
if db.nodeCnt%100 == 0 {
db.reportStats()
@@ -292,7 +292,7 @@ func (db *depBuilder) buildPlan(output string, neededBy string, tsvs Vars) (*Dep
var children []*DepNode
var actualInputs []string
- Logf("Evaluating command: %s inputs:%q", output, rule.inputs)
+ logf("Evaluating command: %s inputs:%q", output, rule.inputs)
for _, input := range rule.inputs {
if len(rule.outputPatterns) > 0 {
if len(rule.outputPatterns) > 1 {
@@ -375,11 +375,11 @@ func (db *depBuilder) populateSuffixRule(r *rule, output string) bool {
func mergeRules(oldRule, r *rule, output string, isSuffixRule bool) *rule {
if oldRule.isDoubleColon != r.isDoubleColon {
- Error(r.filename, r.lineno, "*** target file %q has both : and :: entries.", output)
+ errorExit(r.filename, r.lineno, "*** target file %q has both : and :: entries.", output)
}
if len(oldRule.cmds) > 0 && len(r.cmds) > 0 && !isSuffixRule && !r.isDoubleColon {
- Warn(r.filename, r.cmdLineno, "overriding commands for target %q", output)
- Warn(oldRule.filename, oldRule.cmdLineno, "ignoring old commands for target %q", output)
+ warn(r.filename, r.cmdLineno, "overriding commands for target %q", output)
+ warn(oldRule.filename, oldRule.cmdLineno, "ignoring old commands for target %q", output)
}
mr := &rule{}
@@ -523,7 +523,7 @@ func newDepBuilder(er *evalResult, vars Vars) *depBuilder {
func (db *depBuilder) Eval(targets []string) ([]*DepNode, error) {
if len(targets) == 0 {
if db.firstRule == nil {
- ErrorNoLocation("*** No targets.")
+ errorNoLocationExit("*** No targets.")
}
targets = append(targets, db.firstRule.outputs[0])
}
diff --git a/eval.go b/eval.go
index b24d2ed..2bfaa46 100644
--- a/eval.go
+++ b/eval.go
@@ -151,10 +151,10 @@ func (ev *Evaluator) evalAssign(ast *assignAST) {
ev.lastRule = nil
lhs, rhs := ev.evalAssignAST(ast)
if LogFlag {
- Logf("ASSIGN: %s=%q (flavor:%q)", lhs, rhs, rhs.Flavor())
+ logf("ASSIGN: %s=%q (flavor:%q)", lhs, rhs, rhs.Flavor())
}
if lhs == "" {
- Error(ast.filename, ast.lineno, "*** empty variable name.")
+ errorExit(ast.filename, ast.lineno, "*** empty variable name.")
}
ev.outVars.Assign(lhs, rhs)
}
@@ -188,7 +188,7 @@ func (ev *Evaluator) setTargetSpecificVar(assign *assignAST, output string) {
ev.currentScope = vars
lhs, rhs := ev.evalAssignAST(assign)
if LogFlag {
- Logf("rule outputs:%q assign:%q=%q (flavor:%q)", output, lhs, rhs, rhs.Flavor())
+ logf("rule outputs:%q assign:%q=%q (flavor:%q)", output, lhs, rhs, rhs.Flavor())
}
vars.Assign(lhs, &targetSpecificVar{v: rhs, op: assign.op})
ev.currentScope = nil
@@ -207,7 +207,7 @@ func (ev *Evaluator) evalMaybeRule(ast *maybeRuleAST) {
line = append(line, ast.afterTerm...)
}
if LogFlag {
- Logf("rule? %q=>%q", ast.expr, line)
+ logf("rule? %q=>%q", ast.expr, line)
}
// See semicolon.mk.
@@ -222,15 +222,15 @@ func (ev *Evaluator) evalMaybeRule(ast *maybeRuleAST) {
}
assign, err := r.parse(line)
if err != nil {
- Error(ast.filename, ast.lineno, "%v", err.Error())
+ errorExit(ast.filename, ast.lineno, "%v", err)
}
freeBuf(buf)
if LogFlag {
- Logf("rule %q => outputs:%q, inputs:%q", line, r.outputs, r.inputs)
+ logf("rule %q => outputs:%q, inputs:%q", line, r.outputs, r.inputs)
}
// TODO: Pretty print.
- //Logf("RULE: %s=%s (%d commands)", lhs, rhs, len(cmds))
+ //logf("RULE: %s=%s (%d commands)", lhs, rhs, len(cmds))
if assign != nil {
if ast.term == ';' {
@@ -244,7 +244,7 @@ func (ev *Evaluator) evalMaybeRule(ast *maybeRuleAST) {
lexpr.Eval(buf, ev)
assign, err = r.parse(buf.Bytes())
if err != nil {
- Error(ast.filename, ast.lineno, "%v", err.Error())
+ errorExit(ast.filename, ast.lineno, "%v", err)
}
freeBuf(buf)
}
@@ -261,7 +261,7 @@ func (ev *Evaluator) evalMaybeRule(ast *maybeRuleAST) {
r.cmds = append(r.cmds, string(ast.afterTerm[1:]))
}
if LogFlag {
- Logf("rule outputs:%q cmds:%q", r.outputs, r.cmds)
+ logf("rule outputs:%q cmds:%q", r.outputs, r.cmds)
}
ev.lastRule = r
ev.outRules = append(ev.outRules, r)
@@ -288,7 +288,7 @@ func (ev *Evaluator) evalCommand(ast *commandAST) {
if strings.TrimSpace(ast.cmd)[0] == '#' {
return
}
- Error(ast.filename, ast.lineno, "*** commands commence before first target.")
+ errorExit(ast.filename, ast.lineno, "*** commands commence before first target.")
}
ev.lastRule.cmds = append(ev.lastRule.cmds, ast.cmd)
if ev.lastRule.cmdLineno == 0 {
@@ -351,7 +351,7 @@ func (ev *Evaluator) evalInclude(ast *includeAST) {
ev.filename = ast.filename
ev.lineno = ast.lineno
- Logf("%s:%d include %q", ev.filename, ev.lineno, ast.expr)
+ logf("%s:%d include %q", ev.filename, ev.lineno, ast.expr)
v, _, err := parseExpr([]byte(ast.expr), nil, false)
if err != nil {
panic(err)
@@ -381,18 +381,18 @@ func (ev *Evaluator) evalInclude(ast *includeAST) {
mk, hash, err := makefileCache.parse(fn)
if os.IsNotExist(err) {
if ast.op == "include" {
- Error(ev.filename, ev.lineno, fmt.Sprintf("%v\nNOTE: kati does not support generating missing makefiles", err))
+ errorExit(ev.filename, ev.lineno, "%v\nNOTE: kati does not support generating missing makefiles", err)
} else {
msg := ev.cache.update(fn, hash, fileNotExists)
if msg != "" {
- Warn(ev.filename, ev.lineno, "%s", msg)
+ warn(ev.filename, ev.lineno, "%s", msg)
}
continue
}
}
msg := ev.cache.update(fn, hash, fileExists)
if msg != "" {
- Warn(ev.filename, ev.lineno, "%s", msg)
+ warn(ev.filename, ev.lineno, "%s", msg)
}
err = ev.evalIncludeFile(fn, mk)
if err != nil {
@@ -416,7 +416,7 @@ func (ev *Evaluator) evalIf(iast *ifAST) {
freeBuf(buf)
isTrue = (val > 0) == (iast.op == "ifdef")
if LogFlag {
- Logf("%s lhs=%q value=%q => %t", iast.op, iast.lhs, value, isTrue)
+ logf("%s lhs=%q value=%q => %t", iast.op, iast.lhs, value, isTrue)
}
case "ifeq", "ifneq":
lexpr := iast.lhs
@@ -428,7 +428,7 @@ func (ev *Evaluator) evalIf(iast *ifAST) {
freeBuf(buf)
isTrue = (lhs == rhs) == (iast.op == "ifeq")
if LogFlag {
- Logf("%s lhs=%q %q rhs=%q %q => %t", iast.op, iast.lhs, lhs, iast.rhs, rhs, isTrue)
+ logf("%s lhs=%q %q rhs=%q %q => %t", iast.op, iast.lhs, lhs, iast.rhs, rhs, isTrue)
}
default:
panic(fmt.Sprintf("unknown if statement: %q", iast.op))
diff --git a/exec.go b/exec.go
index d81a11d..df66e09 100644
--- a/exec.go
+++ b/exec.go
@@ -141,7 +141,7 @@ func (v autoSuffixFVar) Eval(w io.Writer, ev *Evaluator) {
func (ex *Executor) makeJobs(n *DepNode, neededBy *job) error {
output := n.Output
if neededBy != nil {
- Logf("MakeJob: %s for %s", output, neededBy.n.Output)
+ logf("MakeJob: %s for %s", output, neededBy.n.Output)
}
ex.buildCnt++
if ex.buildCnt%100 == 0 {
@@ -159,7 +159,7 @@ func (ex *Executor) makeJobs(n *DepNode, neededBy *job) error {
neededBy.numDeps--
}
} else {
- Logf("%s already done: %d", j.n.Output, j.outputTs)
+ logf("%s already done: %d", j.n.Output, j.outputTs)
if neededBy != nil {
ex.wm.ReportNewDep(j, neededBy)
}
@@ -189,7 +189,7 @@ func (ex *Executor) makeJobs(n *DepNode, neededBy *job) error {
}
deps = append(deps, d)
}
- Logf("new: %s (%d)", j.n.Output, j.numDeps)
+ logf("new: %s (%d)", j.n.Output, j.numDeps)
for _, d := range deps {
ex.trace = append(ex.trace, d.Output)
@@ -290,7 +290,7 @@ func (ex *Executor) createRunners(n *DepNode, avoidIO bool) ([]runner, bool) {
ev.avoidIO = avoidIO
ev.filename = n.Filename
ev.lineno = n.Lineno
- Logf("Building: %s cmds:%q", n.Output, n.Cmds)
+ logf("Building: %s cmds:%q", n.Output, n.Cmds)
r := runner{
output: n.Output,
echo: true,
diff --git a/func.go b/func.go
index 46de333..8cb59d8 100644
--- a/func.go
+++ b/func.go
@@ -165,7 +165,7 @@ func (f *funcSubst) Eval(w io.Writer, ev *Evaluator) {
from := fargs[0]
to := fargs[1]
text := fargs[2]
- Logf("subst from:%q to:%q text:%q", from, to, text)
+ logf("subst from:%q to:%q text:%q", from, to, text)
w.Write(bytes.Replace(text, from, to, -1))
freeBuf(abuf)
stats.add("funcbody", "subst", t)
@@ -335,10 +335,10 @@ func (f *funcWord) Eval(w io.Writer, ev *Evaluator) {
v := string(trimSpaceBytes(fargs[0]))
index, ok := numericValueForFunc(v)
if !ok {
- Error(ev.filename, ev.lineno, `*** non-numeric first argument to "word" function: %q.`, v)
+ errorExit(ev.filename, ev.lineno, `*** non-numeric first argument to "word" function: %q.`, v)
}
if index == 0 {
- Error(ev.filename, ev.lineno, `*** first argument to "word" function must be greater than 0.`)
+ errorExit(ev.filename, ev.lineno, `*** first argument to "word" function must be greater than 0.`)
}
ws := newWordScanner(fargs[1])
for ws.Scan() {
@@ -363,15 +363,15 @@ func (f *funcWordlist) Eval(w io.Writer, ev *Evaluator) {
v := string(trimSpaceBytes(fargs[0]))
si, ok := numericValueForFunc(v)
if !ok {
- Error(ev.filename, ev.lineno, `*** non-numeric first argument to "wordlist" function: %q.`, v)
+ errorExit(ev.filename, ev.lineno, `*** non-numeric first argument to "wordlist" function: %q.`, v)
}
if si == 0 {
- Error(ev.filename, ev.lineno, `*** invalid first argument to "wordlist" function: %s`, f.args[1])
+ errorExit(ev.filename, ev.lineno, `*** invalid first argument to "wordlist" function: %s`, f.args[1])
}
v = string(trimSpaceBytes(fargs[1]))
ei, ok := numericValueForFunc(v)
if !ok {
- Error(ev.filename, ev.lineno, `*** non-numeric second argument to "wordlist" function: %q.`, v)
+ errorExit(ev.filename, ev.lineno, `*** non-numeric second argument to "wordlist" function: %q.`, v)
}
ws := newWordScanner(fargs[2])
@@ -638,12 +638,12 @@ func (f *funcRealpath) Eval(w io.Writer, ev *Evaluator) {
name := string(ws.Bytes())
name, err := filepath.Abs(name)
if err != nil {
- Logf("abs: %v", err)
+ logf("abs: %v", err)
continue
}
name, err = filepath.EvalSymlinks(name)
if err != nil {
- Logf("realpath: %v", err)
+ logf("realpath: %v", err)
continue
}
sw.WriteString(name)
@@ -666,7 +666,7 @@ func (f *funcAbspath) Eval(w io.Writer, ev *Evaluator) {
name := string(ws.Bytes())
name, err := filepath.Abs(name)
if err != nil {
- Logf("abs: %v", err)
+ logf("abs: %v", err)
continue
}
sw.WriteString(name)
@@ -751,7 +751,7 @@ func hasNoIoInShellScript(s []byte) bool {
if !bytes.HasPrefix(s, []byte("echo $((")) || s[len(s)-1] != ')' {
return false
}
- Logf("has no IO - evaluate now: %s", s)
+ logf("has no IO - evaluate now: %s", s)
return true
}
@@ -775,7 +775,7 @@ func (f *funcShell) Eval(w io.Writer, ev *Evaluator) {
// TODO: Should be Eval, not String.
cmdline := []string{shellVar.String(), "-c", arg}
if LogFlag {
- Logf("shell %q", cmdline)
+ logf("shell %q", cmdline)
}
cmd := exec.Cmd{
Path: cmdline[0],
@@ -786,7 +786,7 @@ func (f *funcShell) Eval(w io.Writer, ev *Evaluator) {
out, err := cmd.Output()
shellStats.add(time.Since(te.t))
if err != nil {
- Logf("$(shell %q) failed: %q", arg, err)
+ logf("$(shell %q) failed: %q", arg, err)
}
w.Write(formatCommandOutput(out))
traceEvent.end(te)
@@ -811,11 +811,11 @@ func (f *funcShell) Compact() Value {
// hack for android
for _, sb := range shBuiltins {
if v, ok := matchExpr(exp, sb.pattern); ok {
- Logf("shell compact apply %s for %s", sb.name, exp)
+ logf("shell compact apply %s for %s", sb.name, exp)
return sb.compact(f, v)
}
}
- Logf("shell compact no match: %s", exp)
+ logf("shell compact no match: %s", exp)
}
return f
}
@@ -832,7 +832,7 @@ func (f *funcCall) Eval(w io.Writer, ev *Evaluator) {
variable := string(varname)
te := traceEvent.begin("call", literal(variable), traceEventMain)
if LogFlag {
- Logf("call %q variable %q", f.args[1], variable)
+ logf("call %q variable %q", f.args[1], variable)
}
v := ev.LookupVar(variable)
// Evalualte all arguments first before we modify the table.
@@ -847,7 +847,7 @@ func (f *funcCall) Eval(w io.Writer, ev *Evaluator) {
// f.args[2]=>args[1] will be $1.
args = append(args, tmpval(arg))
if LogFlag {
- Logf("call $%d: %q=>%q", i+1, arg, fargs[i+1])
+ logf("call $%d: %q=>%q", i+1, arg, fargs[i+1])
}
}
oldParams := ev.paramVars
@@ -861,7 +861,7 @@ func (f *funcCall) Eval(w io.Writer, ev *Evaluator) {
ev.paramVars = oldParams
traceEvent.end(te)
if LogFlag {
- Logf("call %q variable %q return %q", f.args[1], variable, buf.Bytes())
+ logf("call %q variable %q return %q", f.args[1], variable, buf.Bytes())
}
freeBuf(abuf)
}
@@ -885,7 +885,7 @@ func (f *funcEval) Eval(w io.Writer, ev *Evaluator) {
abuf := newBuf()
f.args[1].Eval(abuf, ev)
s := abuf.Bytes()
- Logf("eval %q at %s:%d", s, ev.filename, ev.lineno)
+ logf("eval %q at %s:%d", s, ev.filename, ev.lineno)
mk, err := parseMakefileBytes(s, ev.filename, ev.lineno)
if err != nil {
panic(err)
@@ -917,7 +917,7 @@ func (f *funcEval) Compact() Value {
rhs = append(rhs, rhsprefix)
}
rhs = append(rhs, arg[1:]...)
- Logf("eval assign %#v => lhs:%q op:%q rhs:%#v", f, lhs, op, rhs)
+ logf("eval assign %#v => lhs:%q op:%q rhs:%#v", f, lhs, op, rhs)
return &funcEvalAssign{
lhs: lhs,
op: op,
@@ -1041,7 +1041,7 @@ func (f *funcEvalAssign) Eval(w io.Writer, ev *Evaluator) {
rvalue = &recursiveVar{expr: tmpval(rhs), origin: "file"}
}
if LogFlag {
- Logf("Eval ASSIGN: %s=%q (flavor:%q)", f.lhs, rvalue, rvalue.Flavor())
+ logf("Eval ASSIGN: %s=%q (flavor:%q)", f.lhs, rvalue, rvalue.Flavor())
}
ev.outVars.Assign(f.lhs, rvalue)
}
@@ -1129,7 +1129,7 @@ func (f *funcError) Eval(w io.Writer, ev *Evaluator) {
}
abuf := newBuf()
f.args[1].Eval(abuf, ev)
- Error(ev.filename, ev.lineno, "*** %s.", abuf.String())
+ errorExit(ev.filename, ev.lineno, "*** %s.", abuf.String())
freeBuf(abuf)
}
diff --git a/log.go b/log.go
index 514ff9b..1138b30 100644
--- a/log.go
+++ b/log.go
@@ -23,7 +23,7 @@ import (
var logMu sync.Mutex
-func LogAlways(f string, a ...interface{}) {
+func logAlways(f string, a ...interface{}) {
var buf bytes.Buffer
buf.WriteString("*kati*: ")
buf.WriteString(f)
@@ -37,22 +37,22 @@ func LogStats(f string, a ...interface{}) {
if !LogFlag && !StatsFlag {
return
}
- LogAlways(f, a...)
+ logAlways(f, a...)
}
-func Logf(f string, a ...interface{}) {
+func logf(f string, a ...interface{}) {
if !LogFlag {
return
}
- LogAlways(f, a...)
+ logAlways(f, a...)
}
-func Warn(filename string, lineno int, f string, a ...interface{}) {
+func warn(filename string, lineno int, f string, a ...interface{}) {
f = fmt.Sprintf("%s:%d: warning: %s\n", filename, lineno, f)
fmt.Printf(f, a...)
}
-func WarnNoPrefix(filename string, lineno int, f string, a ...interface{}) {
+func warnNoPrefix(filename string, lineno int, f string, a ...interface{}) {
f = fmt.Sprintf("%s:%d: %s\n", filename, lineno, f)
fmt.Printf(f, a...)
}
@@ -63,12 +63,12 @@ func AtError(f func()) {
atErrors = append(atErrors, f)
}
-func Error(filename string, lineno int, f string, a ...interface{}) {
+func errorExit(filename string, lineno int, f string, a ...interface{}) {
f = fmt.Sprintf("%s:%d: %s", filename, lineno, f)
- ErrorNoLocation(f, a...)
+ errorNoLocationExit(f, a...)
}
-func ErrorNoLocation(f string, a ...interface{}) {
+func errorNoLocationExit(f string, a ...interface{}) {
f = fmt.Sprintf("%s\n", f)
fmt.Printf(f, a...)
for i := len(atErrors) - 1; i >= 0; i-- {
diff --git a/parser.go b/parser.go
index 53f6185..06e5f74 100644
--- a/parser.go
+++ b/parser.go
@@ -193,7 +193,7 @@ func newAssignAST(p *parser, lhsBytes []byte, rhsBytes []byte, op string) *assig
}
func (p *parser) parseAssign(line []byte, sep, esep int) ast {
- Logf("parseAssign %q op:%q", line, line[sep:esep])
+ logf("parseAssign %q op:%q", line, line[sep:esep])
aast := newAssignAST(p, bytes.TrimSpace(line[:sep]), trimLeftSpaceBytes(line[esep:]), string(line[sep:esep]))
aast.filename = p.mk.filename
aast.lineno = p.lineno
@@ -289,7 +289,7 @@ func (p *parser) parseTwoQuotes(s string, op string) ([]string, bool) {
s = s[end+1:]
}
if len(s) > 0 {
- Error(p.mk.filename, p.lineno, `extraneous text after %q directive`, op)
+ errorExit(p.mk.filename, p.lineno, `extraneous text after %q directive`, op)
}
return args, true
}
@@ -327,7 +327,7 @@ func (p *parser) parseIfeq(line string, oplen int) ast {
op := line[:oplen]
lhsBytes, rhsBytes, ok := p.parseEq(strings.TrimSpace(line[oplen+1:]), op)
if !ok {
- Error(p.mk.filename, p.lineno, `*** invalid syntax in conditional.`)
+ errorExit(p.mk.filename, p.lineno, `*** invalid syntax in conditional.`)
}
lhs, _, err := parseExpr([]byte(lhsBytes), nil, true)
@@ -354,7 +354,7 @@ func (p *parser) parseIfeq(line string, oplen int) ast {
func (p *parser) checkIfStack(curKeyword string) {
if len(p.ifStack) == 0 {
- Error(p.mk.filename, p.lineno, `*** extraneous %q.`, curKeyword)
+ errorExit(p.mk.filename, p.lineno, `*** extraneous %q.`, curKeyword)
}
}
@@ -362,7 +362,7 @@ func (p *parser) parseElse(line []byte) {
p.checkIfStack("else")
state := &p.ifStack[len(p.ifStack)-1]
if state.inElse {
- Error(p.mk.filename, p.lineno, `*** only one "else" per conditional.`)
+ errorExit(p.mk.filename, p.lineno, `*** only one "else" per conditional.`)
}
state.inElse = true
p.outStmts = &state.ast.falseStmts
@@ -384,7 +384,7 @@ func (p *parser) parseElse(line []byte) {
return
}
p.numIfNest = 0
- WarnNoPrefix(p.mk.filename, p.lineno, "extraneous text after `else` directive")
+ warnNoPrefix(p.mk.filename, p.lineno, "extraneous text after `else` directive")
}
func (p *parser) parseEndif(line string) {
@@ -561,7 +561,7 @@ func (p *parser) isEndef(s string) bool {
if found >= 0 && s[:found] == "endef" {
rest := strings.TrimSpace(s[found+1:])
if rest != "" && rest[0] != '#' {
- WarnNoPrefix(p.mk.filename, p.lineno, "extraneous text after \"endef\" directive")
+ warnNoPrefix(p.mk.filename, p.lineno, "extraneous text after \"endef\" directive")
}
return true
}
@@ -580,7 +580,7 @@ func (p *parser) parse() (mk makefile, err error) {
if len(p.inDef) > 0 {
lineStr := string(p.processDefineLine(line))
if p.isEndef(lineStr) {
- Logf("multilineAssign %q", p.inDef)
+ logf("multilineAssign %q", p.inDef)
aast := newAssignAST(p, []byte(p.inDef[0]), []byte(strings.Join(p.inDef[1:], "\n")), "=")
aast.filename = p.mk.filename
aast.lineno = p.lineno - len(p.inDef)
@@ -626,7 +626,7 @@ func (p *parser) parse() (mk makefile, err error) {
parenStack = append(parenStack, ch)
case ')', '}':
if len(parenStack) == 0 {
- Warn(p.mk.filename, p.lineno, "Unmatched parens: %s", line)
+ warn(p.mk.filename, p.lineno, "Unmatched parens: %s", line)
} else {
cp := closeParen(parenStack[len(parenStack)-1])
if cp == ch {
@@ -685,7 +685,7 @@ func defaultMakefile() string {
return filename
}
}
- ErrorNoLocation("no targets specified and no makefile found.")
+ errorNoLocationExit("no targets specified and no makefile found.")
panic("") // Cannot be reached.
}
@@ -737,16 +737,16 @@ func (mc *makefileCacheT) lookup(filename string) (makefile, [sha1.Size]byte, bo
}
func (mc *makefileCacheT) parse(filename string) (makefile, [sha1.Size]byte, error) {
- Logf("parse Makefile %q", filename)
+ logf("parse Makefile %q", filename)
mk, hash, ok, err := makefileCache.lookup(filename)
if ok {
if LogFlag {
- Logf("makefile cache hit for %q", filename)
+ logf("makefile cache hit for %q", filename)
}
return mk, hash, err
}
if LogFlag {
- Logf("reading makefile %q", filename)
+ logf("reading makefile %q", filename)
}
c, err := ioutil.ReadFile(filename)
if err != nil {
diff --git a/pathutil.go b/pathutil.go
index 5c5649e..3d4f6bc 100644
--- a/pathutil.go
+++ b/pathutil.go
@@ -176,7 +176,7 @@ func (c *androidFindCacheT) init(prunes []string) {
}
func (c *androidFindCacheT) start(prunes, leafNames []string) {
- Logf("find cache init: prunes=%q leafNames=%q", prunes, leafNames)
+ logf("find cache init: prunes=%q leafNames=%q", prunes, leafNames)
te := traceEvent.begin("findcache", literal("init"), traceEventFindCache)
defer func() {
traceEvent.end(te)
@@ -198,7 +198,7 @@ func (c *androidFindCacheT) start(prunes, leafNames []string) {
if info.IsDir() {
for _, prune := range prunes {
if info.Name() == prune {
- Logf("find cache prune: %s", path)
+ logf("find cache prune: %s", path)
return filepath.SkipDir
}
}
@@ -209,7 +209,7 @@ func (c *androidFindCacheT) start(prunes, leafNames []string) {
}
for _, leaf := range leafNames {
if info.Name() == leaf {
- Logf("find cache leaf: %s", path)
+ logf("find cache leaf: %s", path)
leafch <- fileInfo{
path: path,
mode: info.Mode(),
@@ -220,7 +220,7 @@ func (c *androidFindCacheT) start(prunes, leafNames []string) {
return nil
})
if err != nil && err != filepath.SkipDir {
- Logf("error in adnroid find cache: %v", err)
+ logf("error in adnroid find cache: %v", err)
close(c.filesch)
close(c.leavesch)
return
@@ -253,7 +253,7 @@ func (c *androidFindCacheT) start(prunes, leafNames []string) {
traceEvent.end(leavesTe)
LogStats("%d leaves %d dirs in find cache", nfiles, len(dirs))
for i, leaf := range leaves {
- Logf("android findleaves cache: %d: %s %v", i, leaf.path, leaf.mode)
+ logf("android findleaves cache: %d: %s %v", i, leaf.path, leaf.mode)
}
}()
@@ -268,20 +268,20 @@ func (c *androidFindCacheT) start(prunes, leafNames []string) {
traceEvent.end(filesTe)
LogStats("%d files in find cache", len(files))
for i, fi := range files {
- Logf("android find cache: %d: %s %v", i, fi.path, fi.mode)
+ logf("android find cache: %d: %s %v", i, fi.path, fi.mode)
}
}()
curdir, err := os.Open(".")
if err != nil {
- Logf("open . failed: %v", err)
+ logf("open . failed: %v", err)
close(c.filesch)
close(c.leavesch)
return
}
names, err := curdir.Readdirnames(-1)
if err != nil {
- Logf("readdir . failed: %v", err)
+ logf("readdir . failed: %v", err)
close(c.filesch)
close(c.leavesch)
return
@@ -334,7 +334,7 @@ func (c *androidFindCacheT) walk(dir string, walkFn func(int, fileInfo) error) e
i := sort.Search(len(c.files), func(i int) bool {
return c.files[i].path >= dir
})
- Logf("android find in dir cache: %s i=%d/%d", dir, i, len(c.files))
+ logf("android find in dir cache: %s i=%d/%d", dir, i, len(c.files))
start := i
var skipdirs []string
Loop:
@@ -347,7 +347,7 @@ Loop:
continue
}
if !strings.HasPrefix(c.files[i].path, dir) {
- Logf("android find in dir cache: %s end=%d/%d", dir, i, len(c.files))
+ logf("android find in dir cache: %s end=%d/%d", dir, i, len(c.files))
return nil
}
if !strings.HasPrefix(c.files[i].path, dir+"/") {
@@ -361,7 +361,7 @@ Loop:
err := walkFn(i, c.files[i])
if err == errSkipDir {
- Logf("android find in skip dir: %s", c.files[i].path)
+ logf("android find in skip dir: %s", c.files[i].path)
skipdirs = append(skipdirs, c.files[i].path)
continue
}
@@ -377,7 +377,7 @@ Loop:
// if [ -d $1 ] ; then cd $1 ; find ./ -not -name '.*' -and -type f -and -not -type l ; fi
func (c *androidFindCacheT) findInDir(sw *ssvWriter, dir string) {
dir = filepath.Clean(dir)
- Logf("android find in dir cache: %s", dir)
+ logf("android find in dir cache: %s", dir)
c.walk(dir, func(_ int, fi fileInfo) error {
// -not -name '.*'
if strings.HasPrefix(filepath.Base(fi.path), ".") {
@@ -391,7 +391,7 @@ func (c *androidFindCacheT) findInDir(sw *ssvWriter, dir string) {
name := strings.TrimPrefix(fi.path, dir+"/")
name = "./" + name
sw.WriteString(name)
- Logf("android find in dir cache: %s=> %s", dir, name)
+ logf("android find in dir cache: %s=> %s", dir, name)
return nil
})
}
@@ -403,12 +403,12 @@ func (c *androidFindCacheT) findInDir(sw *ssvWriter, dir string) {
func (c *androidFindCacheT) findExtFilesUnder(sw *ssvWriter, chdir, root, ext string) bool {
chdir = filepath.Clean(chdir)
dir := filepath.Join(chdir, root)
- Logf("android find %s in dir cache: %s %s", ext, chdir, root)
+ logf("android find %s in dir cache: %s %s", ext, chdir, root)
// check symlinks
var matches []int
err := c.walk(dir, func(i int, fi fileInfo) error {
if fi.mode&os.ModeSymlink == os.ModeSymlink {
- Logf("android find %s in dir cache: detect symlink %s %v", ext, c.files[i].path, c.files[i].mode)
+ logf("android find %s in dir cache: detect symlink %s %v", ext, c.files[i].path, c.files[i].mode)
return fmt.Errorf("symlink %s", fi.path)
}
matches = append(matches, i)
@@ -431,7 +431,7 @@ func (c *androidFindCacheT) findExtFilesUnder(sw *ssvWriter, chdir, root, ext st
}
name := strings.TrimPrefix(fi.path, chdir+"/")
sw.WriteString(name)
- Logf("android find %s in dir cache: %s=> %s", ext, dir, name)
+ logf("android find %s in dir cache: %s=> %s", ext, dir, name)
}
return true
}
@@ -443,7 +443,7 @@ func (c *androidFindCacheT) findExtFilesUnder(sw *ssvWriter, chdir, root, ext st
// -name "overview.html" -a \! -name ".*.swp" -a \! -name ".DS_Store" \
// -a \! -name "*~" -print )
func (c *androidFindCacheT) findJavaResourceFileGroup(sw *ssvWriter, dir string) {
- Logf("android find java resource in dir cache: %s", dir)
+ logf("android find java resource in dir cache: %s", dir)
c.walk(filepath.Clean(dir), func(_ int, fi fileInfo) error {
// -type d -a -name ".svn" -prune
if fi.mode.IsDir() && filepath.Base(fi.path) == ".svn" {
@@ -468,7 +468,7 @@ func (c *androidFindCacheT) findJavaResourceFileGroup(sw *ssvWriter, dir string)
name := strings.TrimPrefix(fi.path, dir+"/")
name = "./" + name
sw.WriteString(name)
- Logf("android find java resource in dir cache: %s=> %s", dir, name)
+ logf("android find java resource in dir cache: %s=> %s", dir, name)
return nil
})
}
@@ -485,7 +485,7 @@ func (c *androidFindCacheT) findleaves(sw *ssvWriter, dir, name string, prunes [
dir = ""
}
depth := strings.Count(dir, "/")
- // Logf("android findleaves dir=%q depth=%d dirs=%q", dir, depth, dirs)
+ // logf("android findleaves dir=%q depth=%d dirs=%q", dir, depth, dirs)
i := sort.Search(len(c.leaves), func(i int) bool {
di := strings.Count(c.leaves[i].path, "/")
if di != depth {
@@ -497,7 +497,7 @@ func (c *androidFindCacheT) findleaves(sw *ssvWriter, dir, name string, prunes [
}
return c.leaves[i].path >= dir
})
- Logf("android findleaves dir=%q i=%d/%d", dir, i, len(c.leaves))
+ logf("android findleaves dir=%q i=%d/%d", dir, i, len(c.leaves))
Scandir:
for ; i < len(c.leaves); i++ {
@@ -511,7 +511,7 @@ func (c *androidFindCacheT) findleaves(sw *ssvWriter, dir, name string, prunes [
if !c.leaves[i].mode.IsDir() && filepath.Base(c.leaves[i].path) == name {
n := "./" + c.leaves[i].path
found = append(found, n)
- Logf("android findleaves name=%s=> %s (depth=%d topdepth=%d mindepth=%d)", name, n, depth, topdepth, mindepth)
+ logf("android findleaves name=%s=> %s (depth=%d topdepth=%d mindepth=%d)", name, n, depth, topdepth, mindepth)
break Scandir
}
}
@@ -519,9 +519,9 @@ func (c *androidFindCacheT) findleaves(sw *ssvWriter, dir, name string, prunes [
dirs = append(dirs, c.leaves[i].path)
}
}
- // Logf("android findleaves next dirs=%q", dirs)
+ // logf("android findleaves next dirs=%q", dirs)
}
- Logf("android findleave done")
+ logf("android findleave done")
sort.Strings(found)
for _, f := range found {
sw.WriteString(f)
diff --git a/serialize.go b/serialize.go
index 9a18062..f97eb8c 100644
--- a/serialize.go
+++ b/serialize.go
@@ -604,7 +604,7 @@ func LoadDepGraphCache(makefile string, roots []string) *DepGraph {
filename := cacheFilename(makefile, roots)
if !exists(filename) {
- LogAlways("Cache not found")
+ logAlways("Cache not found")
return nil
}
@@ -615,23 +615,23 @@ func LoadDepGraphCache(makefile string, roots []string) *DepGraph {
}
if mk.State == fileNotExists {
if exists(mk.Filename) {
- LogAlways("Cache expired: %s", mk.Filename)
+ logAlways("Cache expired: %s", mk.Filename)
return nil
}
} else {
c, err := ioutil.ReadFile(mk.Filename)
if err != nil {
- LogAlways("Cache expired: %s", mk.Filename)
+ logAlways("Cache expired: %s", mk.Filename)
return nil
}
h := sha1.Sum(c)
if !bytes.Equal(h[:], mk.Hash[:]) {
- LogAlways("Cache expired: %s", mk.Filename)
+ logAlways("Cache expired: %s", mk.Filename)
return nil
}
}
}
g.isCached = true
- LogAlways("Cache found!")
+ logAlways("Cache found!")
return g
}
diff --git a/shellutil.go b/shellutil.go
index 71fd620..71a6d4e 100644
--- a/shellutil.go
+++ b/shellutil.go
@@ -274,14 +274,14 @@ func (f *funcShellAndroidFindFileInDir) Eval(w io.Writer, ev *Evaluator) {
fargs := ev.args(abuf, f.dir)
dir := string(trimSpaceBytes(fargs[0]))
freeBuf(abuf)
- Logf("shellAndroidFindFileInDir %s => %s", f.dir.String(), dir)
+ logf("shellAndroidFindFileInDir %s => %s", f.dir.String(), dir)
if strings.Contains(dir, "..") {
- Logf("shellAndroidFindFileInDir contains ..: call original shell")
+ logf("shellAndroidFindFileInDir contains ..: call original shell")
f.funcShell.Eval(w, ev)
return
}
if !androidFindCache.ready() {
- Logf("shellAndroidFindFileInDir androidFindCache is not ready: call original shell")
+ logf("shellAndroidFindFileInDir androidFindCache is not ready: call original shell")
f.funcShell.Eval(w, ev)
return
}
@@ -311,14 +311,14 @@ func (f *funcShellAndroidFindExtFilesUnder) Eval(w io.Writer, ev *Evaluator) {
roots = append(roots, string(ws.Bytes()))
}
freeBuf(abuf)
- Logf("shellAndroidFindExtFilesUnder %s,%s => %s,%s", f.chdir.String(), f.roots.String(), chdir, roots)
+ logf("shellAndroidFindExtFilesUnder %s,%s => %s,%s", f.chdir.String(), f.roots.String(), chdir, roots)
if strings.Contains(chdir, "..") || hasDotDot {
- Logf("shellAndroidFindExtFilesUnder contains ..: call original shell")
+ logf("shellAndroidFindExtFilesUnder contains ..: call original shell")
f.funcShell.Eval(w, ev)
return
}
if !androidFindCache.ready() {
- Logf("shellAndroidFindExtFilesUnder androidFindCache is not ready: call original shell")
+ logf("shellAndroidFindExtFilesUnder androidFindCache is not ready: call original shell")
f.funcShell.Eval(w, ev)
return
}
@@ -327,7 +327,7 @@ func (f *funcShellAndroidFindExtFilesUnder) Eval(w io.Writer, ev *Evaluator) {
for _, root := range roots {
if !androidFindCache.findExtFilesUnder(&sw, chdir, root, f.ext) {
freeBuf(buf)
- Logf("shellAndroidFindExtFilesUnder androidFindCache couldn't handle: call original shell")
+ logf("shellAndroidFindExtFilesUnder androidFindCache couldn't handle: call original shell")
f.funcShell.Eval(w, ev)
return
}
@@ -346,14 +346,14 @@ func (f *funcShellAndroidFindJavaResourceFileGroup) Eval(w io.Writer, ev *Evalua
fargs := ev.args(abuf, f.dir)
dir := string(trimSpaceBytes(fargs[0]))
freeBuf(abuf)
- Logf("shellAndroidFindJavaResourceFileGroup %s => %s", f.dir.String(), dir)
+ logf("shellAndroidFindJavaResourceFileGroup %s => %s", f.dir.String(), dir)
if strings.Contains(dir, "..") {
- Logf("shellAndroidFindJavaResourceFileGroup contains ..: call original shell")
+ logf("shellAndroidFindJavaResourceFileGroup contains ..: call original shell")
f.funcShell.Eval(w, ev)
return
}
if !androidFindCache.ready() {
- Logf("shellAndroidFindJavaResourceFileGroup androidFindCache is not ready: call original shell")
+ logf("shellAndroidFindJavaResourceFileGroup androidFindCache is not ready: call original shell")
f.funcShell.Eval(w, ev)
return
}
@@ -371,7 +371,7 @@ type funcShellAndroidFindleaves struct {
func (f *funcShellAndroidFindleaves) Eval(w io.Writer, ev *Evaluator) {
if !androidFindCache.leavesReady() {
- Logf("shellAndroidFindleaves androidFindCache is not ready: call original shell")
+ logf("shellAndroidFindleaves androidFindCache is not ready: call original shell")
f.funcShell.Eval(w, ev)
return
}
@@ -387,7 +387,7 @@ func (f *funcShellAndroidFindleaves) Eval(w io.Writer, ev *Evaluator) {
for ws.Scan() {
dir := string(ws.Bytes())
if strings.Contains(dir, "..") {
- Logf("shellAndroidFindleaves contains .. in %s: call original shell", dir)
+ logf("shellAndroidFindleaves contains .. in %s: call original shell", dir)
f.funcShell.Eval(w, ev)
return
}
diff --git a/strutil.go b/strutil.go
index d3b3792..f5f1eb4 100644
--- a/strutil.go
+++ b/strutil.go
@@ -48,7 +48,7 @@ func splitSpaces(s string) []string {
if tokStart >= 0 {
r = append(r, s[tokStart:])
}
- Logf("splitSpace(%q)=%q", s, r)
+ logf("splitSpace(%q)=%q", s, r)
return r
}
@@ -69,7 +69,7 @@ func splitSpacesBytes(s []byte) (r [][]byte) {
if tokStart >= 0 {
r = append(r, s[tokStart:])
}
- Logf("splitSpace(%q)=%q", s, r)
+ logf("splitSpace(%q)=%q", s, r)
return r
}
diff --git a/worker.go b/worker.go
index ff4689f..8948ac6 100644
--- a/worker.go
+++ b/worker.go
@@ -215,11 +215,11 @@ func (j *job) build() {
return
}
if len(j.parents) == 0 {
- ErrorNoLocation("*** No rule to make target %q.", j.n.Output)
+ errorNoLocationExit("*** No rule to make target %q.", j.n.Output)
} else {
- ErrorNoLocation("*** No rule to make target %q, needed by %q.", j.n.Output, j.parents[0].n.Output)
+ errorNoLocationExit("*** No rule to make target %q, needed by %q.", j.n.Output, j.parents[0].n.Output)
}
- ErrorNoLocation("no rule to make target %q", j.n.Output)
+ errorNoLocationExit("no rule to make target %q", j.n.Output)
}
if j.outputTs >= j.depsTs {
@@ -231,7 +231,7 @@ func (j *job) build() {
err := r.run(j.n.Output)
if err != nil {
exit := exitStatus(err)
- ErrorNoLocation("[%s] Error %d: %v", j.n.Output, exit, err)
+ errorNoLocationExit("[%s] Error %d: %v", j.n.Output, exit, err)
}
}
@@ -254,7 +254,7 @@ func (wm *workerManager) handleJobs() {
return
}
j := heap.Pop(&wm.readyQueue).(*job)
- Logf("run: %s", j.n.Output)
+ logf("run: %s", j.n.Output)
if wm.para != nil {
j.runners = j.createRunners()
@@ -278,7 +278,7 @@ func (wm *workerManager) handleJobs() {
func (wm *workerManager) updateParents(j *job) {
for _, p := range j.parents {
p.numDeps--
- Logf("child: %s (%d)", p.n.Output, p.numDeps)
+ logf("child: %s (%d)", p.n.Output, p.numDeps)
if p.depsTs < j.outputTs {
p.depsTs = j.outputTs
}
@@ -356,7 +356,7 @@ func (wm *workerManager) maybePushToReadyQueue(j *job) {
return
}
heap.Push(&wm.readyQueue, j)
- Logf("ready: %s", j.n.Output)
+ logf("ready: %s", j.n.Output)
}
func (wm *workerManager) handleNewDep(j *job, neededBy *job) {
@@ -375,19 +375,19 @@ func (wm *workerManager) Run() {
for wm.hasTodo() || len(wm.busyWorkers) > 0 || len(wm.runnings) > 0 || !done {
select {
case j := <-wm.jobChan:
- Logf("wait: %s (%d)", j.n.Output, j.numDeps)
+ logf("wait: %s (%d)", j.n.Output, j.numDeps)
j.id = len(wm.jobs) + 1
wm.jobs = append(wm.jobs, j)
wm.maybePushToReadyQueue(j)
case jr := <-wm.resultChan:
- Logf("done: %s", jr.j.n.Output)
+ logf("done: %s", jr.j.n.Output)
delete(wm.busyWorkers, jr.w)
wm.freeWorkers = append(wm.freeWorkers, jr.w)
wm.updateParents(jr.j)
wm.finishCnt++
case af := <-wm.newDepChan:
wm.handleNewDep(af.j, af.neededBy)
- Logf("dep: %s (%d) %s", af.neededBy.n.Output, af.neededBy.numDeps, af.j.n.Output)
+ logf("dep: %s (%d) %s", af.neededBy.n.Output, af.neededBy.numDeps, af.j.n.Output)
case pr := <-wm.paraChan:
if pr.status < 0 && pr.signal < 0 {
j := wm.runnings[pr.output]
@@ -413,14 +413,14 @@ func (wm *workerManager) Run() {
if numBusy > wm.maxJobs {
numBusy = wm.maxJobs
}
- Logf("job=%d ready=%d free=%d busy=%d", len(wm.jobs)-wm.finishCnt, wm.readyQueue.Len(), wm.maxJobs-numBusy, numBusy)
+ logf("job=%d ready=%d free=%d busy=%d", len(wm.jobs)-wm.finishCnt, wm.readyQueue.Len(), wm.maxJobs-numBusy, numBusy)
} else {
- Logf("job=%d ready=%d free=%d busy=%d", len(wm.jobs)-wm.finishCnt, wm.readyQueue.Len(), len(wm.freeWorkers), len(wm.busyWorkers))
+ logf("job=%d ready=%d free=%d busy=%d", len(wm.jobs)-wm.finishCnt, wm.readyQueue.Len(), len(wm.freeWorkers), len(wm.busyWorkers))
}
}
if wm.para != nil {
- Logf("Wait for para to finish")
+ logf("Wait for para to finish")
wm.para.Wait()
} else {
for _, w := range wm.freeWorkers {