Skip to content

Commit

Permalink
Merge pull request #49 from xonixx/optimize-goals
Browse files Browse the repository at this point in the history
Optimize goals
  • Loading branch information
xonixx authored Sep 17, 2021
2 parents 60bf4a0 + f7e4b3e commit 639f36e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
19 changes: 5 additions & 14 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -391,19 +391,6 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
}

goalBody[0] = ""
if (!("silent" in Options)) {
addStr(goalBody, "echo \" goal '" goalName "' ")
if (reachedGoals[goalName])
addStr(goalBody, "[already satisfied].")
else if (emptyGoals[goalName])
addStr(goalBody, "[empty].")
else
addStr(goalBody, "...")
addStr(goalBody, "\"")
}
if (reachedGoals[goalName])
addLine(goalBody, "exit 0")

addLine(goalBody, definesLine[0])
if (goalName in GoalToLib)
addLine(goalBody, Lib[GoalToLib[goalName]])
Expand All @@ -428,7 +415,11 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
goalTimed = "timing" in Options && !reachedGoals[goalName] && !emptyGoals[goalName]
if (goalTimed)
t1 = t2 ? t2 : currentTimeMillis()
exitCode = shellExec(goalBodies[goalName])

if (!("silent" in Options))
print " goal '" goalName "' " (reachedGoals[goalName] ? "[already satisfied]." : emptyGoals[goalName] ? "[empty]." : "...")

exitCode = (reachedGoals[goalName] || emptyGoals[goalName]) ? 0 : shellExec(goalBodies[goalName])
if (exitCode != 0)
print " goal '" goalName "' failed"
if (goalTimed) {
Expand Down
2 changes: 1 addition & 1 deletion tests/18_empty_prelude.tush
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

$ cd "$MYDIR"; PATH=tests/wrapper/bash:$PATH ./$MAKESURE -f tests/18_empty_prelude.sh
| running bash
| goal 'default' ...
| running bash
| hello
6 changes: 6 additions & 0 deletions tests/20_optimize_goals.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

@goal hello
echo "Hello world"

@goal hello_empty
@depends_on hello
6 changes: 6 additions & 0 deletions tests/20_optimize_goals.tush
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

$ cd "$MYDIR"; PATH=tests/wrapper/bash:$PATH ./$MAKESURE -f tests/20_optimize_goals.sh hello_empty
| goal 'hello' ...
| running bash
| Hello world
| goal 'hello_empty' [empty].

0 comments on commit 639f36e

Please sign in to comment.