mirror of
https://github.com/janet-lang/janet
synced 2024-11-25 01:37:19 +00:00
Format jpm with spork.
This commit is contained in:
parent
e3862b86b5
commit
9aefb59afe
71
jpm
71
jpm
@ -151,11 +151,11 @@
|
|||||||
["/LD"]
|
["/LD"]
|
||||||
["-fPIC"]))
|
["-fPIC"]))
|
||||||
(def- dynamic-lflags
|
(def- dynamic-lflags
|
||||||
(if is-win
|
(if is-win
|
||||||
["/DLL" ;thread-flags]
|
["/DLL" ;thread-flags]
|
||||||
(if is-mac
|
(if is-mac
|
||||||
["-shared" "-undefined" "dynamic_lookup" ;thread-flags]
|
["-shared" "-undefined" "dynamic_lookup" ;thread-flags]
|
||||||
["-shared" ;thread-flags])))
|
["-shared" ;thread-flags])))
|
||||||
|
|
||||||
(defn- opt
|
(defn- opt
|
||||||
"Get an option, allowing overrides via dynamic bindings AND some
|
"Get an option, allowing overrides via dynamic bindings AND some
|
||||||
@ -196,7 +196,7 @@
|
|||||||
(def env (make-env))
|
(def env (make-env))
|
||||||
(put env :jpm-no-deps no-deps)
|
(put env :jpm-no-deps no-deps)
|
||||||
(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))))
|
||||||
env)
|
env)
|
||||||
|
|
||||||
(defn require-jpm
|
(defn require-jpm
|
||||||
@ -280,7 +280,7 @@
|
|||||||
(if is-win
|
(if is-win
|
||||||
(let [end (last (peg/match path-splitter src))
|
(let [end (last (peg/match path-splitter src))
|
||||||
isdir (= (os/stat src :mode) :directory)]
|
isdir (= (os/stat src :mode) :directory)]
|
||||||
(shell "xcopy" src (if isdir (string dest "\\" end) dest) "/y" "/s" "/e" "/i"))
|
(shell "xcopy" src (if isdir (string dest "\\" end) dest) "/y" "/s" "/e" "/i"))
|
||||||
(shell "cp" "-rf" src dest)))
|
(shell "cp" "-rf" src dest)))
|
||||||
|
|
||||||
(defn mkdir
|
(defn mkdir
|
||||||
@ -554,13 +554,12 @@ int main(int argc, const char **argv) {
|
|||||||
prefix
|
prefix
|
||||||
"\", 0);\n\n")
|
"\", 0);\n\n")
|
||||||
(when-let [lfs (meta :lflags)]
|
(when-let [lfs (meta :lflags)]
|
||||||
(array/concat dep-lflags lfs))
|
(array/concat dep-lflags lfs))
|
||||||
(buffer/push-string declarations
|
(buffer/push-string declarations
|
||||||
"extern void "
|
"extern void "
|
||||||
(meta :static-entry)
|
(meta :static-entry)
|
||||||
"(JanetTable *);\n"))
|
"(JanetTable *);\n"))
|
||||||
|
|
||||||
|
|
||||||
# Build image
|
# Build image
|
||||||
(def image (marshal main mdict))
|
(def image (marshal main mdict))
|
||||||
# Make image byte buffer
|
# Make image byte buffer
|
||||||
@ -643,7 +642,7 @@ int main(int argc, const char **argv) {
|
|||||||
(if is-win
|
(if is-win
|
||||||
# windows get rid of read-only files
|
# windows get rid of read-only files
|
||||||
(os/shell `rmdir /S /Q "` path `"`))
|
(os/shell `rmdir /S /Q "` path `"`))
|
||||||
(rm path))
|
(rm path))
|
||||||
|
|
||||||
(defn clear-cache
|
(defn clear-cache
|
||||||
"Clear the global git cache."
|
"Clear the global git cache."
|
||||||
@ -668,9 +667,9 @@ int main(int argc, const char **argv) {
|
|||||||
(unless (string/find ":" repo)
|
(unless (string/find ":" repo)
|
||||||
(def pkgs
|
(def pkgs
|
||||||
(try (require "pkgs")
|
(try (require "pkgs")
|
||||||
([err f]
|
([err f]
|
||||||
(install-git (dyn :pkglist default-pkglist))
|
(install-git (dyn :pkglist default-pkglist))
|
||||||
(require "pkgs"))))
|
(require "pkgs"))))
|
||||||
(def next-repo (get-in pkgs ['packages :value (symbol repo)]))
|
(def next-repo (get-in pkgs ['packages :value (symbol repo)]))
|
||||||
(unless next-repo
|
(unless next-repo
|
||||||
(error (string "package " repo " not found.")))
|
(error (string "package " repo " not found.")))
|
||||||
@ -687,11 +686,11 @@ int main(int argc, const char **argv) {
|
|||||||
(error (string "did not find cached repo for dependency " repo))
|
(error (string "did not find cached repo for dependency " repo))
|
||||||
(set fresh true))
|
(set fresh true))
|
||||||
(when (mkdir module-dir)
|
(when (mkdir module-dir)
|
||||||
(set fresh true)
|
(set fresh true)
|
||||||
(print "cloning repository " repo " to " module-dir)
|
(print "cloning repository " repo " to " module-dir)
|
||||||
(unless (zero? (os/execute ["git" "clone" repo module-dir] :p))
|
(unless (zero? (os/execute ["git" "clone" repo module-dir] :p))
|
||||||
(rimraf module-dir)
|
(rimraf module-dir)
|
||||||
(error (string "could not clone git dependency " repo)))))
|
(error (string "could not clone git dependency " repo)))))
|
||||||
(def olddir (os/cwd))
|
(def olddir (os/cwd))
|
||||||
(try
|
(try
|
||||||
(with-dyns [:rules @{}
|
(with-dyns [:rules @{}
|
||||||
@ -787,12 +786,12 @@ int main(int argc, const char **argv) {
|
|||||||
(compile-c opts src (out-path src ".c" objext)))
|
(compile-c opts src (out-path src ".c" objext)))
|
||||||
(def objects (map (fn [path] (out-path path ".c" objext)) sources))
|
(def objects (map (fn [path] (out-path path ".c" objext)) sources))
|
||||||
(when-let [embedded (opts :embedded)]
|
(when-let [embedded (opts :embedded)]
|
||||||
(loop [src :in embedded]
|
(loop [src :in embedded]
|
||||||
(def c-src (out-path src ".janet" ".janet.c"))
|
(def c-src (out-path src ".janet" ".janet.c"))
|
||||||
(def o-src (out-path src ".janet" (if is-win ".janet.obj" ".janet.o")))
|
(def o-src (out-path src ".janet" (if is-win ".janet.obj" ".janet.o")))
|
||||||
(array/push objects o-src)
|
(array/push objects o-src)
|
||||||
(create-buffer-c src c-src (embed-name src))
|
(create-buffer-c src c-src (embed-name src))
|
||||||
(compile-c opts c-src o-src)))
|
(compile-c opts c-src o-src)))
|
||||||
(link-c opts lname ;objects)
|
(link-c opts lname ;objects)
|
||||||
(add-dep "build" lname)
|
(add-dep "build" lname)
|
||||||
(install-rule lname path)
|
(install-rule lname path)
|
||||||
@ -820,12 +819,12 @@ int main(int argc, const char **argv) {
|
|||||||
(compile-c opts src (out-path src ".c" sobjext) true))
|
(compile-c opts src (out-path src ".c" sobjext) true))
|
||||||
(def sobjects (map (fn [path] (out-path path ".c" sobjext)) sources))
|
(def sobjects (map (fn [path] (out-path path ".c" sobjext)) sources))
|
||||||
(when-let [embedded (opts :embedded)]
|
(when-let [embedded (opts :embedded)]
|
||||||
(loop [src :in embedded]
|
(loop [src :in embedded]
|
||||||
(def c-src (out-path src ".janet" ".janet.c"))
|
(def c-src (out-path src ".janet" ".janet.c"))
|
||||||
(def o-src (out-path src ".janet" sjobjext))
|
(def o-src (out-path src ".janet" sjobjext))
|
||||||
(array/push sobjects o-src)
|
(array/push sobjects o-src)
|
||||||
# Buffer c-src is already declared by dynamic module
|
# Buffer c-src is already declared by dynamic module
|
||||||
(compile-c opts c-src o-src true)))
|
(compile-c opts c-src o-src true)))
|
||||||
(archive-c opts sname ;sobjects)
|
(archive-c opts sname ;sobjects)
|
||||||
(add-dep "build" sname)
|
(add-dep "build" sname)
|
||||||
(install-rule sname path)))
|
(install-rule sname path)))
|
||||||
@ -890,8 +889,8 @@ int main(int argc, const char **argv) {
|
|||||||
(eachp [i d] (sorted root-deps)
|
(eachp [i d] (sorted root-deps)
|
||||||
(print-rule-tree
|
(print-rule-tree
|
||||||
d (dec depth)
|
d (dec depth)
|
||||||
(string prefix-part (if (= i l) " └─" " ├─"))
|
(string prefix-part (if (= i l) " └─" " ├─"))
|
||||||
(string prefix-part (if (= i l) " " " │ ")))))))
|
(string prefix-part (if (= i l) " " " │ ")))))))
|
||||||
|
|
||||||
(defn declare-archive
|
(defn declare-archive
|
||||||
"Build a janet archive. This is a file that bundles together many janet
|
"Build a janet archive. This is a file that bundles together many janet
|
||||||
@ -1109,10 +1108,10 @@ Flags are:
|
|||||||
(def env
|
(def env
|
||||||
(try
|
(try
|
||||||
(require-jpm "./project.janet")
|
(require-jpm "./project.janet")
|
||||||
([err f]
|
([err f]
|
||||||
(if (= "cannot open ./project.janet" err)
|
(if (= "cannot open ./project.janet" err)
|
||||||
(put (make-jpm-env) :project {})
|
(put (make-jpm-env) :project {})
|
||||||
(propagate err f)))))
|
(propagate err f)))))
|
||||||
(setdyn :pretty-format (if-not (dyn :nocolor) "%.20Q" "%.20q"))
|
(setdyn :pretty-format (if-not (dyn :nocolor) "%.20Q" "%.20q"))
|
||||||
(setdyn :err-color (if-not (dyn :nocolor) true))
|
(setdyn :err-color (if-not (dyn :nocolor) true))
|
||||||
(def p (env :project))
|
(def p (env :project))
|
||||||
|
Loading…
Reference in New Issue
Block a user