blob: 6bc12460856fd498150cebbab03232284175b1f2 (
plain) (
blame)
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
|
(declare-project
:name "jurl"
:description "Janet cUrl"
:author "Chloe Kudryavtsev <toast@bunkerlabs.net>"
:license "Unlicense"
:repo "https://github.com/CosmicToast/jurl.git"
:dependencies ["spork"])
(declare-source
:source ["jurl"])
# --- jurl/native
(defn- execute
[& args]
(try
(let [p (os/spawn args :p {:out :pipe :err :pipe})
r (os/proc-wait p)]
{:status r
:out (:read (p :out) :all)
:err (:read (p :err) :all)})
([e] {:status false
:error e})))
(def pkgconf (let [bin? |(if ((execute $) :status) $ false)
bin (or (bin? "pkgconf") (bin? "pkg-config"))]
(fn pkgconf
[defval & args]
(if bin
(string/split " " (-> bin
(execute ;args)
(get :out)
(string/trim)))
defval))))
(def curl-cflags (pkgconf []
"libcurl" "--cflags" "--static"))
(def curl-ldflags (pkgconf ["-lcurl"]
"libcurl" "--libs" "--static"))
(declare-native
:name "jurl/native"
:cflags [;default-cflags ;curl-cflags]
:ldflags [;default-lflags ;curl-ldflags]
:headers ["src/jurl.h"]
:source ["src/main.c"
"src/jurl.c"
"src/callbacks.c"
"src/cleanup.c"
"src/enums.c"
"src/errors.c"
"src/getinfo.c"
"src/mime.c"
"src/setopt.c"
"src/util.c"])
|