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 18, 2021
1 parent d40b0aa commit 80cb8a3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
14 changes: 8 additions & 6 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ BEGIN {
split("",Options)
split("",GoalNames) # list
split("",GoalsByName) # name -> private
split("",Glob) # name -> pattern
split("",Code) # name -> body
split("",DefineOverrides) # k -> ""
DefinesFile=""
split("",Dependencies) # name,i -> dep goal
split("",DependenciesLineNo) # name,i -> line no.
split("",DependenciesCnt) # name -> dep cnd
split("",Doc) # name -> doc str
split("",DependenciesCnt) # name -> dep cnd
split("",Doc) # name -> doc str
split("",ReachedIf) # name -> condition line
split("",GlobFiles) # list
split("",GlobGoals) # list
Expand Down Expand Up @@ -214,6 +215,7 @@ function registerGoal(goalName, priv) {
}

function calcGlob(goalName, pattern, script, file) {
Glob[goalName] = pattern
split("",GlobGoals)
split("",GlobFiles)
script = MyDirScript ";for f in ./" pattern ";do test -e \"$f\" && echo \"$f\";done"
Expand Down Expand Up @@ -242,19 +244,19 @@ function handleGoalGlob( goalName,g,priv,i,pattern) {
goalName = ""
} else $3 = ""
calcGlob(goalName, pattern = trim($0))
registerGoal(goalName = goalName ? goalName : pattern, priv)
for (i=0; i in GlobGoals; i++){
registerDependency(goalName, g = GlobGoals[i])
registerGoal(g, 1)
}
registerGoal(goalName = goalName ? goalName : pattern, priv)
}

function handleDoc( i) {
checkGoalOnly()

if ("goal" == Mode)
registerDoc(currentGoalName())
else {
registerDoc(currentGoalName())

if ("goal_glob" == Mode) {
for (i=0; i in GlobGoals; i++){
registerDoc(GlobGoals[i])
}
Expand Down
29 changes: 25 additions & 4 deletions tests/11_goal_glob.tush
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@

$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh test1 -l
$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh -l
| Available goals:
| 11_goal_glob_1.txt : test goal_glob
| 11_goal_glob_2.txt : test goal_glob
| 11_goal_glob_3.txt : test goal_glob
| 11_goal_glob*.txt : test goal_glob
| non-existent-glob*
| test1
| test2
| goal_name

$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh -la
| Available goals:
| 11_goal_glob_1.txt : test goal_glob
| 11_goal_glob_2.txt : test goal_glob
| 11_goal_glob_3.txt : test goal_glob
| 11_goal_glob_10.txt : test goal_glob
| 11_goal_glob*.txt : test goal_glob
| non-existent-glob*
| test1
| test2
| goal_name@11_goal_glob_1.txt
| goal_name@11_goal_glob_2.txt
| goal_name@11_goal_glob_3.txt
| goal_name@11_goal_glob_10.txt
| goal_name

$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh -d '11_goal_glob*.txt'
| Resolved goals to reach for '11_goal_glob*.txt':
| 11_goal_glob_1.txt
| 11_goal_glob_2.txt
| 11_goal_glob_3.txt
| 11_goal_glob_10.txt
| 11_goal_glob*.txt

$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh test1
| goal '11_goal_glob_1.txt' ...
Expand Down
1 change: 1 addition & 0 deletions tests/11_goal_glob_10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
content 101010

0 comments on commit 80cb8a3

Please sign in to comment.