From 67fffee0c2ff9dabcea131888a9a110f62124497 Mon Sep 17 00:00:00 2001 From: xonix Date: Sun, 19 Sep 2021 16:48:12 +0300 Subject: [PATCH] Improvement to `@goal @glob` #46 --- makesure.awk | 19 +++++++++++++------ tests/11_goal_glob.tush | 8 ++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/makesure.awk b/makesure.awk index 5b39635..5ac7dd6 100755 --- a/makesure.awk +++ b/makesure.awk @@ -236,7 +236,7 @@ function parseGoalLine( priv) { return priv } -function handleGoalGlob( goalName,globAllGoal,g,priv,i,pattern) { +function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern) { started("goal_glob") priv = parseGoalLine() goalName = $2; $2 = "" @@ -245,19 +245,26 @@ function handleGoalGlob( goalName,globAllGoal,g,priv,i,pattern) { } else $3 = "" calcGlob(goalName, pattern = trim($0)) globAllGoal = goalName ? goalName : pattern + globSingle = arrLen(GlobGoals) == 1 && globAllGoal == GlobGoals[0] for (i=0; i in GlobGoals; i++){ - registerDependency(globAllGoal, g = GlobGoals[i]) - registerGoal(g, 1) + registerGoal(GlobGoals[i], globSingle ? priv : 1) } + if (globSingle) # glob on single file + return registerGoal(globAllGoal, priv) + for (i=0; i in GlobGoals; i++){ + registerDependency(globAllGoal, GlobGoals[i]) + } } function handleDoc( i) { checkGoalOnly() - registerDoc(currentGoalName()) - - if ("goal_glob" == Mode) { + if ("goal" == Mode) { + registerDoc(currentGoalName()) + } else { + if (!(arrLen(GlobGoals) == 1 && currentGoalName() == GlobGoals[0])) # glob on single file + registerDoc(currentGoalName()) for (i=0; i in GlobGoals; i++){ registerDoc(GlobGoals[i]) } diff --git a/tests/11_goal_glob.tush b/tests/11_goal_glob.tush index fca4e52..c037ff2 100644 --- a/tests/11_goal_glob.tush +++ b/tests/11_goal_glob.tush @@ -33,17 +33,17 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh -d '11_goal_glob*.txt' $ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh test1 | goal '11_goal_glob_1.txt' ... -| 11_goal_glob_1.txt :: 0 :: 3 +| 11_goal_glob_1.txt :: 0 :: 4 | content 111 | goal '11_goal_glob_2.txt' [already satisfied]. | goal '11_goal_glob_3.txt' ... -| 11_goal_glob_3.txt :: 2 :: 3 +| 11_goal_glob_3.txt :: 2 :: 4 | content 333 | goal 'test1' [empty]. $ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh test2 | goal 'goal_name@11_goal_glob_2.txt' ... -| goal_name ::: 11_goal_glob_2.txt :: 1 :: 3 +| goal_name ::: 11_goal_glob_2.txt :: 1 :: 4 | goal 'goal_name@11_goal_glob_3.txt' ... -| goal_name ::: 11_goal_glob_3.txt :: 2 :: 3 +| goal_name ::: 11_goal_glob_3.txt :: 2 :: 4 | goal 'test2' [empty].