Skip to content

Commit

Permalink
Parameterized goals #115
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Jan 26, 2023
1 parent 175fb1f commit 6fb3bce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 14 additions & 12 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -260,23 +260,25 @@ function parsePriv() { if ("@private" != $NF) return 0; NF--; return 1 }
function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax) {
started("goal_glob")
priv = parsePriv()
if ("@glob" == goalName = $2) {
if ("@glob" == (goalName = $2)) {
goalName = ""; pattern = $(nfMax=3)
} else
pattern = $(nfMax=4)
if (NF > nfMax) {
if (NF > nfMax)
addError("nothing allowed after glob pattern")
return
}
calcGlob(goalName, pattern)
globAllGoal = goalName ? goalName : pattern
globSingle = GlobCnt == 1 && globAllGoal == globGoal(0)
for (i=0; i < GlobCnt; i++)
registerGoal(globSingle ? priv : 1, globGoal(i))
if (!globSingle) { # glob on single file
registerGoal(priv, globAllGoal)
else if (pattern=="")
addError("absent glob pattern")
else {
calcGlob(goalName, pattern)
globAllGoal = goalName ? goalName : pattern
globSingle = GlobCnt == 1 && globAllGoal == globGoal(0)
for (i=0; i < GlobCnt; i++)
registerDependency(globAllGoal, globGoal(i))
registerGoal(globSingle ? priv : 1, globGoal(i))
if (!globSingle) { # glob on single file
registerGoal(priv, globAllGoal)
for (i=0; i < GlobCnt; i++)
registerDependency(globAllGoal, globGoal(i))
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/12_errors.tush
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/12_errors.sh
@ tests/12_errors.sh:57: @goal @glob '*.txt' should not have anything after glob pattern
@ nothing allowed after glob pattern:
@ tests/12_errors.sh:58: @goal @glob '*.txt' should_not_have_anything_after_glob_pattern
@ absent glob pattern:
@ tests/12_errors.sh:61: @goal @glob # absent glob pattern
@ absent glob pattern:
@ tests/12_errors.sh:62: @goal g19 @glob # absent glob pattern
@ Goal 'g1' has unknown dependency 'unknown':
@ tests/12_errors.sh:18: @depends_on unknown
@ Goal 'g2' uses unknown lib 'unknown':
Expand Down

0 comments on commit 6fb3bce

Please sign in to comment.