-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnanovg.nimble
74 lines (59 loc) · 2.38 KB
/
nanovg.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
# Package
version = "0.2.0"
author = "Joey Yakimowich-Payne"
description = "A wrapper around nanovg"
license = "MIT"
srcDir = "src"
# Dependencies
requires "nim >= 1.0.6",
"https://github.com/jyapayne/nimterop#head",
"opengl >= 1.2.6",
"sdl2#head",
"https://github.com/jyapayne/nim-glew#head",
"https://github.com/jyapayne/nim-glfw#head",
"zip#0.3.1"
import os
proc setupBuildDir(buildDir: string, prefixes: openArray[string]) =
var arch = ""
if system.existsDir(buildDir):
rmDir buildDir
if defined(amd64):
arch = "64bit"
else:
arch = "32bit"
mkDir buildDir
if not defined(windows):
return
var files = listFiles "lib/" & arch & "/"
for fpath in files:
let fname = fpath.extractFileName()
for prefix in prefixes:
if fname.startsWith(prefix):
cpFile fpath, buildDir & "/" & fname
proc setupGLFW(): string =
switch("define", "useGlfw")
let buildDir = "build/demo"
setupBuildDir(buildDir, ["gl"])
return buildDir
proc setupSDL2(): string =
let buildDir = "build/demosdl2"
setupBuildDir(buildDir, ["lib", "SDL2", "glew"])
return buildDir
task buildSDL2Example, "Build SDL2 example":
let buildDir = setupSDL2()
exec "nimble c --app:gui -d:release -d:danger -o:" & buildDir & "/" & "demo_sdl2".toExe & " -r examples/demo_sdl2.nim"
task buildSDL2ExampleDebug, "Build SDL2 example debug":
let buildDir = setupSDL2()
exec "nimble c --app:gui --debugger:native -o:" & buildDir & "/" & "demo_sdl2_debug".toExe & " -r examples/demo_sdl2.nim"
task buildSDL2GPUExample, "Build SDL2 GPU example":
let buildDir = setupSDL2()
exec "nimble c --app:gui -d:release -d:danger -o:" & buildDir & "/" & "demo_sdl2_gpu".toExe & " -r examples/demo_sdl2_gpu.nim"
task buildSDL2GPUExampleDebug, "Build SDL2 GPU debug example":
let buildDir = setupSDL2()
exec "nimble c --app:gui --debugger:native -o:" & buildDir & "/" & "demo_sdl2_gpu".toExe & " -r examples/demo_sdl2_gpu.nim"
task buildGLFWExample, "Build GLFW example":
let buildDir = setupGLFW()
exec "nimble c --app:gui -d:useGlfw -d:release -d:danger -o:" & buildDir & "/" & "demo_glfw".toExe & " -r examples/demo.nim"
task buildGLFWExampleDebug, "Build GLFW example debug":
let buildDir = setupGLFW()
exec "nimble c --app:gui --debugger:native -o:" & buildDir & "/" & "demo_glfw_debug".toExe & " -r examples/demo.nim"