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 22, 2023
1 parent 346eff6 commit a9c4fb3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
8 changes: 7 additions & 1 deletion docs/parameterized_goals.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,10 @@ On encounter `@depends_on` generate instantiated? But this needs to go in-depth.
### PG + @glob
TODO
### PG + @private
TODO
TODO
### PG + @lib
TODO
### PG + @reached_if
TODO
### PG + @doc
TODO
19 changes: 17 additions & 2 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,14 @@ function instantiateGoals( i,l,goalName) {
for (i = 0; i < l; i++)
if (GoalParamsCnt[goalName = GoalNames[i]] == 0)
instantiate(goalName)
# should not be possible to list or invoke (non-instantiated) parameterized goals, so let's remove them
for (goalName in GoalsByName)
if (GoalParamsCnt[goalName] > 0) {
arrDel(GoalNames, goalName)
delete GoalsByName[goalName]
}
}
#function renderArgs(args, s,k) { s = ""; for (k in args) s = s k "=>" args[k] " "; return s }
function copyKey(keySrc,keyDst,arr) { if (keySrc in arr) arr[keyDst] = arr[keySrc] }
#
# args: { F => "file1" }
#
Expand Down Expand Up @@ -856,10 +861,20 @@ function addLine(target, line) { target[0] = addL(target[0], line) }
function addL(s, l) { return s ? s "\n" l : l }
function arrPush(arr, elt) { arr[arr[-7]++] = elt }
function arrLen(arr) { return +arr[-7] }
function arrDel(arr, v, l,i,e,resArr) {
l = arrLen(arr)
for (i=0; i<l; i++)
if (v!=(e=arr[i]))
arrPush(resArr,e)
split("",arr)
for (i in resArr)
arr[i] = resArr[i]
}
function arrLast(arr, l) { return (l = arrLen(arr))>0 ? arr[l-1] : "" }
function commandExists(cmd) { return ok("command -v " cmd " >/dev/null") }
function ok(cmd) { return system(cmd) == 0 }
function isFile(path) { return ok("test -f " quoteArg(path)) }
function rm(f) { system("rm " quoteArg(f)) }
function quoteArg(a) { gsub("'", "'\\''", a); return "'" a "'" }
function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s }
function copyKey(keySrc,keyDst,arr) { if (keySrc in arr) arr[keyDst] = arr[keySrc] }
22 changes: 22 additions & 0 deletions tests/27_parameterized_goals.tush
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

$ cd "$MYDIR"; ./$MAKESURE -f tests/27_parameterized_goals_1.sh -l
| Available goals:
| a
| b@hello

$ cd "$MYDIR"; ./$MAKESURE -f tests/27_parameterized_goals_1.sh -la
| Available goals:
| a
| b@hello

$ cd "$MYDIR"; ./$MAKESURE -f tests/27_parameterized_goals_2.sh -l
| Available goals:
| a
| b@hello
| c@hello

$ cd "$MYDIR"; ./$MAKESURE -f tests/27_parameterized_goals_2.sh -la
| Available goals:
| a
| b@hello
| c@hello

0 comments on commit a9c4fb3

Please sign in to comment.