Skip to content

Commit

Permalink
Propose a method to have parameterized goals #12
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Mar 22, 2021
1 parent f9c8d5c commit 255dd6d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
21 changes: 20 additions & 1 deletion makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ BEGIN {
split("",ScriptsByName) # name -> ""
split("",Script) # name -> body
split("",ScriptFile) # name -> file
split("",GoalToCall) # name -> call script
Mode = "prelude" # prelude/goal/script
srand()
prepareArgs()
Expand Down Expand Up @@ -223,7 +224,25 @@ function handleReachedIf( goal_name) {
ReachedIf[goal_name] = trim($0)
}

function handleCall() {
function handleCall( script_name) {
checkGoalOnly()

goal_name = currentGoalName()

$1 = ""

if (trim(Code[goal_name]))
die("You can't have a goal body when using @call")
if (goal_name in GoalToCall)
die("You can only use one @call in a @goal")

script_name = $2
if (!(script_name in ScriptsByName))
die("Script not found: " script_name)

$2 = ""

GoalToCall[goal_name] = Shell " -e " ScriptFile[script_name] " " trim($0)
}

function doWork( i,j,goal_name,dep_cnt,dep,reached_if,reached_goals,empty_goals,my_dir,defines_line,
Expand Down
7 changes: 7 additions & 0 deletions tests/11_call.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


@goal a
@call script1 Hello

@script script1
echo $1
3 changes: 3 additions & 0 deletions tests/11_call.tush
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

$ cd "$MYDIR"; ./makesure -f tests/11_call.sh
|

0 comments on commit 255dd6d

Please sign in to comment.