-
Notifications
You must be signed in to change notification settings - Fork 15
/
project.janet
39 lines (34 loc) · 1.06 KB
/
project.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
(declare-project
:name "sqlite3"
:description "Janet bindings to SQLite."
:author "Calvin Rose"
:license "MIT"
:url "https://github.com/janet-lang/sqlite3"
:repo "git+https://github.com/janet-lang/sqlite3.git")
(def use-system-lib (= "1" (os/getenv "JANET_SYSTEM_SQLITE" 0)))
(defn pkg-config [what &opt env]
(default env {})
(def p (os/spawn ["pkg-config" ;what] :pe (merge {:out :pipe} env)))
(:wait p)
(unless (zero? (p :return-code))
(error "pkg-config failed!"))
(def v (->>
(:read (p :out) :all)
(string/trim)
(string/split " ")))
v)
(if use-system-lib
(declare-native
:name "sqlite3"
:cflags (pkg-config ["sqlite3" "--cflags"]
{"PKG_CONFIG_ALLOW_SYSTEM_CFLAGS" "1"})
:lflags (pkg-config ["sqlite3" "--libs"])
:source @["main.c"]
:defines {"USE_SYSTEM_SQLITE" use-system-lib})
(declare-native
:name "sqlite3"
:source @["sqlite3.c" "main.c"])
)
(sh-phony "update-sqlite3" []
(print "updating sqlite3 local libs ...")
(os/shell "janet dl-sqlite3"))