-
Notifications
You must be signed in to change notification settings - Fork 36
/
init.janet
58 lines (48 loc) · 1.3 KB
/
init.janet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(import "/spork/cc" :as cc)
(import "/spork/sh" :as sh)
(defn install [m &]
(bundle/add-file m "src/tarray.h" "tarray.h")
(bundle/add m "spork")
(each file (os/dir "build")
(def f (string "build/" file))
(when (= (os/stat f :mode) :file)
(bundle/add-file m f (string "spork/" file)))))
(defn clean [&]
(sh/rm "build"))
(defn build [&]
(os/mkdir "build")
(os/mkdir "build/objects")
(def suffix
(case (os/which)
:windows ".dll"
".so"))
(def asuffix
(case (os/which)
:windows ".lib"
".a"))
(def cc
(case (os/which)
:windows cc/msvc-compile-and-link-shared
cc/compile-and-link-shared))
(def static-cc
(case (os/which)
:windows cc/msvc-compile-and-make-archive
cc/compile-and-make-archive))
(defn make1
[name & other-srcs]
(def from (string "src/" name ".c"))
(def to (string "build/" name suffix))
(def toa (string "build/" name asuffix))
(cc to from ;other-srcs)
(static-cc toa from ;other-srcs))
(setdyn cc/*visit* cc/visit-execute-if-stale)
(setdyn cc/*build-dir* "build/objects")
(make1 "crc")
(make1 "json")
(make1 "cmath")
(make1 "utf8")
(make1 "rawterm")
(make1 "tarray")
(setdyn cc/*defines* {"_LARGEFILE64_SOURCE" true})
(make1 "zip" "deps/miniz/miniz.c")
(print "done!"))