forked from floooh/sokol-nim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sokol.nimble
147 lines (119 loc) · 3.19 KB
/
sokol.nimble
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
# Package
version = "0.5.0"
author = "Andre Weissflog, Garett Bass, Gustav Olsson"
description = "Nim bindings for the sokol C headers"
license = "MIT"
srcDir = "src"
skipDirs = @["examples"]
binDir = "examples/build"
# Dependencies
requires "nim >= 1.4.4"
import strformat
let examples = [
"clear",
"triangle",
"quad",
"bufferoffsets",
"cube",
"noninterleaved",
"texcube",
"shapes",
"offscreen",
"instancing",
"mrt",
"blend",
"debugtext",
"debugtextprintf",
"debugtextuserfont",
"sgl",
"sglcontext",
"sglpoints",
"saudio"
]
let shaders = [
"triangle",
"quad",
"bufferoffsets",
"cube",
"noninterleaved",
"texcube",
"shapes",
"offscreen",
"instancing",
"mrt",
"blend"
]
proc compilerSwitch(): string =
when defined(windows):
return "--cc:vcc"
else:
return ""
proc backendSwitch(): string =
when defined gl:
return "-d:gl"
else:
return ""
proc run(name: string) =
exec &"nim r {compilerSwitch()} {backendSwitch()} examples/{name}"
# Tasks
task clear, "Runs the clear example":
run "clear"
task triangle, "Runs the triangle example":
run "triangle"
task quad, "Runs the quad example":
run "quad"
task bufferoffsets, "Run the bufferoffsets example":
run "bufferoffsets"
task cube, "Runs the cube example":
run "cube"
task noninterleaved, "Runs the noninterleaved example":
run "noninterleaved"
task texcube, "Runs the texcube example":
run "texcube"
task shapes, "Runs the shapes example":
run "shapes"
task offscreen, "Runs the offscreen example":
run "offscreen"
task instancing, "Runs the instancing smaple":
run "instancing"
task mrt, "Runs the mrt sample":
run "mrt"
task blend, "Runs the blend example":
run "blend"
task debugtext, "Runs the debugtext example":
run "debugtext"
task debugtextprintf, "Runs the debugtextprintf example":
run "debugtextprintf"
task debugtextuserfont, "Runs the debugtextuserfont example":
run "debugtextuserfont"
task sgl, "Runs the sgl example":
run "sgl"
task sglcontext, "Runs the sglcontext example":
run "sglcontext"
task sglpoints, "Runs the sglpoints example":
run "sglpoints"
task saudio, "Runs the saudio example":
run "saudio"
task build_debug, "Build all examples in debug mode":
# hmm, is there a better way?
for example in examples:
exec &"nim c --outdir:build {backendSwitch()} {compilerSwitch()} --debugger:native examples/{example}"
task build_all, "Build all examples in release mode":
# hmm, is there a better way?
for example in examples:
exec &"nim c --outdir:build {backendSwitch()} {compilerSwitch()} -d:release examples/{example}"
task shaders, "Compile all shaders (requires ../sokol-tools-bin)":
let binDir = "../sokol-tools-bin/bin/"
let shdcPath =
when defined(windows):
&"{binDir}win32/sokol-shdc"
elif defined(macosx) and defined(arm64):
&"{binDir}osx_arm64/sokol-shdc"
elif defined(macosx):
&"{binDir}osx/sokol-shdc"
else:
&"{binDir}linux/sokol-shdc"
for shader in shaders:
let cmd = &"{shdcPath} -i examples/shaders/{shader}.glsl -o examples/shaders/{shader}.nim -l glsl330:metal_macos:hlsl4 -f sokol_nim"
echo &" {cmd}"
exec cmd