Add static compilation for sdl_gpu and sdl_gfx
This commit is contained in:
parent
ecb3893453
commit
c2626726a5
5 changed files with 78 additions and 42 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -3,7 +3,8 @@
|
|||
!*.*
|
||||
|
||||
build
|
||||
generated/
|
||||
|
||||
*.out
|
||||
*.exe
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -26,8 +26,10 @@ else:
|
|||
const dlurl = "https://www.libsdl.org/release/SDL2-$1.tar.gz"
|
||||
|
||||
when defined(windows):
|
||||
const winBDir = buildDir.replace("C:\\", "/c/").replace("\\", "/")
|
||||
const winIDir = includeDir.replace("C:\\", "/c/").replace("\\", "/")
|
||||
when defined(amd64):
|
||||
const flags = &"--libdir={buildDir} --includedir={includeDir} --host=x86_64-w64-mingw32 CFLAGS=\"-fPIC\""
|
||||
const flags = &"--libdir={winBDir} --includedir={winIDir} --host=x86_64-w64-mingw32 CFLAGS=\"-fPIC\""
|
||||
else:
|
||||
const flags = &"--libdir={buildDir} --includedir={includeDir} --host=i686-w64-mingw32 CFLAGS=\"-fPIC\""
|
||||
elif defined(macosx):
|
||||
|
|
|
|||
|
|
@ -20,38 +20,36 @@ const
|
|||
|
||||
setDefines(defs.splitLines())
|
||||
|
||||
when defined(windows):
|
||||
when defined(amd64):
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=x86_64-w64-mingw32 CFLAGS=\"-fPIC -I{SDLIncludeDir}\""
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=i686-w64-mingw32 CFLAGS=\"-fPIC -I{SDLIncludeDir}\""
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} CFLAGS=\"-fPIC -I{SDLIncludeDir}\""
|
||||
static:
|
||||
let ver = getDefine("SDL2gfxPrimitivesSetVer")
|
||||
downloadUrl(fmt"http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-{ver}.tar.gz", outdir=srcDir)
|
||||
|
||||
getHeader(
|
||||
"SDL2_gfxPrimitives.h",
|
||||
dlurl = "http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-$1.tar.gz",
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_gfx,SDL_gfx",
|
||||
conFlags = flags,
|
||||
buildTypes = [btAutoConf]
|
||||
)
|
||||
# getHeader(
|
||||
# "SDL2_gfxPrimitives.h",
|
||||
# dlurl = "http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-$1.tar.gz",
|
||||
# outdir = srcDir,
|
||||
# altNames = "SDL2_gfx,SDL_gfx",
|
||||
# conFlags = flags,
|
||||
# buildTypes = [btAutoConf]
|
||||
# )
|
||||
|
||||
const ver = getDefine("SDL2gfxPrimitivesSetVer")
|
||||
const newSrcDir = srcDir / fmt"SDL2_gfx-{ver}"
|
||||
cIncludeDir(newSrcDir)
|
||||
cCompile(newSrcDir / "SDL2_gfxPrimitives.c")
|
||||
cCompile(newSrcDir / "SDL2_rotozoom.c")
|
||||
cCompile(newSrcDir / "SDL2_framerate.c")
|
||||
cCompile(newSrcDir / "SDL2_imageFilter.c")
|
||||
|
||||
static:
|
||||
when defined(macosx):
|
||||
fixStaticFile(buildDir)
|
||||
discard
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
when isDefined(SDL2gfxPrimitivesStatic):
|
||||
cImport(srcDir / "SDL2_gfxPrimitives.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_gfxprimitives.nim")
|
||||
cImport(srcDir / "SDL2_rotozoom.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_rotozoom.nim")
|
||||
cImport(srcDir / "SDL2_framerate.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_framerate.nim")
|
||||
cImport(srcDir / "SDL2_imageFilter.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_imagefilter.nim")
|
||||
else:
|
||||
cImport(srcDir / "SDL2_gfxPrimitives.h", recurse = false, dynlib="SDL2_GfxPrimitives_LPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_gfxprimitives.nim")
|
||||
cImport(srcDir / "SDL2_rotozoom.h", recurse = false, dynlib="SDL2_GfxPrimitives_LPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_rotozoom.nim")
|
||||
cImport(srcDir / "SDL2_framerate.h", recurse = false, dynlib="SDL2_GfxPrimitives_LPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_framerate.nim")
|
||||
cImport(srcDir / "SDL2_imageFilter.h", recurse = false, dynlib="SDL2_GfxPrimitives_LPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_imagefilter.nim")
|
||||
cImport(
|
||||
@[newSrcDir / "SDL2_gfxPrimitives.h", newSrcDir / "SDL2_rotozoom.h",
|
||||
newSrcDir / "SDL2_framerate.h", newSrcDir / "SDL2_imageFilter.h"],
|
||||
recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_gfx.nim"
|
||||
)
|
||||
|
|
@ -1,14 +1,16 @@
|
|||
import macros
|
||||
import os, strformat, strutils
|
||||
import sdl2
|
||||
import glew
|
||||
import nimterop/[build, cimport, globals]
|
||||
|
||||
const
|
||||
baseDir = SDLCacheDir
|
||||
sdlDir = (baseDir / "sdl2").sanitizePath
|
||||
srcDir = (baseDir / "sdl2_gpu").sanitizePath
|
||||
currentPath = getProjectPath().parentDir().sanitizePath
|
||||
generatedPath = (currentPath / "generated" / "sdl2_gpu").replace("\\", "/")
|
||||
currentProjectPath = getProjectPath().parentDir().sanitizePath
|
||||
currentPath = currentSourcePath.parentDir().parentDir().sanitizePath
|
||||
generatedPath = (currentProjectPath / "generated" / "sdl2_gpu").replace("\\", "/")
|
||||
cmakeModPath = (currentPath / "cmake" / "sdl2").replace("\\", "/")
|
||||
symbolPluginPath = (currentPath / "sdl2" / "cleansymbols.nim").sanitizePath
|
||||
|
||||
|
|
@ -20,15 +22,25 @@ const
|
|||
|
||||
setDefines(defs.splitLines())
|
||||
|
||||
getHeader(
|
||||
"SDL_gpu.h",
|
||||
giturl = "https://github.com/grimfang4/sdl-gpu",
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_gpu,SDL2_gpu_s",
|
||||
buildTypes = [btCmake],
|
||||
cmakeFlags = &"-DCMAKE_C_FLAGS=-I{SDLIncludeDir} -DCMAKE_MODULE_PATH={cmakeModPath} -DSDL2_LIBRARY={SDLDyLibPath} " &
|
||||
&"-DSDL2MAIN_LIBRARY={SDLMainLib} -DSDL2_PATH={sdlDir} -DSDL2_INCLUDE_DIR={SDLIncludeDir} -DSDL_gpu_BUILD_DEMOS=OFF"
|
||||
)
|
||||
cIncludeDir(SDLIncludeDir)
|
||||
cDefine("SDL_GPU_DISABLE_GLES", "1")
|
||||
|
||||
static:
|
||||
gitPull(
|
||||
"https://github.com/grimfang4/sdl-gpu",
|
||||
outdir=srcDir,
|
||||
checkout="f15d33ccef7f6e063ada7c435e864b7d4b663f88"
|
||||
)
|
||||
|
||||
# getHeader(
|
||||
# "SDL_gpu.h",
|
||||
# giturl = "https://github.com/grimfang4/sdl-gpu",
|
||||
# outdir = srcDir,
|
||||
# altNames = "SDL2_gpu,SDL2_gpu_s",
|
||||
# buildTypes = [btCmake],
|
||||
# cmakeFlags = &"-DCMAKE_C_FLAGS=-I{SDLIncludeDir} -DCMAKE_MODULE_PATH={cmakeModPath} -DSDL2_LIBRARY={SDLDyLibPath} " &
|
||||
# &"-DSDL2MAIN_LIBRARY={SDLMainLib} -DSDL2_PATH={sdlDir} -DSDL2_INCLUDE_DIR={SDLIncludeDir} -DSDL_gpu_BUILD_DEMOS=OFF"
|
||||
# )
|
||||
|
||||
static:
|
||||
cSkipSymbol @["Log"]
|
||||
|
|
@ -109,6 +121,27 @@ cOverride:
|
|||
LOG_LEVEL_WARNING
|
||||
LOG_LEVEL_ERROR
|
||||
|
||||
cIncludeDir(srcDir/"include")
|
||||
cIncludeDir(srcDir/"src")
|
||||
cIncludeDir(srcDir/"src"/"externals"/"stb_image")
|
||||
cIncludeDir(srcDir/"src"/"externals"/"glew"/"GL")
|
||||
cIncludeDir(srcDir/"src"/"externals"/"stb_image_write")
|
||||
|
||||
cCompile(srcDir/"src"/"externals"/"stb_image_write"/"stb_image_write.c")
|
||||
cCompile(srcDir/"src"/"SDL_gpu.c")
|
||||
cCompile(srcDir/"src"/"SDL_gpu_matrix.c")
|
||||
cCompile(srcDir/"src"/"SDL_gpu_renderer.c")
|
||||
cCompile(srcDir/"src"/"SDL_gpu_shapes.c")
|
||||
# cCompile(srcDir/"src"/"renderer_GLES_1.c")
|
||||
# cCompile(srcDir/"src"/"renderer_GLES_2.c")
|
||||
# cCompile(srcDir/"src"/"renderer_GLES_3.c")
|
||||
cCompile(srcDir/"src"/"renderer_OpenGL_1.c")
|
||||
cCompile(srcDir/"src"/"renderer_OpenGL_1_BASE.c")
|
||||
cCompile(srcDir/"src"/"renderer_OpenGL_2.c")
|
||||
cCompile(srcDir/"src"/"renderer_OpenGL_3.c")
|
||||
cCompile(srcDir/"src"/"renderer_OpenGL_4.c")
|
||||
#cCompile(srcDir/"src"/"externals"/"stb_image"/"stb_image.c")
|
||||
#cCompile(srcDir/"src"/"externals"/"stb_image_write"/"stb_image_write.c")
|
||||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,12 @@ else:
|
|||
const dlurl = "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-$1.tar.gz"
|
||||
|
||||
when defined(windows):
|
||||
const winBDir = SDLBuildDir.replace("C:\\", "/c/").replace("\\", "/")
|
||||
const winIDir = SDLIncludeDir.replace("C:\\", "/c/").replace("\\", "/")
|
||||
when defined(amd64):
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=x86_64-w64-mingw32 CFLAGS=\"-fPIC -I{SDLIncludeDir}\""
|
||||
const flags = &"--libdir={winBDir} --includedir={winIDir} --host=x86_64-w64-mingw32 CFLAGS=\"-fPIC -I{winIDir}\""
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=i686-w64-mingw32 CFLAGS=\"-fPIC -I{SDLIncludeDir}\""
|
||||
const flags = &"--libdir={winBDir} --includedir={winIDir} --host=i686-w64-mingw32 CFLAGS=\"-fPIC -I{winIDir}\""
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --with-pic CFLAGS=\"-fPIC -I{SDLIncludeDir}\""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue