From a24cd2d3c815a621d1363729ed7f9d45918a164d Mon Sep 17 00:00:00 2001 From: xonix Date: Fri, 17 Sep 2021 15:49:21 +0300 Subject: [PATCH 1/3] Optimize goals execution #48 --- tests/20_optimize_goals.sh | 6 ++++++ tests/20_optimize_goals.tush | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 tests/20_optimize_goals.sh create mode 100644 tests/20_optimize_goals.tush diff --git a/tests/20_optimize_goals.sh b/tests/20_optimize_goals.sh new file mode 100644 index 0000000..0ce1c40 --- /dev/null +++ b/tests/20_optimize_goals.sh @@ -0,0 +1,6 @@ + +@goal hello + echo "Hello world" + +@goal hello_empty +@depends_on hello \ No newline at end of file diff --git a/tests/20_optimize_goals.tush b/tests/20_optimize_goals.tush new file mode 100644 index 0000000..8654827 --- /dev/null +++ b/tests/20_optimize_goals.tush @@ -0,0 +1,6 @@ + +$ cd "$MYDIR"; PATH=tests/wrapper/bash:$PATH ./$MAKESURE -f tests/20_optimize_goals.sh hello_empty +| running bash +| goal 'hello' ... +| Hello world +| goal 'hello_empty' [empty]. From f2116fffe0fd49238c252f9dbeccd8beb54ab34a Mon Sep 17 00:00:00 2001 From: xonix Date: Fri, 17 Sep 2021 16:02:01 +0300 Subject: [PATCH 2/3] Optimize goals execution #48 --- makesure.awk | 30 +++++++++++++++++------------- tests/20_optimize_goals.tush | 2 +- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/makesure.awk b/makesure.awk index 94ad78e..65d42c2 100755 --- a/makesure.awk +++ b/makesure.awk @@ -391,18 +391,18 @@ 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") + # 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) @@ -428,7 +428,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) { diff --git a/tests/20_optimize_goals.tush b/tests/20_optimize_goals.tush index 8654827..22fdfac 100644 --- a/tests/20_optimize_goals.tush +++ b/tests/20_optimize_goals.tush @@ -1,6 +1,6 @@ $ cd "$MYDIR"; PATH=tests/wrapper/bash:$PATH ./$MAKESURE -f tests/20_optimize_goals.sh hello_empty -| running bash | goal 'hello' ... +| running bash | Hello world | goal 'hello_empty' [empty]. From f7e4b3ee7d67a0b164ef1ff3a9ba07d6ad8cb446 Mon Sep 17 00:00:00 2001 From: xonix Date: Fri, 17 Sep 2021 16:05:31 +0300 Subject: [PATCH 3/3] Optimize goals execution #48 --- makesure.awk | 13 ------------- tests/18_empty_prelude.tush | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/makesure.awk b/makesure.awk index 65d42c2..2627969 100755 --- a/makesure.awk +++ b/makesure.awk @@ -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]]) diff --git a/tests/18_empty_prelude.tush b/tests/18_empty_prelude.tush index cdbd08e..36e94eb 100644 --- a/tests/18_empty_prelude.tush +++ b/tests/18_empty_prelude.tush @@ -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