mirror of
https://github.com/janet-lang/janet
synced 2025-02-02 10:19:10 +00:00
Remove ./build as default rule.
Instead, all compilation rules do the equivalent of mkdir -p to make sure that we can build the output file.
This commit is contained in:
parent
d8617514f8
commit
b0af01a762
21
auxbin/jpm
21
auxbin/jpm
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env janet
|
#!/usr/bin/env janet
|
||||||
|
(os/mkdir "build")
|
||||||
|
|
||||||
# CLI tool for building janet projects.
|
# CLI tool for building janet projects.
|
||||||
|
|
||||||
@ -167,7 +168,7 @@
|
|||||||
ret)
|
ret)
|
||||||
|
|
||||||
(defn check-cc
|
(defn check-cc
|
||||||
"Ensure we have a c compiler"
|
"Ensure we have a c compiler."
|
||||||
[]
|
[]
|
||||||
(if is-win
|
(if is-win
|
||||||
(do
|
(do
|
||||||
@ -177,6 +178,14 @@
|
|||||||
microsoft.com"))
|
microsoft.com"))
|
||||||
(do)))
|
(do)))
|
||||||
|
|
||||||
|
(defn create-dirs
|
||||||
|
"Create all directories needed for a file (mkdir -p)."
|
||||||
|
[dest]
|
||||||
|
(def segs (string/split "/" dest))
|
||||||
|
(for i 1 (length segs)
|
||||||
|
(def path (string/join (slice segs 0 i) "/"))
|
||||||
|
(unless (empty? path) (os/mkdir path))))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Importing a file
|
# Importing a file
|
||||||
#
|
#
|
||||||
@ -344,6 +353,7 @@
|
|||||||
(rule dest [src ;headers]
|
(rule dest [src ;headers]
|
||||||
(check-cc)
|
(check-cc)
|
||||||
(print "compiling " dest "...")
|
(print "compiling " dest "...")
|
||||||
|
(create-dirs dest)
|
||||||
(if is-win
|
(if is-win
|
||||||
(shell cc ;defines "/c" ;cflags (string "/Fo" dest) src)
|
(shell cc ;defines "/c" ;cflags (string "/Fo" dest) src)
|
||||||
(shell cc "-c" src ;defines ;cflags "-o" dest))))
|
(shell cc "-c" src ;defines ;cflags "-o" dest))))
|
||||||
@ -376,6 +386,7 @@
|
|||||||
(rule target objects
|
(rule target objects
|
||||||
(check-cc)
|
(check-cc)
|
||||||
(print "linking " target "...")
|
(print "linking " target "...")
|
||||||
|
(create-dirs target)
|
||||||
(if is-win
|
(if is-win
|
||||||
(shell linker ;lflags (string "/OUT:" target) ;objects (win-import-library))
|
(shell linker ;lflags (string "/OUT:" target) ;objects (win-import-library))
|
||||||
(shell linker ;cflags `-o` target ;objects ;lflags))))
|
(shell linker ;cflags `-o` target ;objects ;lflags))))
|
||||||
@ -387,12 +398,14 @@
|
|||||||
(rule target objects
|
(rule target objects
|
||||||
(check-cc)
|
(check-cc)
|
||||||
(print "creating static library " target "...")
|
(print "creating static library " target "...")
|
||||||
|
(create-dirs target)
|
||||||
(if is-win
|
(if is-win
|
||||||
(shell ar "/nologo" (string "/out:" target) ;objects)
|
(shell ar "/nologo" (string "/out:" target) ;objects)
|
||||||
(shell ar "rcs" target ;objects))))
|
(shell ar "rcs" target ;objects))))
|
||||||
|
|
||||||
(defn- create-buffer-c-impl
|
(defn- create-buffer-c-impl
|
||||||
[bytes dest name]
|
[bytes dest name]
|
||||||
|
(create-dirs dest)
|
||||||
(def out (file/open dest :w))
|
(def out (file/open dest :w))
|
||||||
(def chunks (seq [b :in bytes] (string b)))
|
(def chunks (seq [b :in bytes] (string b)))
|
||||||
(file/write out
|
(file/write out
|
||||||
@ -409,6 +422,7 @@
|
|||||||
[source dest name]
|
[source dest name]
|
||||||
(rule dest [source]
|
(rule dest [source]
|
||||||
(print "generating " dest "...")
|
(print "generating " dest "...")
|
||||||
|
(create-dirs dest)
|
||||||
(with [f (file/open source :r)]
|
(with [f (file/open source :r)]
|
||||||
(create-buffer-c-impl (:read f :all) dest name))))
|
(create-buffer-c-impl (:read f :all) dest name))))
|
||||||
|
|
||||||
@ -435,6 +449,7 @@
|
|||||||
(rule dest [source]
|
(rule dest [source]
|
||||||
(check-cc)
|
(check-cc)
|
||||||
(print "generating executable c source...")
|
(print "generating executable c source...")
|
||||||
|
(create-dirs dest)
|
||||||
# Load entry environment and get main function.
|
# Load entry environment and get main function.
|
||||||
(def entry-env (dofile source))
|
(def entry-env (dofile source))
|
||||||
(def main ((entry-env 'main) :value))
|
(def main ((entry-env 'main) :value))
|
||||||
@ -887,6 +902,7 @@ int main(int argc, const char **argv) {
|
|||||||
(def name (opts :name))
|
(def name (opts :name))
|
||||||
(def iname (string "build" sep name ".jimage"))
|
(def iname (string "build" sep name ".jimage"))
|
||||||
(rule iname (or (opts :deps) [])
|
(rule iname (or (opts :deps) [])
|
||||||
|
(create-dirs iname)
|
||||||
(spit iname (make-image (require entry))))
|
(spit iname (make-image (require entry))))
|
||||||
(def path (dyn :modpath JANET_MODPATH))
|
(def path (dyn :modpath JANET_MODPATH))
|
||||||
(add-dep "build" iname)
|
(add-dep "build" iname)
|
||||||
@ -906,8 +922,7 @@ int main(int argc, const char **argv) {
|
|||||||
(setdyn :manifest-dir manifests)
|
(setdyn :manifest-dir manifests)
|
||||||
(setdyn :installed-files installed-files)
|
(setdyn :installed-files installed-files)
|
||||||
|
|
||||||
(rule "./build" [] (mkdir "build"))
|
(phony "build" [])
|
||||||
(phony "build" ["./build"])
|
|
||||||
|
|
||||||
(phony "manifest" []
|
(phony "manifest" []
|
||||||
(print "generating " manifest "...")
|
(print "generating " manifest "...")
|
||||||
|
Loading…
Reference in New Issue
Block a user