Add gdb debugging capability

This commit is contained in:
Joey Yakimowich-Payne 2020-01-12 01:26:54 -07:00
commit 740a0c46f4
5 changed files with 63 additions and 23 deletions

View file

@ -17,11 +17,10 @@ requires "nim >= 1.0.0",
import os
task buildSDL2Example, "Build SDL2 example":
let buildDir = "build/demosdl2"
proc setupBuildDir(buildDir: string, prefixes: openArray[string]) =
var arch = ""
if system.existsDir(buildDir):
rmDir buildDir
var arch = ""
if defined(amd64):
arch = "64bit"
else:
@ -30,24 +29,33 @@ task buildSDL2Example, "Build SDL2 example":
var files = listFiles "lib/" & arch & "/"
for fpath in files:
let fname = fpath.extractFileName()
if fname.startsWith("lib") or fname.startsWith("SDL2") or fname.startsWith("glew"):
cpFile fpath, buildDir & "/" & fname
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 "nim 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 "nim c --app:gui --debugger:native -o:" & buildDir & "/" & "demo_sdl2_debug".toExe & " -r examples/demo_sdl2.nim"
task buildGLFWExample, "Build GLFW example":
switch("define", "useGlfw")
var arch = ""
let buildDir = "build/demo"
if system.existsDir(buildDir):
rmDir buildDir
if defined(amd64):
arch = "64bit"
else:
arch = "32bit"
mkDir buildDir
var files = listFiles "lib/" & arch & "/"
for fpath in files:
let fname = fpath.extractFileName()
if fname.startsWith("gl"):
cpFile fpath, buildDir & "/" & fname
exec "nim c --app:gui -d:release -d:danger -o:" & buildDir & "/" & "demo_glfw".toExe & " -r examples/demo.nim"
let buildDir = setupGLFW()
exec "nim c --app:gui -d:release -d:danger -o:" & buildDir & "/" & "demo_glfw".toExe & " -r examples/demo.nim"
task buildGLFWExampleDebug, "Build GLFW example debug":
let buildDir = setupGLFW()
exec "nim c --app:gui --debugger:native -o:" & buildDir & "/" & "demo_glfw_debug".toExe & " -r examples/demo.nim"