-
Notifications
You must be signed in to change notification settings - Fork 0
/
project.janet
152 lines (128 loc) · 3.51 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
(declare-project
:name "wjpu"
:description "bindings for wgpu and glfw - written with spork/cjanet"
:url "https://awesemble.de"
:author "Janet Brüll <[email protected]>"
:dependencies ["https://github.com/janet-lang/spork.git"]
)
(comment ```depends on glfw and webgpu, see ./WebGPU-distribution-info.txt and ./glfw/glfw-sources-here. built and "tested" this only on windows so far
todo:
- need to handle getting webgpu better than a zip file
- and cloning glfw
- needs more functions
- move helper functions request-device/adapter into auxiliary c.file
```)
(def this-os (os/which))
(def compiler-flags
(case this-os
:macos '[
"-Iglfw/include"
"-IWebGPU-distribution-wgpu/include"
"-ObjC"]
:windows '[
"/Zi"
"/FS"
"/MD"
#"/fsanitize=address"
"/c"
"/O2"
"/D_CRT_SECURE_NO_WARNINGS"
"/W3"
"-IWebGPU-distribution-wgpu/include"
"-Iwebgpu-release/include"
"-Iglfw/include"
"-Iglfw3webgpu"
#"-Ispork/src"
]
:linux '[
"-IWebGPU-distribution-wgpu/include/"
"-Iwebgpu-release/include/"
"-Iglfw/include/"
"-Iglfw3webgpu/"
]
#default
'[
"-IWebGPU-distribution-wgpu/include/"
"-Iwebgpu-release/include/"
"-Iglfw/include/"
"-Iglfw3webgpu/"
]))
(def linker-flags
(case this-os
:windows '[
"/DEBUG"
"user32.lib"
"gdi32.lib"
"winmm.lib"
"shell32.lib"
"glfw/build/src/Debug/glfw3.lib"
"WebGPU-distribution-wgpu/bin/windows-x86_64/wgpu_native.dll.lib"
#"spork/build/spork/tarray.lib"
"/NODEFAULTLIB:MSVCRTD"
#"clang_rt.asan_dynamic-x86_64.lib"
#"clang_rt.asan_dynamic_runtime_thunk-x86_64.lib
]
:macos '[
"-lpthread"
"-framework" "Cocoa"
"-framework" "CoreVideo"
"-framework" "IOKit"
"-framework" "OpenGL"
]
:linux '[
"-lpthread"
"-lX11"
"-Lglfw/build/src/"
"-lglfw"
"-LWebGPU-distribution-wgpu/bin/linux-x86_64/"
"-lwgpu_native"
]
#default
'["-lpthread"]))
(def os-defines
(case this-os
:windows {"PLATFORM_DESKTOP" true
"WEBGPU_BACKEND_WGPU" true
"WJPU_C99_FORMAT" true}
#default
{"PLATFORM_DESKTOP" true
"WEBGPU_BACKEND_WGPU" true
"WJPU_ANSI_C_FORMAT" true}))
(phony "gen" []
(os/execute ["janet" "src/glfw_wgpu_c.janet"] :p))
(def wgpu-glfw-binding
(declare-native
:name "wgpu-glfw-binding"
:cppflags [;default-cppflags
;compiler-flags]
:defines os-defines
:source [
"src/glfw_wgpu.gen.cpp"
"glfw3webgpu/glfw3webgpu.cpp"
]
:headers [
"src/glfw.aux.hpp"
"glfw3webgpu/glfw3webgpu.hpp"
"glfw/include/GLFW/glfw3.h"
"webgpu-release/include/webgpu/webgpu-release.h"
"WebGPU-distribution-wgpu/include/webgpu/webgpu.h"
"WebGPU-distribution-wgpu/include/webgpu/wgpu.h"
]
:lflags [;default-lflags
;linker-flags]
#:install true
:native-deps ["spork/tarray"]
))
(comment
(declare-source
:source ["src/wjpu.janet"]))
(declare-executable
:name "demo"
:deps @[(wgpu-glfw-binding :static)]
:entry "demo.janet")
# `jpm run repl` to run a repl with access to jaylib
(phony "repl" ["build"]
(os/execute ["janet" "-l" "./build/wjpu"] :p))
#(declare-executable
# :name "test"
# :entry "test/main.janet")