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 19, 2023
1 parent b6b3477 commit 03e5d6b
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,16 @@ function handleGoal() {
registerGoal($2, isPriv())
}

function registerGoal(goalName, priv) {
function registerGoal(goalName, priv, i) {
if (goalName == "")
addError("Goal must have a name")
if (goalName in GoalsByName)
addError("Goal " quote2(goalName,1) " is already defined")
arrPush(GoalNames, goalName)
GoalsByName[goalName] = priv
if ("@params" == $3)
for (i=4; i <= NF; i++)
GoalParams[goalName,GoalParamsCnt[goalName]++] = $i # TODO $NF=="@private"?
}

function globGoal(i) { return (GlobGoalName ? GlobGoalName "@" : "") GlobFiles[i] }
Expand Down Expand Up @@ -289,9 +292,21 @@ function handleDependsOn( i) {
registerDependsOn(globGoal(i))
}

function registerDependsOn(goalName, i) {
for (i=2; i<=NF; i++)
registerDependency(goalName, $i)
function registerDependsOn(goalName, i,dep,x,y) {
for (i=2; i<=NF; i++) {
dep = $i
if ("@args" == dep) {
if (i != 3) addError("@args only allowed at position 3") # TODO finalize error msg
if (i == NF) addError("must be at least one argument") # TODO finalize error msg
while (++i <= NF) {
x = goalName SUBSEP DependenciesCnt[goalName]
y = x SUBSEP DependencyArgsCnt[x]++
DependencyArgs[y] = $i
DependencyArgsType[y] = "string" # TODO
}
} else
registerDependency(goalName, dep)
}
}

function registerDependency(goalName, depGoalName, x) {
Expand Down

0 comments on commit 03e5d6b

Please sign in to comment.