Skip to content

Commit

Permalink
Allow @glob goals to be parameterized #155
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Jan 5, 2024
1 parent 6b60186 commit c4ee297
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
24 changes: 24 additions & 0 deletions docs/glob_plus_pg.md
Original file line number Diff line number Diff line change
@@ -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'
```
5 changes: 2 additions & 3 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions tests/29_glob_plus_pg.tush
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
16 changes: 16 additions & 0 deletions tests/29_glob_plus_pg_2.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c4ee297

Please sign in to comment.