1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-01 12:29:54 +00:00
janet/tools/jpm

42 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env janet
# CLI tool for building janet projects. Wraps cook.
2019-05-29 15:04:38 +00:00
(import cook)
(def- argpeg
(peg/compile
'(* "--" '(some (if-not "=" 1)) "=" '(any 1))))
(defn- help
[]
(print "usage: jpm [targets]... --key=value ...")
(print "Available targets are:")
(each k (sort (keys (dyn :rules @{})))
(print " " k))
(print `
Keys are:
2019-05-29 15:04:38 +00:00
--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*
--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 $CC or cc.
--linker : C linker to use for linking natives. Defaults to $LINKER or cc.
--cflags : Extra compiler flags for native modules. Defaults to $CFLAGS if set.
--lflags : Extra linker flags for native modules. Defaults to $LFLAGS if set.
`))
(def args (tuple/slice process/args 2))
2019-05-29 02:12:42 +00:00
(def todo @[])
(each arg args
(if (string/has-prefix? "--" arg)
(let [[key value] (peg/match argpeg arg)]
(setdyn (keyword key) value))
2019-05-29 02:12:42 +00:00
(array/push todo arg)))
2019-05-29 15:04:38 +00:00
(cook/import-rules "./project.janet")
2019-05-29 02:12:42 +00:00
2019-05-29 15:04:38 +00:00
(if (empty? todo) (help))
(each rule todo (cook/do-rule rule))