mirror of
https://github.com/janet-lang/janet
synced 2025-01-26 23:24:44 +00:00
Add jpm rule-tree.
Useful for debugging jpm. This funtionality also maybe reused for for showing a dependency tree as well.
This commit is contained in:
parent
42c257d0fc
commit
e579d1d89f
33
auxbin/jpm
33
auxbin/jpm
@ -862,6 +862,25 @@ int main(int argc, const char **argv) {
|
||||
(add-body "install"
|
||||
(spit newname bat))))
|
||||
|
||||
(def- tree-l " └─")
|
||||
(def- tree-t " ├─")
|
||||
(def- tree-i " │ ")
|
||||
(def- tree-s " ")
|
||||
(defn- print-rule-tree
|
||||
"Show dependencies for a given rule recursively in a nice tree."
|
||||
[root depth prefix prefix-part]
|
||||
(printf "%s%s" prefix root)
|
||||
(def rules (getrules))
|
||||
(when-let [[root-deps] (rules root)]
|
||||
(def l (-> root-deps length dec))
|
||||
(when (pos? depth)
|
||||
(eachp [i d] (sorted root-deps)
|
||||
(def is-last (= i l))
|
||||
(print-rule-tree
|
||||
d (dec depth)
|
||||
(string prefix-part (if is-last tree-l tree-t))
|
||||
(string prefix-part (if is-last tree-s tree-i)))))))
|
||||
|
||||
(defn declare-archive
|
||||
"Build a janet archive. This is a file that bundles together many janet
|
||||
scripts into a janet image. This file can the be moved to any machine with
|
||||
@ -976,6 +995,10 @@ Subcommands are:
|
||||
run rule : run a rule. Can also run custom rules added via (phony "task" [deps...] ...)
|
||||
or (rule "ouput.file" [deps...] ...).
|
||||
rules : list rules available with run.
|
||||
rule-tree (root rule) (depth) : Print a nice tree to see what rules depend on other rules.
|
||||
Optinally provide a root rule to start printing from, and a
|
||||
max depth to print. Without these options, all rules will print
|
||||
their full dependency tree.
|
||||
update-pkgs : Update the current package listing from the remote git repository selected.
|
||||
quickbin entry executable : Create an executable from a janet script with a main function.
|
||||
make-lockfile (lockfile) : Create a lockfile based on repositories in the cache. The
|
||||
@ -1044,6 +1067,15 @@ Flags are:
|
||||
[]
|
||||
(local-rule "install-deps" true))
|
||||
|
||||
(defn show-rule-tree
|
||||
[&opt root depth]
|
||||
(import-rules "./project.janet" true)
|
||||
(def max-depth (if depth (scan-number depth) math/inf))
|
||||
(if root
|
||||
(print-rule-tree root max-depth "" "")
|
||||
(let [ks (sort (seq [k :keys (dyn :rules)] k))]
|
||||
(each k ks (print-rule-tree k max-depth "" "")))))
|
||||
|
||||
(defn list-rules
|
||||
[&opt ctx]
|
||||
(import-rules "./project.janet" true)
|
||||
@ -1089,6 +1121,7 @@ Flags are:
|
||||
"help" help
|
||||
"deps" deps
|
||||
"repl" jpm-repl
|
||||
"rule-tree" show-rule-tree
|
||||
"show-paths" show-paths
|
||||
"clear-cache" clear-cache
|
||||
"run" local-rule
|
||||
|
6
jpm.1
6
jpm.1
@ -143,6 +143,12 @@ like make. run will run a single rule or build a single file.
|
||||
.BR rules
|
||||
List all rules that can be run via run. This is useful for exploring rules in the project.
|
||||
|
||||
.TP
|
||||
.BR rule-tree\ [\fBroot\fR] [\fdepth\fR]
|
||||
Show rule dependency tree in a pretty format. Optionally provide a rule to use as the tree
|
||||
root, as well as a max depth to print. By default, prints the full tree for all rules. This
|
||||
can be quite long, so it is recommended to give a root rule.
|
||||
|
||||
.TP
|
||||
.BR show-paths
|
||||
Show all of the paths used when installing and building artifacts.
|
||||
|
@ -45,6 +45,10 @@
|
||||
/* #define JANET_NO_DOCSTRINGS */
|
||||
/* #define JANET_NO_SOURCEMAPS */
|
||||
/* #define JANET_REDUCED_OS */
|
||||
/* #define JANET_OS_NO_EXECUTE */
|
||||
/* #define JANET_OS_NO_TIME */
|
||||
/* #define JANET_OS_NO_FS */
|
||||
/* #define JANET_OS_NO_ENV */
|
||||
|
||||
/* Other settings */
|
||||
/* #define JANET_NO_ASSEMBLER */
|
||||
|
Loading…
Reference in New Issue
Block a user