Skip to content

Commit

Permalink
Improvement to @goal @glob #46
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Sep 19, 2021
1 parent 98e9975 commit 67fffee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
19 changes: 13 additions & 6 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -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])
}
Expand Down
8 changes: 4 additions & 4 deletions tests/11_goal_glob.tush
Original file line number Diff line number Diff line change
Expand Up @@ -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].

0 comments on commit 67fffee

Please sign in to comment.