From 944f13a88303902453e38e2ce46cea7e67cf228b Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sun, 23 Aug 2020 20:36:50 -0600 Subject: [PATCH] Use isDefined --- nim.cfg | 7 ------- sdl2.nimble | 2 +- src/sdl2/sdl2.nim | 12 ++++++++++-- src/sdl2/sdl2_gfx.nim | 11 ++++++++++- src/sdl2/sdl2_gpu.nim | 10 +++++++++- src/sdl2/sdl2_image.nim | 11 ++++++++++- src/sdl2/sdl2_mixer.nim | 10 +++++++++- src/sdl2/sdl2_net.nim | 10 +++++++++- src/sdl2/sdl2_ttf.nim | 10 +++++++++- 9 files changed, 67 insertions(+), 16 deletions(-) diff --git a/nim.cfg b/nim.cfg index 1bd5aad..e69de29 100644 --- a/nim.cfg +++ b/nim.cfg @@ -1,7 +0,0 @@ --d:SDL_SetVer="2.0.12" -d:SDL_DL -d:SDL_Static --d:SDL_ImageSetVer="2.0.5" -d:SDL_Image_DL -d:SDL_Image_Static --d:SDL_NetSetVer="2.0.1" -d:SDL_Net_DL -d:SDL_Net_Static --d:SDL_MixerSetVer="2.0.4" -d:SDL_Mixer_DL -d:SDL_Mixer_Static --d:SDL_ttf_SetVer="2.0.15" -d:SDL_TTF_DL -d:SDL_ttf_Static --d:SDL_GpuSetVer="def5ea1" -d:SDL_GPU_Git -d:SDL_Gpu_Static --d:SDL2_GFXPrimitivesSetVer="1.0.4" -d:SDL2_GFXPrimitives_DL -d:SDL2_GFXPrimitives_Static -d:SDL2_GFX_Static \ No newline at end of file diff --git a/sdl2.nimble b/sdl2.nimble index e935efa..b8240d8 100644 --- a/sdl2.nimble +++ b/sdl2.nimble @@ -1,6 +1,6 @@ # Package -version = "0.1.0" +version = "0.2.0" author = "Joey Yakimowich-Payne" description = "SDL2 Autogenerated wrapper" license = "MIT" diff --git a/src/sdl2/sdl2.nim b/src/sdl2/sdl2.nim index 634438a..2dee40c 100644 --- a/src/sdl2/sdl2.nim +++ b/src/sdl2/sdl2.nim @@ -9,6 +9,14 @@ const includeDir = (srcDir / "include").sanitizePath symbolPluginPath = (currentSourcePath.parentDir() / "cleansymbols.nim").sanitizePath + defs = """ + SDLSetVer=2.0.12 + SDLDL + SDLStatic + """ + +setDefines(defs.splitLines()) + when defined(windows): const dlurl = "https://www.libsdl.org/release/SDL2-$1.zip" else: @@ -174,7 +182,7 @@ static: if "lSDL2" in line: return line.strip()#.replace("-lSDL2 ", "").replace("-lSDL2main ", "") - when defined(SDL_Static): + when isDefined(SDLStatic): when defined(windows): #TODO: Find a way to automate this on Windows reliably const conf = &"-lmingw32 {SDLStaticLib} {SDLMainLib} -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc" @@ -222,7 +230,7 @@ when defined(macosx): else: {.passC: "-fPIC".} -when defined(SDL_Static): +when isDefined(SDLStatic): cImport(srcDir/"include"/"SDL.h", recurse = true, flags = "-f=ast2 -H -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_") else: cImport(srcDir/"include"/"SDL.h", recurse = true, dynlib = "SDL_LPath", flags = "-f=ast2 -H -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_") diff --git a/src/sdl2/sdl2_gfx.nim b/src/sdl2/sdl2_gfx.nim index 45af8aa..96f68f5 100644 --- a/src/sdl2/sdl2_gfx.nim +++ b/src/sdl2/sdl2_gfx.nim @@ -8,6 +8,15 @@ const buildDir = srcDir / ".libs" symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim" + defs = """ + SDL2gfxPrimitivesSetVer=1.0.4 + SDL2gfxPrimitivesDL + SDL2gfxPrimitivesStatic + SDL2gfxStatic + """ + +setDefines(defs.splitLines()) + when defined(windows): when defined(amd64): const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=x86_64-w64-mingw32 CFLAGS=\"-fPIC -I{SDLIncludeDir}\"" @@ -33,7 +42,7 @@ static: cPluginPath(symbolPluginPath) -when defined(SDL2_GfxPrimitives_Static): +when isDefined(SDL2gfxPrimitivesStatic): cImport(srcDir / "SDL2_gfxPrimitives.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H") cImport(srcDir / "SDL2_rotozoom.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H") cImport(srcDir / "SDL2_framerate.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H") diff --git a/src/sdl2/sdl2_gpu.nim b/src/sdl2/sdl2_gpu.nim index ab534aa..767f4c9 100644 --- a/src/sdl2/sdl2_gpu.nim +++ b/src/sdl2/sdl2_gpu.nim @@ -10,6 +10,14 @@ const cmakeModPath = (currentPath / "cmake" / "sdl2").replace("\\", "/") symbolPluginPath = (currentPath / "sdl2" / "cleansymbols.nim").sanitizePath + defs = """ + SDLgpuSetVer=def5ea1 + SDLgpuGit + SDLgpuStatic + """ + +setDefines(defs.splitLines()) + getHeader( "SDL_gpu.h", giturl = "https://github.com/grimfang4/sdl-gpu", @@ -102,7 +110,7 @@ cOverride: cPluginPath(symbolPluginPath) -when defined(SDL_gpu_Static): +when isDefined(SDLgpuStatic): cImport(srcDir/"include"/"SDL_gpu.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H") else: cImport(srcDir/"include"/"SDL_gpu.h", recurse = false, dynlib = "SDL_gpuLPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H") diff --git a/src/sdl2/sdl2_image.nim b/src/sdl2/sdl2_image.nim index 37f8a54..5538be5 100644 --- a/src/sdl2/sdl2_image.nim +++ b/src/sdl2/sdl2_image.nim @@ -8,6 +8,15 @@ const buildDir = srcDir / ".libs" symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim" + defs = """ + SDLimageSetVer=2.0.5 + SDLimageDL + SDLimageStatic + """ + +setDefines(defs.splitLines()) + + when defined(windows): const dlurl = "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-$1.zip" else: @@ -52,7 +61,7 @@ cIncludeDir(SDLIncludeDir) {.passL: "-lwebp -lpng -ltiff -ljpeg".} -when defined(SDL_image_Static): +when isDefined(SDLimageStatic): cImport(srcDir/"SDL_image.h", recurse = false, flags = &"-f=ast2 -H") else: cImport(srcDir/"SDL_image.h", recurse = false, dynlib = "SDL_image_LPath", flags = &"-f=ast2 -H") diff --git a/src/sdl2/sdl2_mixer.nim b/src/sdl2/sdl2_mixer.nim index f0cc214..27b3034 100644 --- a/src/sdl2/sdl2_mixer.nim +++ b/src/sdl2/sdl2_mixer.nim @@ -8,6 +8,14 @@ const buildDir = srcDir / "build" / ".libs" symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim" + defs = """ + SDLmixerSetVer=2.0.4 + SDLmixerDL + SDLmixerStatic + """ + +setDefines(defs.splitLines()) + when defined(windows): const dlurl = "https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-$1.zip" else: @@ -44,7 +52,7 @@ cOverride: cPluginPath(symbolPluginPath) -when defined(SDL_Mixer_Static): +when isDefined(SDLmixerStatic): cImport(srcDir/"SDL_mixer.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H") else: cImport(srcDir/"SDL_mixer.h", recurse = false, dynlib = "SDL_mixer_LPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H") diff --git a/src/sdl2/sdl2_net.nim b/src/sdl2/sdl2_net.nim index 65cd58d..37cd89f 100644 --- a/src/sdl2/sdl2_net.nim +++ b/src/sdl2/sdl2_net.nim @@ -8,6 +8,14 @@ const buildDir = srcDir / ".libs" symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim" + defs = """ + SDLnetSetVer=2.0.1 + SDLnetDL + SDLnetStatic + """ + +setDefines(defs.splitLines()) + when defined(windows): const dlurl = "https://www.libsdl.org/projects/SDL_net/release/SDL2_net-$1.zip" else: @@ -42,7 +50,7 @@ cOverride: cPluginPath(symbolPluginPath) -when defined(SDL_net_Static): +when isDefined(SDLnetStatic): cImport(srcDir / "SDL_net.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H") cImport(srcDir / "SDLnetsys.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H") else: diff --git a/src/sdl2/sdl2_ttf.nim b/src/sdl2/sdl2_ttf.nim index 5c1ce5e..ca800b6 100644 --- a/src/sdl2/sdl2_ttf.nim +++ b/src/sdl2/sdl2_ttf.nim @@ -10,6 +10,14 @@ const currentPath = currentSourcePath().parentDir().parentDir().sanitizePath symbolPluginPath = (currentPath / "sdl2" / "cleansymbols.nim").sanitizePath + defs = """ + SDLttfSetVer=2.0.15 + SDLttfDL + SDLttfStatic + """ + +setDefines(defs.splitLines()) + when defined(windows): const dlurl = "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$1.zip" else: @@ -46,7 +54,7 @@ cOverride: GetError* = "" SetError* = "" -when defined(SDL_ttf_Static): +when isDefined(SDLttfStatic): cImport(srcDir / "SDL_ttf.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H") else: cImport(srcDir / "SDL_ttf.h", recurse = false, dynlib = "SDL_ttf_LPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H")