-
Notifications
You must be signed in to change notification settings - Fork 1
/
project.janet
32 lines (28 loc) · 876 Bytes
/
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
(declare-project
:name "redis"
:description "A Janet Redis library built with the official hiredis C library."
:author "Andrew Chambers"
:license "MIT"
:url "https://github.com/andrewchambers/janet-redis"
:repo "git+https://github.com/andrewchambers/janet-redis.git")
(defn exec-slurp
"Read stdout of subprocess and return it trimmed in a string."
[& args]
(def proc (os/spawn args :px {:out :pipe}))
(def out (get proc :out))
(def buf @"")
(ev/gather
(:read out :all buf)
(:wait proc))
(string/trimr buf))
(defn pkg-config [& what]
(try
(string/split " " (exec-slurp "pkg-config" ;what))
([err] (error "pkg-config failed!"))))
(declare-source
:source ["redis.janet"])
(declare-native
:name "_janet_redis"
:cflags (pkg-config "hiredis" "--cflags")
:lflags (pkg-config "hiredis" "--libs")
:source ["redis.c"])