1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-28 11:09:54 +00:00

More work on cook and jpm.

This commit is contained in:
Calvin Rose 2019-05-28 08:48:18 -04:00
parent e7189438dd
commit 7569930b0c
2 changed files with 21 additions and 15 deletions

View File

@ -301,7 +301,6 @@ install: $(JANET_TARGET) $(PKG_CONFIG_PATH)/janet.pc
ln -sf libjanet.so.$(shell $(JANET_TARGET) -e '(print janet/version)') $(LIBDIR)/$(SONAME) ln -sf libjanet.so.$(shell $(JANET_TARGET) -e '(print janet/version)') $(LIBDIR)/$(SONAME)
cp tools/cook.janet $(JANET_PATH) cp tools/cook.janet $(JANET_PATH)
cp tools/jpm $(BINDIR)/jpm cp tools/jpm $(BINDIR)/jpm
chmod +x $(BINDIR)/jpm
cp tools/highlight.janet $(JANET_PATH) cp tools/highlight.janet $(JANET_PATH)
cp tools/bars.janet $(JANET_PATH) cp tools/bars.janet $(JANET_PATH)
mkdir -p $(MANPATH) mkdir -p $(MANPATH)

View File

@ -144,12 +144,6 @@
[src dest] [src dest]
(shell (if is-win "robocopy " "cp -rf ") src " " dest (if is-win " /s /e" ""))) (shell (if is-win "robocopy " "cp -rf ") src " " dest (if is-win " /s /e" "")))
(defn- install-data
"Helper for installing file at path into dir."
[path dir]
(try (os/mkdir dir) ([err] nil))
(copy path dir))
# #
# C Compilation # C Compilation
# #
@ -259,8 +253,23 @@
# tailored for janet. # tailored for janet.
# #
(defn- install-rule
"Add install and uninstall rule for moving file from src into destdir."
[src destdir]
(def parts (string/split sep src))
(def name (last parts))
(add-body "install"
(try (os/mkdir destdir) ([err] nil))
(copy src destdir))
(add-body "uninstall"
(def path (string destdir sep name))
(print "removing " path)
(try (rm path) ([err]
(unless (= err "No such file or directory")
(error err))))))
(defn declare-native (defn declare-native
"Build a native binary. This is a shared library that can be loaded "Declare a native binary. This is a shared library that can be loaded
dynamically by a janet runtime." dynamically by a janet runtime."
[&keys opts] [&keys opts]
(def sources (opts :source)) (def sources (opts :source))
@ -279,8 +288,7 @@
(link-c opts lname ;objects) (link-c opts lname ;objects)
(add-dep "build" lname) (add-dep "build" lname)
(def libdir (opt opts :libdir LIBDIR)) (def libdir (opt opts :libdir LIBDIR))
(add-body "install" (install-data lname LIBDIR)) (install-rule lname LIBDIR))
lname)
(defn declare-source (defn declare-source
"Create a Janet modules. This does not actually build the module(s), "Create a Janet modules. This does not actually build the module(s),
@ -289,15 +297,14 @@
(def sources (opts :source)) (def sources (opts :source))
(def libdir (opt opts :libdir LIBDIR)) (def libdir (opt opts :libdir LIBDIR))
(each s sources (each s sources
(add-body "install" (install-data s libdir)))) (install-rule s libdir)))
(defn declare-binscript (defn declare-binscript
"Declare a janet file to be installed as an executable script." "Declare a janet file to be installed as an executable script."
[&keys opts] [&keys opts]
(def main (opts :main)) (def main (opts :main))
(def bindir (opt opts :bindir BINDIR)) (def bindir (opt opts :bindir BINDIR))
(add-body "install" (install-data main bindir)) (install-rule main bindir))
main)
(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
@ -310,8 +317,7 @@
(rule iname (or (opts :deps) []) (rule iname (or (opts :deps) [])
(spit iname (make-image (require entry)))) (spit iname (make-image (require entry))))
(def libdir (opt opts :libdir LIBDIR)) (def libdir (opt opts :libdir LIBDIR))
(add-body "install" (install-data iname libdir)) (install-rule iname libdir))
iname)
(defn declare-project (defn declare-project
"Define your project metadata. This should "Define your project metadata. This should
@ -322,6 +328,7 @@
(try (os/mkdir "build") ([err] nil)) (try (os/mkdir "build") ([err] nil))
(phony "build" [] (print "Built.")) (phony "build" [] (print "Built."))
(phony "install" ["build"] (print "Installed.")) (phony "install" ["build"] (print "Installed."))
(phony "uninstall" [] (print "Uninstalled."))
(phony "clean" [] (rm "build") (print "Deleted build directory.")) (phony "clean" [] (rm "build") (print "Deleted build directory."))
(phony "test" ["build"] (phony "test" ["build"]
(defn dodir (defn dodir