From 2d8ebb010abf21c2b1f5ecc070dbbcc2bc61335f Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 3 Jan 2024 19:29:11 +0200 Subject: [PATCH 1/9] Allow @glob goals to be parameterized #155 : add tests --- tests/29_glob_plus_pg.sh | 16 ++++++++++++++++ tests/29_glob_plus_pg.tush | 8 ++++++++ tests/glob_test/1.txt | 1 + tests/glob_test/2.txt | 1 + 4 files changed, 26 insertions(+) create mode 100644 tests/29_glob_plus_pg.sh create mode 100644 tests/29_glob_plus_pg.tush create mode 100644 tests/glob_test/1.txt create mode 100644 tests/glob_test/2.txt diff --git a/tests/29_glob_plus_pg.sh b/tests/29_glob_plus_pg.sh new file mode 100644 index 0000000..2b2abdf --- /dev/null +++ b/tests/29_glob_plus_pg.sh @@ -0,0 +1,16 @@ + +@goal gpg @glob 'glob_test/*.txt' @params P + echo "$ITEM $P" + +@goal g1 +@depends_on gpg @args 'hello' + +@goal g2 +@depends_on gpg @args 'hello' +@depends_on gpg @args 'hi' + +@goal g3 +@depends_on g3pg @args 'salut' + +@goal g3pg @params X +@depends_on gpg @args X diff --git a/tests/29_glob_plus_pg.tush b/tests/29_glob_plus_pg.tush new file mode 100644 index 0000000..66e9026 --- /dev/null +++ b/tests/29_glob_plus_pg.tush @@ -0,0 +1,8 @@ + +$ cd "$MYDIR"; ./$MAKESURE -f tests/29_glob_plus_pg.sh -l + +$ cd "$MYDIR"; ./$MAKESURE -f tests/29_glob_plus_pg.sh g1 + +$ cd "$MYDIR"; ./$MAKESURE -f tests/29_glob_plus_pg.sh g2 + +$ cd "$MYDIR"; ./$MAKESURE -f tests/29_glob_plus_pg.sh g3 diff --git a/tests/glob_test/1.txt b/tests/glob_test/1.txt new file mode 100644 index 0000000..9d07aa0 --- /dev/null +++ b/tests/glob_test/1.txt @@ -0,0 +1 @@ +111 \ No newline at end of file diff --git a/tests/glob_test/2.txt b/tests/glob_test/2.txt new file mode 100644 index 0000000..6dd90d2 --- /dev/null +++ b/tests/glob_test/2.txt @@ -0,0 +1 @@ +222 \ No newline at end of file From 6b60186a1248e0ab6c8b385c076710f9cdbcde4a Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 3 Jan 2024 19:35:03 +0200 Subject: [PATCH 2/9] rm unnecessary `cd "$MYDIR"` from all tests --- tests/29_glob_plus_pg.tush | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/29_glob_plus_pg.tush b/tests/29_glob_plus_pg.tush index 66e9026..a29dd11 100644 --- a/tests/29_glob_plus_pg.tush +++ b/tests/29_glob_plus_pg.tush @@ -1,8 +1,8 @@ -$ cd "$MYDIR"; ./$MAKESURE -f tests/29_glob_plus_pg.sh -l +$ ./$MAKESURE -f tests/29_glob_plus_pg.sh -l -$ cd "$MYDIR"; ./$MAKESURE -f tests/29_glob_plus_pg.sh g1 +$ ./$MAKESURE -f tests/29_glob_plus_pg.sh g1 -$ cd "$MYDIR"; ./$MAKESURE -f tests/29_glob_plus_pg.sh g2 +$ ./$MAKESURE -f tests/29_glob_plus_pg.sh g2 -$ cd "$MYDIR"; ./$MAKESURE -f tests/29_glob_plus_pg.sh g3 +$ ./$MAKESURE -f tests/29_glob_plus_pg.sh g3 From c4ee297a85597679793dfff5307d3ffc92cef8ed Mon Sep 17 00:00:00 2001 From: xonix Date: Fri, 5 Jan 2024 16:03:57 +0200 Subject: [PATCH 3/9] Allow `@glob` goals to be parameterized #155 --- docs/glob_plus_pg.md | 24 +++++++++++++++++++ makesure.awk | 5 ++-- tests/29_glob_plus_pg.tush | 16 +++++++++---- ...9_glob_plus_pg.sh => 29_glob_plus_pg_1.sh} | 0 tests/29_glob_plus_pg_2.sh | 16 +++++++++++++ 5 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 docs/glob_plus_pg.md rename tests/{29_glob_plus_pg.sh => 29_glob_plus_pg_1.sh} (100%) create mode 100644 tests/29_glob_plus_pg_2.sh diff --git a/docs/glob_plus_pg.md b/docs/glob_plus_pg.md new file mode 100644 index 0000000..9168594 --- /dev/null +++ b/docs/glob_plus_pg.md @@ -0,0 +1,24 @@ + +```shell +@goal gpg @glob 'glob_test/*.txt' @params P + echo "$ITEM $P" + +@goal g1 +@depends_on gpg @args 'hello' +``` + +-> + +```shell +@goal gpg @params P +@depends_on 'gpg@glob_test/1.txt' @args P +@depends_on 'gpg@glob_test/2.txt' @args P + +@goal 'gpg@glob_test/1.txt' @params P + echo "$ITEM $P" +@goal 'gpg@glob_test/2.txt' @params P + echo "$ITEM $P" + +@goal g1 +@depends_on gpg @args 'hello' +``` diff --git a/makesure.awk b/makesure.awk index 954b693..fbe221e 100755 --- a/makesure.awk +++ b/makesure.awk @@ -300,10 +300,9 @@ function handleDependsOn( i) { registerDependsOn(globGoal(i)) } -function registerDependsOn(goalName, i,dep,x,y) { +function registerDependsOn(goalName, i,dep) { for (i = 2; i <= NF; i++) { - dep = $i - if ("@args" == dep) { + if ("@args" == (dep = $i)) { if (i != 3) addError("@args only allowed at position 3") DependencyArgsNR[goalName, DependenciesCnt[goalName] - 1] = NR diff --git a/tests/29_glob_plus_pg.tush b/tests/29_glob_plus_pg.tush index a29dd11..e2d161c 100644 --- a/tests/29_glob_plus_pg.tush +++ b/tests/29_glob_plus_pg.tush @@ -1,8 +1,16 @@ -$ ./$MAKESURE -f tests/29_glob_plus_pg.sh -l +$ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh -l -$ ./$MAKESURE -f tests/29_glob_plus_pg.sh g1 +$ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh g1 -$ ./$MAKESURE -f tests/29_glob_plus_pg.sh g2 +$ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh g2 -$ ./$MAKESURE -f tests/29_glob_plus_pg.sh g3 +$ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh g3 + +$ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh -l + +$ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh g1 + +$ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh g2 + +$ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh g3 diff --git a/tests/29_glob_plus_pg.sh b/tests/29_glob_plus_pg_1.sh similarity index 100% rename from tests/29_glob_plus_pg.sh rename to tests/29_glob_plus_pg_1.sh diff --git a/tests/29_glob_plus_pg_2.sh b/tests/29_glob_plus_pg_2.sh new file mode 100644 index 0000000..9cc97fb --- /dev/null +++ b/tests/29_glob_plus_pg_2.sh @@ -0,0 +1,16 @@ + +@goal @glob 'glob_test/*.txt' @params P + echo "$ITEM $P" + +@goal g1 +@depends_on 'glob_test/*.txt' @args 'hello' + +@goal g2 +@depends_on 'glob_test/*.txt' @args 'hello' +@depends_on 'glob_test/*.txt' @args 'hi' + +@goal g3 +@depends_on g3pg @args 'salut' + +@goal g3pg @params X +@depends_on 'glob_test/*.txt' @args X From 2a05c1311834231f03bb2ba4ca5ca29f6c8e3191 Mon Sep 17 00:00:00 2001 From: xonix Date: Fri, 5 Jan 2024 16:37:04 +0200 Subject: [PATCH 4/9] Allow `@glob` goals to be parameterized #155 --- makesure.awk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/makesure.awk b/makesure.awk index fbe221e..d57eb06 100755 --- a/makesure.awk +++ b/makesure.awk @@ -20,7 +20,7 @@ BEGIN { delete Dependencies # name,depI -> dep goal delete DependenciesLineNo # name,depI -> line no. delete DependenciesCnt # name -> dep cnt - delete DependencyArgsNR # name,depI -> NR only when it's @depends_on with @args + delete DependencyArgsL # name,depI -> initial $0, but only when it's @depends_on with @args delete Doc # name -> doc str delete ReachedIf # name -> condition line GlobCnt = 0 # count of files for glob @@ -41,7 +41,7 @@ BEGIN { function makesure( i) { while (getline > 0) { - Lines[NR] = $0 + Lines[NR] = Line0 = $0 if ($1 ~ /^@/ && "@reached_if" != $1 && !reparseCli()) continue if ("@options" == $1) handleOptions() else if ("@define" == $1) handleDefine() @@ -305,7 +305,7 @@ function registerDependsOn(goalName, i,dep) { if ("@args" == (dep = $i)) { if (i != 3) addError("@args only allowed at position 3") - DependencyArgsNR[goalName, DependenciesCnt[goalName] - 1] = NR + DependencyArgsL[goalName, DependenciesCnt[goalName] - 1] = Line0 break } else registerDependency(goalName, dep) @@ -645,12 +645,12 @@ function instantiate(goal,args,newArgs, i,j,depArg,depArgType,dep,goalNameInst dep = Dependencies[gi = goal SUBSEP i] argsCnt = 0 - if (gi in DependencyArgsNR) { + if (gi in DependencyArgsL) { delete reparsed # The idea behind deferring this reparsing to instantiation is to be able to reference both @define vars and PG # params in PG arg string interpolation. # Already should not fails syntax (checked earlier) - we don't check result code. - parseCli_2(Lines[DependencyArgsNR[gi]], args, Vars, reparsed) + parseCli_2(DependencyArgsL[gi], args, Vars, reparsed) argsCnt = reparsed[-7] - 3 # -7 holds len. Subtracting 3, because args start after `@depends_on pg @args` } From 2b49b94d3f2568748565b7be7edb74bb4626838c Mon Sep 17 00:00:00 2001 From: xonix Date: Fri, 5 Jan 2024 17:20:41 +0200 Subject: [PATCH 5/9] Allow `@glob` goals to be parameterized #155 --- makesure.awk | 30 +++++++++++++----- tests/29_glob_plus_pg.tush | 64 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 7 deletions(-) diff --git a/makesure.awk b/makesure.awk index d57eb06..22d7781 100755 --- a/makesure.awk +++ b/makesure.awk @@ -30,6 +30,7 @@ BEGIN { delete Lib # name -> code delete UseLibLineNo# name -> line no. delete GoalToLib # goal name -> lib name + delete GlobPgParams # TODO delete EMPTY Mode = "prelude" # prelude|define|goal|goal_glob|lib srand() @@ -242,27 +243,42 @@ function parsePriv() { NF-- return 1 } -function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax) { +function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax,gi,j,l) { started("goal_glob") + delete GlobPgParams priv = parsePriv() if ("@glob" == (goalName = $2)) { goalName = ""; pattern = $(nfMax = 3) } else pattern = $(nfMax = 4) - if (NF > nfMax) - addError("nothing allowed after glob pattern") + if (NF > nfMax && "@params" != $(nfMax + 1)) + addError("nothing allowed after glob pattern") # TODO adjust error else if (pattern == "") addError("absent glob pattern") else { + if ("@params" == $(nfMax + 1)) + for (i = nfMax + 2; i <= NF; i++) + arrPush(GlobPgParams, validateParamName($i)) 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 + for (i = 0; i < GlobCnt; i++) { + registerGoal(globSingle ? priv : 1, gi = globGoal(i)) + for (j = 0; j in GlobPgParams; j++) + GoalParams[gi, GoalParamsCnt[gi]++] = GlobPgParams[j] + } if (!globSingle) { # glob on single file registerGoal(priv, globAllGoal) - for (i = 0; i < GlobCnt; i++) + for (j = 0; j in GlobPgParams; j++) + GoalParams[globAllGoal, GoalParamsCnt[globAllGoal]++] = GlobPgParams[j] + for (i = 0; i < GlobCnt; i++) { registerDependency(globAllGoal, globGoal(i)) + if (arrLen(GlobPgParams)) { + l = "@depends_on x @params" + for (j = 0; j in GlobPgParams; j++) + l = l " " GlobPgParams[j] + DependencyArgsL[globAllGoal, i] = l + } + } } } } diff --git a/tests/29_glob_plus_pg.tush b/tests/29_glob_plus_pg.tush index e2d161c..00ef160 100644 --- a/tests/29_glob_plus_pg.tush +++ b/tests/29_glob_plus_pg.tush @@ -1,16 +1,80 @@ $ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh -l +| Available goals: +| g1 +| g2 +| g3 +| gpg@hello +| gpg@hi +| g3pg@salut +| gpg@salut $ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh g1 +| goal 'gpg@glob_test/1.txt@hello' ... +| glob_test/1.txt hello +| goal 'gpg@glob_test/2.txt@hello' ... +| glob_test/2.txt hello +| goal 'gpg@hello' [empty]. +| goal 'g1' [empty]. $ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh g2 +| goal 'gpg@glob_test/1.txt@hello' ... +| glob_test/1.txt hello +| goal 'gpg@glob_test/2.txt@hello' ... +| glob_test/2.txt hello +| goal 'gpg@hello' [empty]. +| goal 'gpg@glob_test/1.txt@hi' ... +| glob_test/1.txt hi +| goal 'gpg@glob_test/2.txt@hi' ... +| glob_test/2.txt hi +| goal 'gpg@hi' [empty]. +| goal 'g2' [empty]. $ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh g3 +| goal 'gpg@glob_test/1.txt@salut' ... +| glob_test/1.txt salut +| goal 'gpg@glob_test/2.txt@salut' ... +| glob_test/2.txt salut +| goal 'gpg@salut' [empty]. +| goal 'g3pg@salut' [empty]. +| goal 'g3' [empty]. $ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh -l +| Available goals: +| g1 +| g2 +| g3 +| 'glob_test/*.txt@hello' +| 'glob_test/*.txt@hi' +| g3pg@salut +| 'glob_test/*.txt@salut' $ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh g1 +| goal 'glob_test/1.txt@hello' ... +| glob_test/1.txt hello +| goal 'glob_test/2.txt@hello' ... +| glob_test/2.txt hello +| goal 'glob_test/*.txt@hello' [empty]. +| goal 'g1' [empty]. $ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh g2 +| goal 'glob_test/1.txt@hello' ... +| glob_test/1.txt hello +| goal 'glob_test/2.txt@hello' ... +| glob_test/2.txt hello +| goal 'glob_test/*.txt@hello' [empty]. +| goal 'glob_test/1.txt@hi' ... +| glob_test/1.txt hi +| goal 'glob_test/2.txt@hi' ... +| glob_test/2.txt hi +| goal 'glob_test/*.txt@hi' [empty]. +| goal 'g2' [empty]. $ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh g3 +| goal 'glob_test/1.txt@salut' ... +| glob_test/1.txt salut +| goal 'glob_test/2.txt@salut' ... +| glob_test/2.txt salut +| goal 'glob_test/*.txt@salut' [empty]. +| goal 'g3pg@salut' [empty]. +| goal 'g3' [empty]. From c7f8088aa5e9c534e83abab5177dcebb0d3985ab Mon Sep 17 00:00:00 2001 From: xonix Date: Fri, 5 Jan 2024 17:29:04 +0200 Subject: [PATCH 6/9] Allow `@glob` goals to be parameterized #155 rfct --- makesure.awk | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/makesure.awk b/makesure.awk index 22d7781..7c9e58b 100755 --- a/makesure.awk +++ b/makesure.awk @@ -30,7 +30,6 @@ BEGIN { delete Lib # name -> code delete UseLibLineNo# name -> line no. delete GoalToLib # goal name -> lib name - delete GlobPgParams # TODO delete EMPTY Mode = "prelude" # prelude|define|goal|goal_glob|lib srand() @@ -243,9 +242,8 @@ function parsePriv() { NF-- return 1 } -function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax,gi,j,l) { +function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax,gi,j,l,globPgParams) { started("goal_glob") - delete GlobPgParams priv = parsePriv() if ("@glob" == (goalName = $2)) { goalName = ""; pattern = $(nfMax = 3) @@ -258,24 +256,24 @@ function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax, else { if ("@params" == $(nfMax + 1)) for (i = nfMax + 2; i <= NF; i++) - arrPush(GlobPgParams, validateParamName($i)) + arrPush(globPgParams, validateParamName($i)) calcGlob(goalName, pattern) globAllGoal = goalName ? goalName : pattern globSingle = GlobCnt == 1 && globAllGoal == globGoal(0) for (i = 0; i < GlobCnt; i++) { registerGoal(globSingle ? priv : 1, gi = globGoal(i)) - for (j = 0; j in GlobPgParams; j++) - GoalParams[gi, GoalParamsCnt[gi]++] = GlobPgParams[j] + for (j = 0; j in globPgParams; j++) + GoalParams[gi, GoalParamsCnt[gi]++] = globPgParams[j] } if (!globSingle) { # glob on single file registerGoal(priv, globAllGoal) - for (j = 0; j in GlobPgParams; j++) - GoalParams[globAllGoal, GoalParamsCnt[globAllGoal]++] = GlobPgParams[j] + for (j = 0; j in globPgParams; j++) + GoalParams[globAllGoal, GoalParamsCnt[globAllGoal]++] = globPgParams[j] for (i = 0; i < GlobCnt; i++) { registerDependency(globAllGoal, globGoal(i)) - if (arrLen(GlobPgParams)) { + if (arrLen(globPgParams)) { l = "@depends_on x @params" - for (j = 0; j in GlobPgParams; j++) - l = l " " GlobPgParams[j] + for (j = 0; j in globPgParams; j++) + l = l " " globPgParams[j] DependencyArgsL[globAllGoal, i] = l } } From 5f8c46d559d106d3b6dc82b1335d819e80204fe9 Mon Sep 17 00:00:00 2001 From: xonix Date: Fri, 5 Jan 2024 17:32:54 +0200 Subject: [PATCH 7/9] Allow `@glob` goals to be parameterized #155 --- makesure.awk | 2 +- tests/12_errors.tush | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/makesure.awk b/makesure.awk index 7c9e58b..0d75b8a 100755 --- a/makesure.awk +++ b/makesure.awk @@ -250,7 +250,7 @@ function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax, } else pattern = $(nfMax = 4) if (NF > nfMax && "@params" != $(nfMax + 1)) - addError("nothing allowed after glob pattern") # TODO adjust error + addError("nothing or @params allowed after glob pattern") else if (pattern == "") addError("absent glob pattern") else { diff --git a/tests/12_errors.tush b/tests/12_errors.tush index 30071cd..4dbe975 100644 --- a/tests/12_errors.tush +++ b/tests/12_errors.tush @@ -42,11 +42,11 @@ $ ./$MAKESURE -f tests/12_errors.sh @ tests/12_errors.sh:48: @goal @private @ nothing allowed after goal name: @ tests/12_errors.sh:51: @goal g15 should not have anything after goal name -@ nothing allowed after glob pattern: +@ nothing or @params allowed after glob pattern: @ tests/12_errors.sh:54: @goal g17 @glob '*.txt' should not have anything after glob pattern -@ nothing allowed after glob pattern: +@ nothing or @params allowed after glob pattern: @ tests/12_errors.sh:57: @goal @glob '*.txt' should not have anything after glob pattern -@ nothing allowed after glob pattern: +@ nothing or @params 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 From b393af9c2f65945b52c45f6e894fe56b29093192 Mon Sep 17 00:00:00 2001 From: xonix Date: Fri, 5 Jan 2024 22:54:31 +0200 Subject: [PATCH 8/9] Allow `@glob` goals to be parameterized #155 --- makesure.awk | 3 +- tests/29_glob_plus_pg.tush | 70 ++++++++++++++++++++++++++++++++++++++ tests/29_glob_plus_pg_3.sh | 16 +++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 tests/29_glob_plus_pg_3.sh diff --git a/makesure.awk b/makesure.awk index 0d75b8a..e4fec09 100755 --- a/makesure.awk +++ b/makesure.awk @@ -264,7 +264,8 @@ function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax, registerGoal(globSingle ? priv : 1, gi = globGoal(i)) for (j = 0; j in globPgParams; j++) GoalParams[gi, GoalParamsCnt[gi]++] = globPgParams[j] - } if (!globSingle) { # glob on single file + } + if (!globSingle) { # glob on single file registerGoal(priv, globAllGoal) for (j = 0; j in globPgParams; j++) GoalParams[globAllGoal, GoalParamsCnt[globAllGoal]++] = globPgParams[j] diff --git a/tests/29_glob_plus_pg.tush b/tests/29_glob_plus_pg.tush index 00ef160..09a9a37 100644 --- a/tests/29_glob_plus_pg.tush +++ b/tests/29_glob_plus_pg.tush @@ -9,6 +9,22 @@ $ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh -l | g3pg@salut | gpg@salut +$ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh -la +| Available goals: +| g1 +| g2 +| g3 +| gpg@hello +| gpg@glob_test/1.txt@hello +| gpg@glob_test/2.txt@hello +| gpg@hi +| gpg@glob_test/1.txt@hi +| gpg@glob_test/2.txt@hi +| g3pg@salut +| gpg@salut +| gpg@glob_test/1.txt@salut +| gpg@glob_test/2.txt@salut + $ ./$MAKESURE -f tests/29_glob_plus_pg_1.sh g1 | goal 'gpg@glob_test/1.txt@hello' ... | glob_test/1.txt hello @@ -49,6 +65,22 @@ $ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh -l | g3pg@salut | 'glob_test/*.txt@salut' +$ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh -la +| Available goals: +| g1 +| g2 +| g3 +| 'glob_test/*.txt@hello' +| glob_test/1.txt@hello +| glob_test/2.txt@hello +| 'glob_test/*.txt@hi' +| glob_test/1.txt@hi +| glob_test/2.txt@hi +| g3pg@salut +| 'glob_test/*.txt@salut' +| glob_test/1.txt@salut +| glob_test/2.txt@salut + $ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh g1 | goal 'glob_test/1.txt@hello' ... | glob_test/1.txt hello @@ -78,3 +110,41 @@ $ ./$MAKESURE -f tests/29_glob_plus_pg_2.sh g3 | goal 'glob_test/*.txt@salut' [empty]. | goal 'g3pg@salut' [empty]. | goal 'g3' [empty]. + +$ ./$MAKESURE -f tests/29_glob_plus_pg_3.sh -l +| Available goals: +| g1 +| g2 +| g3 +| glob_test/1.txt@hello +| glob_test/1.txt@hi +| g3pg@salut +| glob_test/1.txt@salut + +$ ./$MAKESURE -f tests/29_glob_plus_pg_3.sh -la +| Available goals: +| g1 +| g2 +| g3 +| glob_test/1.txt@hello +| glob_test/1.txt@hi +| g3pg@salut +| glob_test/1.txt@salut + +$ ./$MAKESURE -f tests/29_glob_plus_pg_3.sh g1 +| goal 'glob_test/1.txt@hello' ... +| glob_test/1.txt hello +| goal 'g1' [empty]. + +$ ./$MAKESURE -f tests/29_glob_plus_pg_3.sh g2 +| goal 'glob_test/1.txt@hello' ... +| glob_test/1.txt hello +| goal 'glob_test/1.txt@hi' ... +| glob_test/1.txt hi +| goal 'g2' [empty]. + +$ ./$MAKESURE -f tests/29_glob_plus_pg_3.sh g3 +| goal 'glob_test/1.txt@salut' ... +| glob_test/1.txt salut +| goal 'g3pg@salut' [empty]. +| goal 'g3' [empty]. diff --git a/tests/29_glob_plus_pg_3.sh b/tests/29_glob_plus_pg_3.sh new file mode 100644 index 0000000..67e1487 --- /dev/null +++ b/tests/29_glob_plus_pg_3.sh @@ -0,0 +1,16 @@ + +@goal @glob 'glob_test/1.txt' @params P + echo "$ITEM $P" + +@goal g1 +@depends_on 'glob_test/1.txt' @args 'hello' + +@goal g2 +@depends_on 'glob_test/1.txt' @args 'hello' +@depends_on 'glob_test/1.txt' @args 'hi' + +@goal g3 +@depends_on g3pg @args 'salut' + +@goal g3pg @params X +@depends_on 'glob_test/1.txt' @args X From 33c88f856d983d11dc1f48c620357be5fc1d7a54 Mon Sep 17 00:00:00 2001 From: xonix Date: Sat, 6 Jan 2024 21:13:45 +0200 Subject: [PATCH 9/9] Allow `@glob` goals to be parameterized #155 : README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0efd9f0..d9f3ec7 100644 --- a/README.md +++ b/README.md @@ -417,6 +417,8 @@ ARG=hello world You can also rely on parameterized goals [parameters interpolation](https://github.com/xonixx/makesure/issues/153). +Also, it's possible for a `@glob` goal [to be parameterized](https://github.com/xonixx/makesure/issues/155). + Please find a more real-world example [here](https://github.com/xonixx/fhtagn/blob/e7161f92731c13b5afbc09c7d738c1ff4882906f/Makesurefile#L70). For more technical consideration regarding this feature see [parameterized_goals.md](docs/parameterized_goals.md).