diff --git a/Makesurefile b/Makesurefile index ec4b0b0..e48c4fd 100644 --- a/Makesurefile +++ b/Makesurefile @@ -110,6 +110,7 @@ @depends_on tests/13_errors.tush @depends_on tests/14_doc.tush @depends_on tests/15_private.tush +@depends_on tests/16_lib.tush @goal stable @doc rebuilds makesure_stable & README.md for release diff --git a/makesure.awk b/makesure.awk index 80b4d6e..895b3ab 100755 --- a/makesure.awk +++ b/makesure.awk @@ -22,7 +22,10 @@ BEGIN { split("",ReachedIf) # name -> condition line split("",GlobFiles) # list split("",GlobGoals) # list - Mode = "prelude" # prelude/goal/goal_glob + split("",LibNames) # list + split("",Lib) # name -> code + split("",GoalToLib)# goal name -> lib name + Mode = "prelude" # prelude|goal|goal_glob|lib srand() prepareArgs() MyDirScript = "MYDIR=" quoteArg(getMyDir(ARGV[1])) ";export MYDIR;cd \"$MYDIR\"" @@ -36,6 +39,8 @@ BEGIN { "@doc" == $1 { handleDoc(); next } "@depends_on" == $1 { handleDependsOn(); next } "@reached_if" == $1 { handleReachedIf(); next } +"@lib" == $1 { handleLib(); next } +"@use_lib" == $1 { handleUseLib(); next } $1 ~ /^@/ { addError("Unknown directive: " $1); next } { handleCodeLine($0); next } @@ -156,6 +161,36 @@ function started(mode) { Mode = mode } +function handleLib() { + started("lib") + + libName = trim($2) + if (libName in Lib) { + die("Lib '" libName "' is already defined") + } + arrPush(LibNames, script_name) + Lib[libName] +} + +function handleUseLib( goal_name) { + checkGoalOnly() + + if ("goal" == Mode) + registerUseLib(currentGoalName()) + else { + for (i=0; i