From 9943bdd9079c8929a7520ed518364640d1ad791f Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Wed, 19 Jun 2019 00:48:57 -0400 Subject: [PATCH] Update cook.janet and jpm They should throw better error messages when project.janet not found. --- auxbin/jpm | 4 ++-- auxlib/cook.janet | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/auxbin/jpm b/auxbin/jpm index 03a5bb8c..039eb7d5 100755 --- a/auxbin/jpm +++ b/auxbin/jpm @@ -17,8 +17,8 @@ (print ` Keys are: - --modpath : The directory to install modules to. Defaults to $JANET_MODPATH or module/*syspath* - --headerpath : The directory containing janet headers. Defaults to $JANET_HEADERPATH or module/*headerpath* + --modpath : The directory to install modules to. Defaults to $JANET_MODPATH or (dyn :syspath) + --headerpath : The directory containing janet headers. Defaults to $JANET_HEADERPATH or (dyn :headerpath) --binpath : The directory to install binaries and scripts. Defaults to $JANET_BINPATH. --optimize : Optimization level for natives. Defaults to $OPTIMIZE or 2. --compiler : C compiler to use for natives. Defaults to $COMPILER or cc. diff --git a/auxlib/cook.janet b/auxlib/cook.janet index 04f870d6..216af42f 100644 --- a/auxlib/cook.janet +++ b/auxlib/cook.janet @@ -92,24 +92,22 @@ (unless phony target)) (def- _env (fiber/getenv (fiber/current))) -(defn- import-rules* - [path & args] - (def [realpath] (module/find path)) + +(defn import-rules + "Import another file that defines more cook rules. This ruleset + is merged into the current ruleset." + [path] (def env (make-env)) + (unless (os/stat path :mode) + (error (string "cannot open " path))) (loop [k :keys _env :when (symbol? k)] (unless ((_env k) :private) (put env k (_env k)))) (def currenv (fiber/getenv (fiber/current))) (loop [k :keys currenv :when (keyword? k)] (put env k (currenv k))) - (require path :env env ;args) + (dofile path :env env) (when-let [rules (env :rules)] (merge-into (getrules) rules))) -(defmacro import-rules - "Import another file that defines more cook rules. This ruleset - is merged into the current ruleset." - [path & args] - ~(,import-rules* ,(string path) ,;args)) - # # Configuration #