mirror of
https://github.com/janet-lang/janet
synced 2024-11-17 14:14:49 +00:00
db55277b58
We will probably shift to NSIS as the default installation method for windows. Shipping around a single binary just doesn't cut it if we want to be able to reliably use tools like `jpm` to build things.
40 lines
1.3 KiB
Plaintext
Executable File
40 lines
1.3 KiB
Plaintext
Executable File
#!/usr/bin/env janet
|
|
|
|
# CLI tool for building janet projects. Wraps cook.
|
|
|
|
(import cook :prefix "")
|
|
|
|
(import-rules "./project.janet")
|
|
|
|
(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:
|
|
--libdir : The directory to install modules to. Defaults to $JANET_PATH or module/*syspath*
|
|
--includedir : The directory containing janet headers. Defaults to $JANET_HEADERPATH or module/*headerpath*
|
|
--bindir : The directory to install binaries and scripts. Defaults to $JANET_BINDIR.
|
|
--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))
|
|
(each arg args
|
|
(if (string/has-prefix? "--" arg)
|
|
(let [[key value] (peg/match argpeg arg)]
|
|
(setdyn (keyword key) value))
|
|
(do-rule arg)))
|
|
|
|
(if (empty? args) (help))
|