-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathproject.janet
48 lines (42 loc) · 1.31 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
40
41
42
43
44
45
46
47
48
(declare-project
:name "webview"
:author "Calvin Rose"
:license "MIT"
:url "https://github.com/janet-lang/webview"
:repo "git+https://github.com/janet-lang/webview.git")
(defn shell
"Helper for using pkg-config"
[cmd]
(def p (os/spawn (string/split " " cmd) :p {:in :pipe :out :pipe}))
(def output (:read (p :out) :all))
(string/replace "\n" "" output))
(def webview-def (case (os/which)
:windows "WEBVIEW_WINAPI"
:macos "WEBVIEW_COCOA"
"WEBVIEW_GTK"))
(defn parts
"Split on whitespace."
[str]
(peg/match
'{:ws (set " \t\n\r\0")
:non-ws '(some (if-not :ws 1))
:main (any (* (any :ws) :non-ws))}
str))
(def more-cflags (case (os/which)
# :windows "-lole32 -lcomctl32 -loleaut32 -luuid -mwindows" # flags are for mingw
:windows []
:macos []
(parts
(shell `pkg-config --cflags gtk+-3.0 webkit2gtk-4.0`))))
(def more-lflags (case (os/which)
# :windows "-lole32 -lcomctl32 -loleaut32 -luuid -mwindows" # flags are for mingw
:windows []
:macos ["-framework" "WebKit"]
(parts
(shell `pkg-config --libs gtk+-3.0 webkit2gtk-4.0`))))
(declare-native
:name "webview"
:cflags [;default-cflags ;more-cflags]
:lflags [;default-lflags ;more-lflags]
:defines {webview-def true}
:source @["webview.c"])