Fix sdl2_image builds
This commit is contained in:
parent
3a71315981
commit
cd0d409173
2 changed files with 29 additions and 7 deletions
|
|
@ -175,8 +175,6 @@ static:
|
||||||
{.passL: &"{conf}".}
|
{.passL: &"{conf}".}
|
||||||
|
|
||||||
echo conf
|
echo conf
|
||||||
when defined(SDL_Static):
|
|
||||||
{.passC: "-static".}
|
|
||||||
|
|
||||||
# let pathenv = getEnv("PATH")
|
# let pathenv = getEnv("PATH")
|
||||||
# when defined(windows):
|
# when defined(windows):
|
||||||
|
|
@ -199,6 +197,8 @@ static:
|
||||||
# putEnv("DYLD_LIBRARY_PATH", &"{buildDir}:{buildDir.unixizePath}:{dyldpath}")
|
# putEnv("DYLD_LIBRARY_PATH", &"{buildDir}:{buildDir.unixizePath}:{dyldpath}")
|
||||||
# putEnv("SDL2_PATH", srcDir)
|
# putEnv("SDL2_PATH", srcDir)
|
||||||
|
|
||||||
|
{.passC: "-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -fPIC".}
|
||||||
|
|
||||||
when defined(SDL_Static):
|
when defined(SDL_Static):
|
||||||
cImport(srcDir/"include"/"SDL.h", recurse = true, flags = "-f=ast2 -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_")
|
cImport(srcDir/"include"/"SDL.h", recurse = true, flags = "-f=ast2 -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_")
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ const
|
||||||
baseDir = SDLCacheDir
|
baseDir = SDLCacheDir
|
||||||
sdlIncludeDir = baseDir / "sdl2" / "include"
|
sdlIncludeDir = baseDir / "sdl2" / "include"
|
||||||
srcDir = baseDir / "sdl2_image"
|
srcDir = baseDir / "sdl2_image"
|
||||||
|
buildDir = srcDir / ".libs"
|
||||||
symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim"
|
symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim"
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
|
|
@ -21,6 +22,8 @@ when defined(windows):
|
||||||
else:
|
else:
|
||||||
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir}"
|
const flags = &"--libdir={SDLBuildDir} --includedir={SDLIncludeDir}"
|
||||||
|
|
||||||
|
{.passC: "-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -fPIC".}
|
||||||
|
|
||||||
getHeader(
|
getHeader(
|
||||||
"SDL_image.h",
|
"SDL_image.h",
|
||||||
dlurl = dlurl,
|
dlurl = dlurl,
|
||||||
|
|
@ -30,7 +33,25 @@ getHeader(
|
||||||
buildTypes = [btAutoConf]
|
buildTypes = [btAutoConf]
|
||||||
)
|
)
|
||||||
|
|
||||||
# static:
|
proc findStaticlib(): string =
|
||||||
|
const pathRegex = "(lib)?SDL2_image[0-9.\\-]*\\.a"
|
||||||
|
return findFile(pathRegex, buildDir, regex = true)
|
||||||
|
|
||||||
|
static:
|
||||||
|
when defined(macosx):
|
||||||
|
# For some reason on MacOSX Catalina, the default static
|
||||||
|
# binary is linked weird and causes the error:
|
||||||
|
# "ld: warning: ignoring file
|
||||||
|
# /path/to/sdl2_image/.libs/libSDL2_image.a,
|
||||||
|
# building for macOS-x86_64 but attempting to link
|
||||||
|
# with file built for macOS-x86_64"
|
||||||
|
#
|
||||||
|
# Simply recombining the object files into a static file seems to work
|
||||||
|
let staticFile = findStaticlib()
|
||||||
|
rmFile(staticFile)
|
||||||
|
let res = execAction(&"ar ru {staticFile} {buildDir}/*.o")
|
||||||
|
if res.ret != 0:
|
||||||
|
raise newException(CatchableError, &"Error: could not build static lib {staticFile}")
|
||||||
# cDebug()
|
# cDebug()
|
||||||
# cDisableCaching()
|
# cDisableCaching()
|
||||||
|
|
||||||
|
|
@ -41,8 +62,9 @@ cOverride:
|
||||||
ClearError* = ""
|
ClearError* = ""
|
||||||
|
|
||||||
cPluginPath(symbolPluginPath)
|
cPluginPath(symbolPluginPath)
|
||||||
|
cIncludeDir(sdlIncludeDir)
|
||||||
|
|
||||||
when defined(SDL_image_Static):
|
when defined(SDL_image_Static):
|
||||||
cImport(srcDir/"SDL_image.h", recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
cImport(srcDir/"SDL_image.h", recurse = false, flags = &"-f=ast2")
|
||||||
else:
|
else:
|
||||||
cImport(srcDir/"SDL_image.h", recurse = false, dynlib = "SDL_image_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
cImport(srcDir/"SDL_image.h", recurse = false, dynlib = "SDL_image_LPath", flags = &"-f=ast2")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue