aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloe Kudryavtsev <code@toast.bunkerlabs.net>2023-04-16 17:08:11 -0400
committerChloe Kudryavtsev <code@toast.bunkerlabs.net>2023-04-16 17:08:11 -0400
commit348f30d4a9e7148166d2ff518b665e95f5f48ae0 (patch)
tree55d8e2c906b9d535b6c21f86d3d34a51a26809f8
parentmeta: use non-static config for now (diff)
meta: test for ability to build statically
-rw-r--r--project.janet21
1 files changed, 16 insertions, 5 deletions
diff --git a/project.janet b/project.janet
index b0e1994..643d00d 100644
--- a/project.janet
+++ b/project.janet
@@ -20,6 +20,15 @@
:err (:read (p :err) :all)})
([e] {:status false
:error e})))
+(defn- compiles?
+ [& flags]
+ (let [[inr inw] (os/pipe)
+ [_ out] (os/pipe)
+ [_ err] (os/pipe)
+ _ (:write inw "int main(){}")]
+ (zero? (os/execute ["cc" "-" "-xc" "-o/dev/null" ;flags]
+ :p
+ {:err err :in inr :out out}))))
(def pkgconf (let [bin? |(if ((execute $) :status) $ false)
bin (or (bin? "pkgconf") (bin? "pkg-config"))]
(fn pkgconf
@@ -38,11 +47,13 @@
ldflags (partial pkgconf ["-lcurl"] "libcurl" "--libs")
curl-c (cflags)
curl-l (ldflags)
- scurl-c (cflags "--static")
- scurl-l (cflags "--static")]
- # TODO: test scurl-c and scurl-l to pass those if applicable
- {:cflags curl-c
- :ldflags curl-l}))
+ scurl-c (cflags "--static")
+ scurl-l (ldflags "--static")]
+ (if (compiles? ;scurl-c ;scurl-l)
+ {:cflags scurl-c
+ :ldflags scurl-l}
+ {:cflags curl-c
+ :ldflags curl-l})))
(declare-native
:name "jurl/native"