From 947728809fe0dd526a524f39da2e633295959404 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sat, 11 Jan 2020 20:26:57 -0700 Subject: [PATCH] Fix some mac stuff, add more debug options --- .vscode/launch.json | 49 ++++++++++++++++++++++++++++++++++++++++-- examples/demo.nim | 2 +- nanovg.nimble | 4 +++- nim-gdb | 0 nim-gdb-mac | 20 +++++++++++++++++ src/nanovg/wrapper.nim | 2 +- 6 files changed, 72 insertions(+), 5 deletions(-) mode change 100644 => 100755 nim-gdb create mode 100755 nim-gdb-mac diff --git a/.vscode/launch.json b/.vscode/launch.json index 3ae2400..0ddca2b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,13 +6,58 @@ "configurations": [ { - "name": "Nim Debug", + "name": "Nim Debug GLFW Windows", "type": "gdb", "request": "launch", "target": "${workspaceFolder}\\build\\demo\\demo_glfw_debug.exe", "cwd": "${workspaceRoot}", "gdbpath": "${workspaceFolder}\\nim-gdb.bat", "valuesFormatting": "parseText" - } + }, + { + "name": "Nim Debug SDL2 Windows", + "type": "gdb", + "request": "launch", + "target": "${workspaceFolder}\\build\\demosdl2\\demo_sdl2_debug.exe", + "cwd": "${workspaceRoot}", + "gdbpath": "${workspaceFolder}\\nim-gdb.bat", + "valuesFormatting": "parseText" + }, + { + "name": "Nim Debug SDL2", + "type": "gdb", + "request": "launch", + "target": "${workspaceFolder}/build/demosdl2/demo_sdl2_debug", + "cwd": "${workspaceRoot}", + "gdbpath": "${workspaceFolder}/nim-gdb", + "valuesFormatting": "parseText" + }, + { + "name": "Nim Debug GLFW", + "type": "gdb", + "request": "launch", + "target": "${workspaceFolder}/build/demo/demo_glfw_debug", + "cwd": "${workspaceRoot}", + "gdbpath": "${workspaceFolder}/nim-gdb", + "valuesFormatting": "parseText" + }, + { + "name": "Nim Debug SDL2 Mac", + "type": "gdb", + "request": "launch", + "target": "${workspaceFolder}/build/demosdl2/demo_sdl2_debug", + "cwd": "${workspaceRoot}", + "gdbpath": "${workspaceFolder}/nim-gdb-mac", + "valuesFormatting": "parseText" + }, + { + "name": "Nim Debug GLFW Mac", + "type": "gdb", + "request": "launch", + "target": "${workspaceFolder}/build/demo/demo_glfw_debug", + "cwd": "${workspaceRoot}", + "gdbpath": "${workspaceFolder}/nim-gdb-mac", + "valuesFormatting": "parseText" + }, ] } \ No newline at end of file diff --git a/examples/demo.nim b/examples/demo.nim index 3574211..fc77f9b 100644 --- a/examples/demo.nim +++ b/examples/demo.nim @@ -10,7 +10,7 @@ proc main = c.version = glv32 c.title = "Minimal Nim-GLFW example" c.forwardCompat = true - c.profile = opCompatProfile + c.profile = opCoreProfile c.debugContext = false let diff --git a/nanovg.nimble b/nanovg.nimble index 4d59287..00193ec 100644 --- a/nanovg.nimble +++ b/nanovg.nimble @@ -18,6 +18,8 @@ requires "nim >= 1.0.0", import os proc setupBuildDir(buildDir: string, prefixes: openArray[string]) = + if not defined(windows): + return var arch = "" if system.existsDir(buildDir): rmDir buildDir @@ -54,7 +56,7 @@ task buildSDL2ExampleDebug, "Build SDL2 example debug": task buildGLFWExample, "Build GLFW example": let buildDir = setupGLFW() - exec "nim c --app:gui -d:release -d:danger -o:" & buildDir & "/" & "demo_glfw".toExe & " -r examples/demo.nim" + exec "nim 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() diff --git a/nim-gdb b/nim-gdb old mode 100644 new mode 100755 diff --git a/nim-gdb-mac b/nim-gdb-mac new file mode 100755 index 0000000..5d33d98 --- /dev/null +++ b/nim-gdb-mac @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Exit if anything fails +set -e + +which nim > /dev/null || (echo "nim not in PATH"; exit 1) +which gdb > /dev/null || (echo "gdb not in PATH"; exit 1) + +# Find out where the pretty printer Python module is +NIM_SYSROOT=$(dirname $(dirname $(greadlink -e $(which nim)))) +GDB_PYTHON_MODULE_PATH="$NIM_SYSROOT/tools/nim-gdb.py" + +# Run GDB with the additional arguments that load the pretty printers +# Set the environment variable `NIM_GDB` to overwrite the call to a +# different/specific command (defaults to `gdb`). +NIM_GDB="${NIM_GDB:-gdb}" +echo "source $GDB_PYTHON_MODULE_PATH" > gdbcommands.txt +# exec replaces the new process of bash with gdb. It is always good to +# have fewer processes. +exec ${NIM_GDB} --command="gdbcommands.txt" "$@" \ No newline at end of file diff --git a/src/nanovg/wrapper.nim b/src/nanovg/wrapper.nim index 4a46bf8..f934e52 100644 --- a/src/nanovg/wrapper.nim +++ b/src/nanovg/wrapper.nim @@ -71,7 +71,7 @@ cIncludeDir(srcDir/"src") when defined(macosx): # cDefine("GLFW_INCLUDE_GLCOREARB", "1") {.passC: "-DNANOVG_GL3_IMPLEMENTATION -DNANOVG_GLEW -D_GLFW_USE_RETINA -D_GLFW_COCOA -D_GLFW_USE_CHDir -D_GLFW_USE_MENUBAR".} - {.passL: "-m64 -framework GLUT -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -framework Carbon -lm".} + {.passL: "-m64 -lglew -framework GLUT -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -framework Carbon -lm".} elif defined(unix): {.passC: "-DNANOVG_GL3_IMPLEMENTATION -DNANOVG_GLEW".}