Fix some build issues
This commit is contained in:
parent
6c0ddc6856
commit
5fcccc9e8f
8 changed files with 131 additions and 80 deletions
|
|
@ -8,7 +8,7 @@ srcDir = "src"
|
|||
skipDirs = @["build"]
|
||||
|
||||
# Dependencies
|
||||
requires "nim >= 1.0.6", "nimterop#head", "regex"
|
||||
requires "nim >= 1.0.6", "nimterop#head", "regex >= 0.14.1"
|
||||
|
||||
when gorgeEx("nimble path nimterop").exitCode == 0:
|
||||
import nimterop/docs
|
||||
|
|
|
|||
|
|
@ -4,24 +4,62 @@ import nimterop/[cimport, build]
|
|||
const
|
||||
SDLCacheDir* = currentSourcePath.parentDir().parentDir() / "build" #getProjectCacheDir("nimsdl2")
|
||||
baseDir = SDLCacheDir
|
||||
srcDir = baseDir / "sdl2"
|
||||
buildDir = srcDir / "buildcache"
|
||||
includeDir = srcDir / "include"
|
||||
symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim"
|
||||
srcDir = (baseDir / "sdl2").sanitizePath
|
||||
buildDir = (srcDir / "build" / ".libs").sanitizePath
|
||||
includeDir = (srcDir / "include").sanitizePath
|
||||
symbolPluginPath = (currentSourcePath.parentDir() / "cleansymbols.nim").sanitizePath
|
||||
|
||||
when defined(windows):
|
||||
const dlurl = "https://www.libsdl.org/release/SDL2-$1.zip"
|
||||
else:
|
||||
const dlurl = "https://www.libsdl.org/release/SDL2-$1.tar.gz"
|
||||
|
||||
when defined(windows):
|
||||
when defined(amd64):
|
||||
const flags = &"--libdir={buildDir} --includedir={includeDir} --host=x86_64-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={buildDir} --includedir={includeDir} --host=i686-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={buildDir} --includedir={includeDir}"
|
||||
|
||||
getHeader(
|
||||
"SDL.h",
|
||||
dlurl = dlurl,
|
||||
outdir = srcDir,
|
||||
cmakeFlags = "-DSDL_STATIC_PIC=ON",
|
||||
altNames = "SDL2"
|
||||
conFlags = flags,
|
||||
altNames = "SDL2",
|
||||
buildTypes = [btAutoConf]
|
||||
)
|
||||
|
||||
proc getDynlibExt(): string =
|
||||
when defined(windows):
|
||||
result = ".dll"
|
||||
elif defined(linux):
|
||||
result = ".so[0-9.]*"
|
||||
elif defined(macosx):
|
||||
result = ".dylib[0-9.]*"
|
||||
|
||||
proc findDynlib(): string =
|
||||
const pathRegex = "(lib)?SDL2[_-]?(static)?[0-9.\\-]*\\" & getDynlibExt()
|
||||
return findFile(pathRegex, buildDir, regex = true)
|
||||
|
||||
proc findStaticlib(): string =
|
||||
const pathRegex = "(lib)?SDL2[_-]?(static)?[0-9.\\-]*\\.a"
|
||||
return findFile(pathRegex, buildDir, regex = true)
|
||||
|
||||
proc findStaticMainlib(): string =
|
||||
const pathRegex = "(lib)?SDL2[_-]?(static)?[0-9.\\-]*\\main.a"
|
||||
return findFile(pathRegex, buildDir, regex = true)
|
||||
|
||||
const SDLDyLibPath* = findDynlib()
|
||||
const SDLMainLib* = findStaticMainlib()
|
||||
const SDLStaticLib* = findStaticlib()
|
||||
const SDL2ConfigPath* = srcDir / "sdl2-config"
|
||||
const SDLSrcDir* = srcDir
|
||||
const SDLBuildDir* = buildDir
|
||||
const SDLIncludeDir* = includeDir
|
||||
|
||||
|
||||
# {.passL: "-framework GLUT -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -framework Carbon -framework CoreAudio -lm".}
|
||||
static:
|
||||
cSkipSymbol @[
|
||||
|
|
@ -105,27 +143,6 @@ cOverride:
|
|||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
static:
|
||||
# when SDL_Static:
|
||||
# when defined(windows):
|
||||
# const conf = "-lmingw32 -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"
|
||||
# else:
|
||||
# const conf = staticExec(&"cd {srcDir}; ./sdl2-config --static-libs").replace("-lSDL2 ", "").replace("-lSDL2main", "").split('\n')[^1]
|
||||
# else:
|
||||
# when defined(windows):
|
||||
# const conf = "-lmingw32 -lSDL2main -lSDL2 -mwindows"
|
||||
# else:
|
||||
# const conf = staticExec(&"cd {srcDir}; ./sdl2-config --libs || (./configure --silent; ./sdl2-config --libs)").split('\n')[^1]
|
||||
|
||||
when defined(windows):
|
||||
when defined(amd64):
|
||||
const flags = "--host=x86_64-w64-mingw32"
|
||||
else:
|
||||
const flags = "--host=i686-w64-mingw32"
|
||||
else:
|
||||
const flags = ""
|
||||
configure(srcDir.sanitizePath, "sdl2-config", flags)
|
||||
|
||||
proc unixizePath*(path: string, noQuote = false, sep = $DirSep): string =
|
||||
result = path.multiReplace([("C:\\", "/c/"), (sep, "/")])
|
||||
if not noQuote:
|
||||
|
|
@ -143,62 +160,50 @@ static:
|
|||
const conf = "-lmingw32 -lSDL2main -lSDL2 -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"
|
||||
else:
|
||||
const cmd = &"cd {srcDir.sanitizePath} && bash ./sdl2-config --static-libs"
|
||||
const conf = execAction(cmd).output.getLibOutput
|
||||
const conf = execAction(cmd).output.getLibOutput.replace("-lSDL2", SDLStaticLib)
|
||||
else:
|
||||
when defined(windows):
|
||||
#TODO: Find a way to automate this on Windows reliably
|
||||
const conf = "-lmingw32 -lSDL2main -lSDL2 -mwindows"
|
||||
else:
|
||||
const cmd = &"cd {srcDir.sanitizePath} && bash ./sdl2-config --libs"
|
||||
const cmd = &"cd {srcDir} && bash ./sdl2-config --libs"
|
||||
const conf = execAction(cmd).output.getLibOutput
|
||||
{.passL: &"-L{buildDir.sanitizePath} -L{buildDir.unixizePath} {conf} -Wl,--no-as-needed -ldl -lsndio".}
|
||||
|
||||
let pathenv = getEnv("PATH")
|
||||
when defined(windows):
|
||||
putEnv("PATH", buildDir.sanitizePath & ";" & pathenv)
|
||||
when defined(linux):
|
||||
{.passL: &"-L{buildDir} -L{buildDir.unixizePath} {conf} -Wl,--no-as-needed -ldl -lsndio".}
|
||||
else:
|
||||
putEnv("PATH", buildDir.sanitizePath & ":" & pathenv)
|
||||
putEnv("CFLAGS", "-I" & includeDir.sanitizePath)
|
||||
putEnv("LDFLAGS", &"-L{buildDir.sanitizePath} -L{buildDir.unixizePath} {conf} -Wl,--no-as-needed -lsndio -ldl") # & " " & buildDir/"libSDL2main.a")
|
||||
{.passL: &"{conf}".}
|
||||
|
||||
echo conf
|
||||
when defined(SDL_Static):
|
||||
{.passC: "-static".}
|
||||
|
||||
# let pathenv = getEnv("PATH")
|
||||
# when defined(windows):
|
||||
# putEnv("PATH", buildDir & ";" & pathenv)
|
||||
# else:
|
||||
# putEnv("PATH", buildDir & ":" & pathenv)
|
||||
let cflags = getEnv("CFLAGS")
|
||||
putEnv("CFLAGS", &"-I{includeDir} {cflags}")
|
||||
when defined(linux):
|
||||
putEnv("LDFLAGS", &"-L{buildDir} -L{buildDir.unixizePath} {conf} -Wl,--no-as-needed -lsndio -ldl") # & " " & buildDir/"libSDL2main.a")
|
||||
else:
|
||||
putEnv("LDFLAGS", &"-L{buildDir} -L{buildDir.unixizePath} {conf}") # & " " & buildDir/"libSDL2main.a")
|
||||
putEnv("SDL2_CONFIG", (srcDir/"sdl2-config").sanitizePath)
|
||||
putEnv("SDL_CONFIG", (srcDir/"sdl2-config").sanitizePath)
|
||||
putEnv("LIBS", &"-L{buildDir.sanitizePath} -L{buildDir.unixizePath}")
|
||||
putEnv("SDL_CFLAGS", "-I" & includeDir.sanitizePath)
|
||||
let ldpath = getEnv("LD_LIBRARY_PATH")
|
||||
putEnv("LD_LIBRARY_PATH", &"{buildDir.sanitizePath}:{buildDir.unixizePath}:{ldpath}")
|
||||
putEnv("SDL2_PATH", srcDir.sanitizePath)
|
||||
putEnv("SDL_LIBS", &"-L{buildDir} -L{buildDir.unixizePath} {conf}")
|
||||
# let ldpath = getEnv("LD_LIBRARY_PATH")
|
||||
# putEnv("LD_LIBRARY_PATH", &"{buildDir}:{buildDir.unixizePath}:{ldpath}")
|
||||
# when defined(macosx):
|
||||
# let dyldpath = getEnv("DYLD_LIBRARY_PATH")
|
||||
# putEnv("DYLD_LIBRARY_PATH", &"{buildDir}:{buildDir.unixizePath}:{dyldpath}")
|
||||
# putEnv("SDL2_PATH", srcDir)
|
||||
|
||||
when defined(SDL_Static):
|
||||
cImport(srcDir/"include"/"SDL.h", recurse = true, flags = "-f=ast2 -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_")
|
||||
else:
|
||||
cImport(srcDir/"include"/"SDL.h", recurse = true, dynlib = "SDL_LPath", flags = "-f=ast2 -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_")
|
||||
|
||||
proc getDynlibExt(): string =
|
||||
when defined(windows):
|
||||
result = ".dll"
|
||||
elif defined(linux):
|
||||
result = ".so[0-9.]*"
|
||||
elif defined(macosx):
|
||||
result = ".dylib[0-9.]*"
|
||||
|
||||
proc findDynlib(): string =
|
||||
const pathRegex = "(lib)?SDL2[_-]?(static)?[0-9.\\-]*\\" & getDynlibExt()
|
||||
return findFile(pathRegex, buildDir, regex = true)
|
||||
|
||||
proc findStaticlib(): string =
|
||||
const pathRegex = "(lib)?SDL2[_-]?(static)?[0-9.\\-]*\\.a"
|
||||
return findFile(pathRegex, buildDir, regex = true)
|
||||
|
||||
proc findStaticMainlib(): string =
|
||||
const pathRegex = "(lib)?SDL2[_-]?(static)?[0-9.\\-]*\\main.a"
|
||||
return findFile(pathRegex, buildDir, regex = true)
|
||||
|
||||
const SDLDyLibPath* = findDynlib()
|
||||
const SDLMainLib* = findStaticMainlib()
|
||||
const SDLStaticLib* = findStaticlib()
|
||||
const SDL2ConfigPath* = srcDir / "sdl2-config"
|
||||
const SDLSrcDir* = srcDir
|
||||
|
||||
const
|
||||
WINDOWPOS_UNDEFINED* = WINDOWPOS_UNDEFINED_DISPLAY(0)
|
||||
WINDOWPOS_CENTERED* = WINDOWPOS_CENTERED_DISPLAY(0)
|
||||
|
|
|
|||
|
|
@ -8,11 +8,21 @@ const
|
|||
srcDir = baseDir / "sdl2_gfx"
|
||||
symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim"
|
||||
|
||||
when defined(windows):
|
||||
when defined(amd64):
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=x86_64-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=i686-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir}"
|
||||
|
||||
getHeader(
|
||||
"SDL2_gfxPrimitives.h",
|
||||
dlurl = "http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-$1.tar.gz",
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_gfx,SDL_gfx"
|
||||
altNames = "SDL2_gfx,SDL_gfx",
|
||||
conFlags = flags,
|
||||
buildTypes = [btAutoConf]
|
||||
)
|
||||
|
||||
# static:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import nimterop/[build, cimport]
|
|||
const
|
||||
baseDir = SDLCacheDir
|
||||
sdlDir = (baseDir / "sdl2").sanitizePath
|
||||
sdlIncludeDir = (sdlDir / "include").sanitizePath
|
||||
srcDir = (baseDir / "sdl2_gpu").sanitizePath
|
||||
currentPath = currentSourcePath().parentDir().parentDir().sanitizePath
|
||||
cmakeModPath = (currentPath / "cmake" / "sdl2").replace("\\", "/")
|
||||
|
|
@ -16,8 +15,8 @@ getHeader(
|
|||
giturl = "https://github.com/grimfang4/sdl-gpu",
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_gpu,SDL2_gpu_s",
|
||||
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"
|
||||
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:
|
||||
|
|
@ -123,6 +122,6 @@ const
|
|||
cPluginPath(symbolPluginPath)
|
||||
|
||||
when defined(SDL_gpu_Static):
|
||||
cImport(srcDir/"include"/"SDL_gpu.h", recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir/"include"/"SDL_gpu.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2")
|
||||
else:
|
||||
cImport(srcDir/"include"/"SDL_gpu.h", recurse = false, dynlib = "SDL_gpuLPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir/"include"/"SDL_gpu.h", recurse = false, dynlib = "SDL_gpuLPath", flags = &"-I={SDLIncludeDir} -f=ast2")
|
||||
|
|
@ -13,11 +13,21 @@ when defined(windows):
|
|||
else:
|
||||
const dlurl = "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-$1.tar.gz"
|
||||
|
||||
when defined(windows):
|
||||
when defined(amd64):
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=x86_64-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=i686-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir}"
|
||||
|
||||
getHeader(
|
||||
"SDL_image.h",
|
||||
dlurl = dlurl,
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_image"
|
||||
altNames = "SDL2_image",
|
||||
conFlags = flags,
|
||||
buildTypes = [btAutoConf]
|
||||
)
|
||||
|
||||
# static:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import nimterop/[cimport, build]
|
|||
const
|
||||
baseDir = SDLCacheDir
|
||||
sdlIncludeDir = baseDir / "sdl2" / "include"
|
||||
sdlBuildDir = baseDir / "sdl2" / "buildcache"
|
||||
srcDir = baseDir / "sdl2_mixer"
|
||||
symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim"
|
||||
|
||||
|
|
@ -14,11 +13,21 @@ when defined(windows):
|
|||
else:
|
||||
const dlurl = "https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-$1.tar.gz"
|
||||
|
||||
when defined(windows):
|
||||
when defined(amd64):
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=x86_64-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=i686-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir}"
|
||||
|
||||
getHeader(
|
||||
"SDL_mixer.h",
|
||||
dlurl = dlurl,
|
||||
outdir = srcDir,
|
||||
conFlags = flags,
|
||||
altNames = "SDL2_mixer",
|
||||
buildTypes = [btAutoConf]
|
||||
)
|
||||
|
||||
# static:
|
||||
|
|
|
|||
|
|
@ -13,11 +13,21 @@ when defined(windows):
|
|||
else:
|
||||
const dlurl = "https://www.libsdl.org/projects/SDL_net/release/SDL2_net-$1.tar.gz"
|
||||
|
||||
when defined(windows):
|
||||
when defined(amd64):
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=x86_64-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=i686-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir}"
|
||||
|
||||
getHeader(
|
||||
"SDL_net.h",
|
||||
dlurl = dlurl,
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_net"
|
||||
conFlags = flags,
|
||||
altNames = "SDL2_net",
|
||||
buildTypes = [btAutoConf]
|
||||
)
|
||||
|
||||
# static:
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ const
|
|||
sdlIncludeDir = (sdlDir / "include").sanitizePath
|
||||
srcDir = (baseDir / "sdl2_ttf").sanitizePath
|
||||
currentPath = currentSourcePath().parentDir().parentDir().sanitizePath
|
||||
cmakeModPath = (currentPath / "cmake" / "sdl2").replace("\\", "/")
|
||||
symbolPluginPath = (currentPath / "sdl2" / "cleansymbols.nim").sanitizePath
|
||||
|
||||
when defined(windows):
|
||||
|
|
@ -16,13 +15,22 @@ when defined(windows):
|
|||
else:
|
||||
const dlurl = "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$1.tar.gz"
|
||||
|
||||
when defined(windows):
|
||||
when defined(amd64):
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=x86_64-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir} --host=i686-w64-mingw32"
|
||||
else:
|
||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir}"
|
||||
|
||||
|
||||
getHeader(
|
||||
"SDL_ttf.h",
|
||||
dlurl = dlurl,
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_ttf",
|
||||
cmakeFlags = &"-DCMAKE_C_FLAGS=-I{sdlIncludeDir} -DCMAKE_MODULE_PATH={cmakeModPath} " &
|
||||
&"-DSDL2MAIN_LIBRARY={SDLMainLib} -DSDL2_LIBRARY={SDLDyLibPath} -DSDL2_PATH={sdlDir}"
|
||||
conFlags = flags,
|
||||
buildTypes = [btAutoConf]
|
||||
)
|
||||
|
||||
# static:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue