1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-23 15:00:27 +00:00

Update cook.janet and jpm

They should throw better error messages when project.janet
not found.
This commit is contained in:
Calvin Rose 2019-06-19 00:48:57 -04:00
parent 264c5bc02b
commit 9943bdd907
2 changed files with 10 additions and 12 deletions

View File

@ -17,8 +17,8 @@
(print ` (print `
Keys are: Keys are:
--modpath : The directory to install modules to. Defaults to $JANET_MODPATH or module/*syspath* --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 module/*headerpath* --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. --binpath : The directory to install binaries and scripts. Defaults to $JANET_BINPATH.
--optimize : Optimization level for natives. Defaults to $OPTIMIZE or 2. --optimize : Optimization level for natives. Defaults to $OPTIMIZE or 2.
--compiler : C compiler to use for natives. Defaults to $COMPILER or cc. --compiler : C compiler to use for natives. Defaults to $COMPILER or cc.

View File

@ -92,24 +92,22 @@
(unless phony target)) (unless phony target))
(def- _env (fiber/getenv (fiber/current))) (def- _env (fiber/getenv (fiber/current)))
(defn- import-rules*
[path & args] (defn import-rules
(def [realpath] (module/find path)) "Import another file that defines more cook rules. This ruleset
is merged into the current ruleset."
[path]
(def env (make-env)) (def env (make-env))
(unless (os/stat path :mode)
(error (string "cannot open " path)))
(loop [k :keys _env :when (symbol? k)] (loop [k :keys _env :when (symbol? k)]
(unless ((_env k) :private) (put env k (_env k)))) (unless ((_env k) :private) (put env k (_env k))))
(def currenv (fiber/getenv (fiber/current))) (def currenv (fiber/getenv (fiber/current)))
(loop [k :keys currenv :when (keyword? k)] (loop [k :keys currenv :when (keyword? k)]
(put env k (currenv k))) (put env k (currenv k)))
(require path :env env ;args) (dofile path :env env)
(when-let [rules (env :rules)] (merge-into (getrules) rules))) (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 # Configuration
# #