Compare commits
29 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2626726a5 | ||
|
|
ecb3893453 | ||
|
|
35fa045a2b | ||
|
|
ff7d334aca | ||
|
|
2147301423 | ||
|
|
bfb9723c40 | ||
|
|
e2dfe815ab | ||
|
|
fd07f1580e | ||
|
|
de10044993 | ||
|
|
944f13a883 | ||
|
|
6ed15c4290 | ||
|
|
efca20435c | ||
|
|
a29c775cb3 | ||
|
|
e0ba50171b | ||
|
|
8278bc5c9c | ||
|
|
4bc788884c | ||
|
|
cd0d409173 | ||
|
|
3a71315981 | ||
|
|
dbaa8e9a7a | ||
|
|
20d775d019 | ||
|
|
5fcccc9e8f | ||
|
|
6c0ddc6856 | ||
|
|
e027beba4e | ||
|
|
90c4554c7e | ||
|
|
64f80bdd4a |
||
|
|
7eeea9c1f2 |
||
|
|
dd0c4025f8 | ||
|
|
e33d11c221 | ||
|
|
13bb7848ad |
13 changed files with 580 additions and 245 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -3,6 +3,8 @@
|
|||
!*.*
|
||||
|
||||
build
|
||||
generated/
|
||||
|
||||
*.out
|
||||
*.exe
|
||||
.DS_Store
|
||||
76
README.md
76
README.md
|
|
@ -1,37 +1,61 @@
|
|||
## Welcome to GitHub Pages
|
||||
# nim-sdl2
|
||||
|
||||
You can use the [editor on GitHub](https://github.com/jyapayne/nim-sdl2/edit/gh-pages/README.md) to maintain and preview the content for your website in Markdown files.
|
||||
NOTE: This project is not in a ready to use state yet. Working on adding support for Windows & Linux.
|
||||
|
||||
Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files.
|
||||
Autogenerated Nim bindings around SDL2. These bindings should be complete.
|
||||
|
||||
### Markdown
|
||||
Bindings are autogenerated at compile time and all related libraries are downloaded and built for you as well. You can specify the version of each SDL2 lib using the information in the Configuration section below.
|
||||
|
||||
Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for
|
||||
## Installation
|
||||
|
||||
```markdown
|
||||
Syntax highlighted code block
|
||||
|
||||
# Header 1
|
||||
## Header 2
|
||||
### Header 3
|
||||
|
||||
- Bulleted
|
||||
- List
|
||||
|
||||
1. Numbered
|
||||
2. List
|
||||
|
||||
**Bold** and _Italic_ and `Code` text
|
||||
|
||||
[Link](url) and 
|
||||
```
|
||||
nimble install nim_sdl2
|
||||
```
|
||||
|
||||
For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/).
|
||||
## Usage
|
||||
|
||||
### Jekyll Themes
|
||||
Examples are coming. To import (and use all libs except sdl2_gpu), use
|
||||
|
||||
Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/jyapayne/nim-sdl2/settings). The name of this theme is saved in the Jekyll `_config.yml` configuration file.
|
||||
```nim
|
||||
import sdl2
|
||||
import sdl2 / sdl2_gpu
|
||||
```
|
||||
|
||||
### Support or Contact
|
||||
If you want to only use specific libs, import individually:
|
||||
|
||||
Having trouble with Pages? Check out our [documentation](https://help.github.com/categories/github-pages-basics/) or [contact support](https://github.com/contact) and we’ll help you sort it out.
|
||||
```nim
|
||||
import sdl2 / sdl2
|
||||
import sdl2 / sdl2_image
|
||||
import sdl2 / sdl2_ttf
|
||||
import sdl2 / sdl2_net
|
||||
import sdl2 / sdl2_mixer
|
||||
import sdl2 / sdl2_gfx
|
||||
|
||||
import sdl2 / sdl2_gpu
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
This project uses [nimterop](https://github.com/nimterop/nimterop) to generate it's bindings and documentation.
|
||||
|
||||
As such, nimterop provides a nice configuration for choosing which versions of libraries get installed. To do so, create a `nim.cfg` file in your project's root directory (if one doesn't exist), and add the following:
|
||||
|
||||
```cfg
|
||||
-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
|
||||
```
|
||||
|
||||
Change the versions as needed above. `sdl-gpu` is in a git repo, so the version it uses is the commit hash. `SDL2_GFXPrimitives` is `sdl2-gfx`, just the naming is a bit weird. If you want to build a dynamically linked library, remove the `_Static` options above.
|
||||
|
||||
## Documentation
|
||||
|
||||
View autogenerated documentation [here](https://jyapayne.github.io/nim-sdl2).
|
||||
|
||||
All symbols and procedure definitions should be in line with their C counterparts, except with the prefixes removed (GPU_, SDL_, etc).
|
||||
|
||||
See the [SDL2 docs](https://wiki.libsdl.org/) for more information.
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
theme: jekyll-theme-slate
|
||||
7
nim.cfg
7
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
|
||||
11
sdl2.nimble
11
sdl2.nimble
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
version = "0.3.0"
|
||||
author = "Joey Yakimowich-Payne"
|
||||
description = "SDL2 Autogenerated wrapper"
|
||||
license = "MIT"
|
||||
|
|
@ -8,7 +8,7 @@ srcDir = "src"
|
|||
skipDirs = @["build"]
|
||||
|
||||
# Dependencies
|
||||
requires "nim >= 1.0.6", "nimterop#head", "regex"
|
||||
requires "nim >= 1.0.6", "https://github.com/jyapayne/nimterop#head"
|
||||
|
||||
when gorgeEx("nimble path nimterop").exitCode == 0:
|
||||
import nimterop/docs
|
||||
|
|
@ -21,3 +21,10 @@ else:
|
|||
|
||||
task buildSDL2, "Build SDL2 example":
|
||||
exec "nimble c -f -r src/sdl2.nim"
|
||||
exec "nimble c -f -r src/sdl2/sdl2_gpu.nim"
|
||||
|
||||
task test, "Test":
|
||||
buildSDL2Task()
|
||||
# Doc building doesn't work on linux yet
|
||||
when not defined(linux):
|
||||
docsTask()
|
||||
|
|
|
|||
|
|
@ -1,28 +1,41 @@
|
|||
import macros, nimterop / plugin
|
||||
import strutils, regex
|
||||
import strutils
|
||||
import sets
|
||||
|
||||
proc firstLetterLower(m: RegexMatch, s: string): string =
|
||||
if m.groupsCount > 0 and m.group(0).len > 0:
|
||||
return s[m.group(0)[0]].toLowerAscii
|
||||
template camelCase(str: string): string =
|
||||
var res = newStringOfCap(str.len)
|
||||
var i = 0
|
||||
while i < str.len:
|
||||
if str[i] == '_' and i < str.len - 1:
|
||||
res.add(str[i+1].toUpperAscii)
|
||||
i += 1
|
||||
else:
|
||||
res.add(str[i])
|
||||
i += 1
|
||||
res
|
||||
|
||||
proc camelCase(m: RegexMatch, s: string): string =
|
||||
if m.groupsCount > 0 and m.group(0).len > 0:
|
||||
return s[m.group(0)[0]].toUpperAscii
|
||||
template lowerFirstLetter(str, rep: string): string =
|
||||
if str.startsWith(rep):
|
||||
var res = str[rep.len .. ^1]
|
||||
res[0] = res[0].toLowerAscii
|
||||
res
|
||||
else:
|
||||
str
|
||||
|
||||
proc nothing(m: RegexMatch, s: string): string =
|
||||
if m.groupsCount > 0 and m.group(0).len > 0:
|
||||
return s[m.group(0)[0]]
|
||||
template removeBeginning(str, rep: string): string =
|
||||
if str.startsWith(rep):
|
||||
str[rep.len .. ^1]
|
||||
else:
|
||||
str
|
||||
|
||||
const replacements = [
|
||||
re"^GPU_(.)",
|
||||
re"^SDL_(.)",
|
||||
re"^TTF_(.)",
|
||||
re"^SDLNet_(.)",
|
||||
re"^Mix_(.)",
|
||||
re"^IMG_(.)"
|
||||
"GPU_",
|
||||
"SDL_",
|
||||
"TTF_",
|
||||
"SDLNet_",
|
||||
"Mix_",
|
||||
"IMG_"
|
||||
]
|
||||
const underscoreReg = re"_(.)"
|
||||
|
||||
const EVENT_TYPES = toHashSet([
|
||||
"FIRSTEVENT",
|
||||
|
|
@ -109,15 +122,10 @@ proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
|||
|
||||
for rep in replacements:
|
||||
if sym.kind == nskProc:
|
||||
try:
|
||||
sym.name = sym.name.replace(rep, firstLetterLower)
|
||||
except:
|
||||
discard
|
||||
sym.name = lowerFirstLetter(sym.name, rep)
|
||||
else:
|
||||
try:
|
||||
sym.name = sym.name.replace(rep, nothing)
|
||||
except:
|
||||
discard
|
||||
sym.name = removeBeginning(sym.name, rep)
|
||||
|
||||
|
||||
if sym.name.startsWith("SDLK_"):
|
||||
sym.name = sym.name.replace("SDLK_", "KEYCODE_")
|
||||
|
|
@ -139,7 +147,7 @@ proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
|||
sym.name = "SDLPRIX64"
|
||||
|
||||
if sym.kind == nskField:
|
||||
sym.name = sym.name.replace(underscoreReg, camelCase)
|
||||
sym.name = camelCase(sym.name)
|
||||
if sym.name == "type":
|
||||
sym.name = "kind"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,104 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import nimterop/[cimport, build]
|
||||
import nimterop/[cimport, build, globals]
|
||||
|
||||
const
|
||||
SDLCacheDir* = currentSourcePath.parentDir().parentDir() / "build" #getProjectCacheDir("nimsdl2")
|
||||
SDLCacheDir* = getProjectCacheDir("nimsdl2")
|
||||
baseDir = SDLCacheDir
|
||||
srcDir = baseDir / "sdl2"
|
||||
buildDir = srcDir / "buildcache"
|
||||
symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim"
|
||||
srcDir = (baseDir / "sdl2").sanitizePath
|
||||
buildDir = (srcDir / "build" / ".libs").sanitizePath
|
||||
includeDir = (srcDir / "include").sanitizePath
|
||||
currentPath = getProjectPath().parentDir().sanitizePath
|
||||
generatedPath = (currentPath / "generated" / "sdl2").replace("\\", "/")
|
||||
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:
|
||||
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={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):
|
||||
const flags = &"--libdir={buildDir} --includedir={includeDir} CFLAGS=\"-fPIC\""
|
||||
else:
|
||||
const flags = &"CFLAGS=\"-fPIC\""
|
||||
|
||||
getHeader(
|
||||
"SDL.h",
|
||||
dlurl = "https://www.libsdl.org/release/SDL2-$1.tar.gz",
|
||||
dlurl = dlurl,
|
||||
outdir = srcDir,
|
||||
cmakeFlags = "-DSDL_STATIC_PIC=ON"
|
||||
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*(dir: string): string =
|
||||
const pathRegex = "(lib)?SDL2[_-]?(static)?([a-zA-Z]+)?[0-9.\\-]*\\.a"
|
||||
return findFile(pathRegex, dir, regex = true)
|
||||
|
||||
proc findStaticMainlib(): string =
|
||||
const pathRegex = "(lib)?SDL2[_-]?(static)?[0-9.\\-]*\\main.a"
|
||||
return findFile(pathRegex, buildDir, regex = true)
|
||||
|
||||
proc fixStaticFile*(dir: string) =
|
||||
# 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(dir)
|
||||
rmFile(staticFile)
|
||||
let res = execAction(&"ar ru {staticFile} {dir}/*.o")
|
||||
if res.ret != 0:
|
||||
raise newException(CatchableError, &"Error: could not build static lib {staticFile}: {res.output}")
|
||||
let ranres = execAction(&"ranlib {staticFile}")
|
||||
if ranres.ret != 0:
|
||||
raise newException(CatchableError, &"Error: could not build static lib {staticFile}: {ranres.output}")
|
||||
|
||||
const SDLDyLibPath* = findDynlib()
|
||||
const SDLMainLib* = findStaticMainlib()
|
||||
const SDLStaticLib* = findStaticlib(buildDir)
|
||||
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 @[
|
||||
"bool", "compile_time_assert_SDL_Event", "INLINE", "FUNCTION",
|
||||
"FILE", "LINE", "PRIu64", "PRIx64", "SDLPRIX64", "assert_state",
|
||||
"assert_data",
|
||||
"assert_data", "NULL"
|
||||
# "SDL_AssertState", "SDL_AssertData", "SDL_threadID", "SDL_Keycode", "SDL_HapticConstant", "SDL_HapticRamp", "SDL_HapticLeftRight", "SDL_HapticCustom", "SDL_HapticPause", "SDL_Log"
|
||||
]
|
||||
# cDebug()
|
||||
|
|
@ -98,33 +176,69 @@ cOverride:
|
|||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
proc unixizePath*(path: string, noQuote = false, sep = $DirSep): string =
|
||||
result = path.multiReplace([("C:\\", "/c/"), (sep, "/")])
|
||||
if not noQuote:
|
||||
result = result.quoteShell
|
||||
|
||||
static:
|
||||
when SDL_Static:
|
||||
const conf = staticExec(&"cd {srcDir}; ./sdl2-config --static-libs || (./configure --silent; ./sdl2-config --static-libs)").replace("-lSDL2 ", "").split('\n')[^1]
|
||||
else:
|
||||
const conf = staticExec(&"cd {srcDir}; ./sdl2-config --libs || (./configure --silent; ./sdl2-config --libs)").split('\n')[^1]
|
||||
{.passL: conf.}
|
||||
proc getLibOutput(output: string): string =
|
||||
for line in output.split('\l'):
|
||||
if "lSDL2" in line:
|
||||
return line.strip()#.replace("-lSDL2 ", "").replace("-lSDL2main ", "")
|
||||
|
||||
when defined(SDL_Static):
|
||||
cImport(SDL_Path, recurse = true, flags = "-f=ast2 -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_")
|
||||
else:
|
||||
cImport(SDL_Path, recurse = true, dynlib = "SDL_LPath", flags = "-f=ast2 -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_")
|
||||
|
||||
proc getDynlibExt(): string =
|
||||
when isDefined(SDLStatic):
|
||||
when defined(windows):
|
||||
result = ".dll"
|
||||
elif defined(linux):
|
||||
result = ".so[0-9.]*"
|
||||
elif defined(macosx):
|
||||
result = ".dylib[0-9.]*"
|
||||
#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"
|
||||
else:
|
||||
const cmd = &"cd {srcDir.sanitizePath} && bash ./sdl2-config --static-libs"
|
||||
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 = &"-L{buildDir} -lmingw32 -lSDL2main -lSDL2 -mwindows"
|
||||
else:
|
||||
const cmd = &"cd {srcDir} && bash ./sdl2-config --libs"
|
||||
const conf = execAction(cmd).output.getLibOutput
|
||||
|
||||
proc findDynlib(): string =
|
||||
const pathRegex = "(lib)?SDL2[_-]?(static)?[0-9.\\-]*\\" & getDynlibExt()
|
||||
return findFile(pathRegex, buildDir, regex = true)
|
||||
when defined(linux):
|
||||
{.passL: &"{conf} -Wl,--no-as-needed -ldl -lsndio".}
|
||||
else:
|
||||
{.passL: &"{conf}".}
|
||||
|
||||
const SDLDyLibPath* = findDynlib()
|
||||
const SDLMainLib* = buildDir / "libSDL2main.a"
|
||||
const SDLStaticLib* = buildDir / "libSDL2.a"
|
||||
echo conf
|
||||
|
||||
# let pathenv = getEnv("PATH")
|
||||
# when defined(windows):
|
||||
# putEnv("PATH", buildDir & ";" & pathenv)
|
||||
# else:
|
||||
# putEnv("PATH", buildDir & ":" & pathenv)
|
||||
let cflags = getEnv("CFLAGS")
|
||||
putEnv("CFLAGS", &"-I{includeDir} -fPIC {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("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(macosx):
|
||||
{.passC: "-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk".}
|
||||
else:
|
||||
{.passC: "-fPIC".}
|
||||
|
||||
when isDefined(SDLStatic):
|
||||
cImport(srcDir/"include"/"SDL.h", recurse = true, flags = "-f=ast2 -H -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_", nimFile = generatedPath / "sdl2.nim")
|
||||
else:
|
||||
cImport(srcDir/"include"/"SDL.h", recurse = true, dynlib = "SDL_LPath", flags = "-f=ast2 -H -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_", nimFile = generatedPath / "sdl2.nim")
|
||||
|
||||
const
|
||||
WINDOWPOS_UNDEFINED* = WINDOWPOS_UNDEFINED_DISPLAY(0)
|
||||
|
|
|
|||
|
|
@ -1,33 +1,55 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import sdl2
|
||||
import nimterop/[cimport, build]
|
||||
import nimterop/[cimport, build, globals]
|
||||
|
||||
const
|
||||
baseDir = SDLCacheDir
|
||||
sdlIncludeDir = baseDir / "sdl2" / "include"
|
||||
srcDir = baseDir / "sdl2_gfx"
|
||||
buildDir = srcDir / ".libs"
|
||||
currentPath = getProjectPath().parentDir().sanitizePath
|
||||
generatedPath = (currentPath / "generated" / "sdl2_gfx").replace("\\", "/")
|
||||
symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim"
|
||||
|
||||
getHeader(
|
||||
"SDL2_gfxPrimitives.h",
|
||||
dlurl = "http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-$1.tar.gz",
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_gfx,SDL_gfx"
|
||||
)
|
||||
defs = """
|
||||
SDL2gfxPrimitivesSetVer=1.0.4
|
||||
SDL2gfxPrimitivesDL
|
||||
SDL2gfxPrimitivesStatic
|
||||
SDL2gfxStatic
|
||||
"""
|
||||
|
||||
# static:
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
setDefines(defs.splitLines())
|
||||
|
||||
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]
|
||||
# )
|
||||
|
||||
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:
|
||||
discard
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
when defined(SDL2_GfxPrimitives_Static):
|
||||
cImport(srcDir / "SDL2_gfxPrimitives.h", recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir / "SDL2_rotozoom.h", recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir / "SDL2_framerate.h", recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir / "SDL2_imageFilter.h", recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
else:
|
||||
cImport(srcDir / "SDL2_gfxPrimitives.h", recurse = false, dynlib="SDL2_GfxPrimitives_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir / "SDL2_rotozoom.h", recurse = false, dynlib="SDL2_GfxPrimitives_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir / "SDL2_framerate.h", recurse = false, dynlib="SDL2_GfxPrimitives_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir / "SDL2_imageFilter.h", recurse = false, dynlib="SDL2_GfxPrimitives_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
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,24 +1,46 @@
|
|||
import macros
|
||||
import os, strformat, strutils
|
||||
import sdl2
|
||||
import nimterop/[build, cimport]
|
||||
import glew
|
||||
import nimterop/[build, cimport, globals]
|
||||
|
||||
const
|
||||
baseDir = SDLCacheDir
|
||||
sdlDir = baseDir / "sdl2"
|
||||
sdlIncludeDir = sdlDir / "include"
|
||||
srcDir = baseDir / "sdl2_gpu"
|
||||
currentPath = currentSourcePath().parentDir().parentDir()
|
||||
cmakeModPath = currentPath / "cmake" / "sdl2"
|
||||
symbolPluginPath = currentPath / "sdl2" / "cleansymbols.nim"
|
||||
sdlDir = (baseDir / "sdl2").sanitizePath
|
||||
srcDir = (baseDir / "sdl2_gpu").sanitizePath
|
||||
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
|
||||
|
||||
getHeader(
|
||||
"SDL_gpu.h",
|
||||
giturl = "https://github.com/grimfang4/sdl-gpu",
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_gpu",
|
||||
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"
|
||||
)
|
||||
defs = """
|
||||
SDLgpuSetVer=def5ea1
|
||||
SDLgpuGit
|
||||
SDLgpuStatic
|
||||
"""
|
||||
|
||||
setDefines(defs.splitLines())
|
||||
|
||||
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"]
|
||||
|
|
@ -26,14 +48,20 @@ static:
|
|||
# cDisableCaching()
|
||||
|
||||
cOverride:
|
||||
type
|
||||
WindowFlagEnum* = WindowFlags
|
||||
LogLevelEnum* = enum
|
||||
LOG_LEVEL_INFO = 0
|
||||
LOG_LEVEL_WARNING
|
||||
LOG_LEVEL_ERROR
|
||||
const
|
||||
RENDERER_UNKNOWN* = 0.uint32
|
||||
RENDERER_OPENGL_1_BASE* = 1.uint32
|
||||
RENDERER_OPENGL_1* = 2.uint32
|
||||
RENDERER_OPENGL_2* = 3.uint32
|
||||
RENDERER_OPENGL_3* = 4.uint32
|
||||
RENDERER_OPENGL_4* = 5.uint32
|
||||
RENDERER_GLES_1* = 11.uint32
|
||||
RENDERER_GLES_2* = 12.uint32
|
||||
RENDERER_GLES_3* = 13.uint32
|
||||
RENDERER_D3D9* = 21.uint32
|
||||
RENDERER_D3D10* = 22.uint32
|
||||
RENDERER_D3D11* = 23.uint32
|
||||
|
||||
const
|
||||
NONE* = 0.uint32
|
||||
FEATURE_NON_POWER_OF_TWO* = 0x1.uint32
|
||||
FEATURE_RENDER_TARGETS* = 0x2.uint32
|
||||
|
|
@ -49,12 +77,6 @@ const
|
|||
FEATURE_GEOMETRY_SHADER* = 0x400.uint32
|
||||
FEATURE_WRAP_REPEAT_MIRRORED* = 0x800.uint32
|
||||
FEATURE_CORE_FRAMEBUFFER_OBJECTS* = 0x1000.uint32
|
||||
FEATURE_ALL_BASE* = FEATURE_RENDER_TARGETS
|
||||
FEATURE_ALL_BLEND_PRESETS* = (FEATURE_BLEND_EQUATIONS or FEATURE_BLEND_FUNC_SEPARATE)
|
||||
FEATURE_ALL_GL_FORMATS* = (FEATURE_GL_BGR or FEATURE_GL_BGRA or FEATURE_GL_ABGR)
|
||||
FEATURE_BASIC_SHADERS* = (FEATURE_FRAGMENT_SHADER or FEATURE_VERTEX_SHADER)
|
||||
FEATURE_ALL_SHADERS* = (FEATURE_FRAGMENT_SHADER or FEATURE_VERTEX_SHADER or FEATURE_GEOMETRY_SHADER)
|
||||
|
||||
INIT_ENABLE_VSYNC* = 0x1.uint32
|
||||
INIT_DISABLE_VSYNC* = 0x2.uint32
|
||||
INIT_DISABLE_DOUBLE_BUFFER* = 0x4.uint32
|
||||
|
|
@ -78,6 +100,62 @@ const
|
|||
BATCH_RGBA* = 0x10.uint32
|
||||
BATCH_RGB8* = 0x20.uint32
|
||||
BATCH_RGBA8* = 0x40.uint32
|
||||
FLIP_NONE* = 0x0.uint32
|
||||
FLIP_HORIZONTAL* = 0x1.uint32
|
||||
FLIP_VERTICAL* = 0x2.uint32
|
||||
|
||||
TYPE_BYTE* = 0x1400.uint32
|
||||
TYPE_UNSIGNED_BYTE* = 0x1401.uint32
|
||||
TYPE_SHORT* = 0x1402.uint32
|
||||
TYPE_UNSIGNED_SHORT* = 0x1403.uint32
|
||||
TYPE_INT* = 0x1404.uint32
|
||||
TYPE_UNSIGNED_INT* = 0x1405.uint32
|
||||
TYPE_FLOAT* = 0x1406.uint32
|
||||
TYPE_DOUBLE* = 0x140A.uint32
|
||||
|
||||
|
||||
type
|
||||
WindowFlagEnum* = WindowFlags
|
||||
LogLevelEnum* = enum
|
||||
LOG_LEVEL_INFO = 0
|
||||
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)
|
||||
|
||||
when isDefined(SDLgpuStatic):
|
||||
cImport(srcDir/"include"/"SDL_gpu.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_gpu.nim")
|
||||
else:
|
||||
cImport(srcDir/"include"/"SDL_gpu.h", recurse = false, dynlib = "SDL_gpuLPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_gpu.nim")
|
||||
|
||||
|
||||
let
|
||||
FEATURE_ALL_BLEND_PRESETS* = (FEATURE_BLEND_EQUATIONS or FEATURE_BLEND_FUNC_SEPARATE)
|
||||
FEATURE_ALL_GL_FORMATS* = (FEATURE_GL_BGR or FEATURE_GL_BGRA or FEATURE_GL_ABGR)
|
||||
FEATURE_BASIC_SHADERS* = (FEATURE_FRAGMENT_SHADER or FEATURE_VERTEX_SHADER)
|
||||
FEATURE_ALL_SHADERS* = (FEATURE_FRAGMENT_SHADER or FEATURE_VERTEX_SHADER or FEATURE_GEOMETRY_SHADER)
|
||||
|
||||
BATCH_XY_ST* = (BATCH_XY or BATCH_ST)
|
||||
BATCH_XYZ_ST* = (BATCH_XYZ or BATCH_ST)
|
||||
|
|
@ -94,35 +172,3 @@ const
|
|||
BATCH_XY_ST_RGBA8* = (BATCH_XY or BATCH_ST or BATCH_RGBA8)
|
||||
BATCH_XYZ_ST_RGBA8* = (BATCH_XYZ or BATCH_ST or BATCH_RGBA8)
|
||||
|
||||
FLIP_NONE* = 0x0.uint32
|
||||
FLIP_HORIZONTAL* = 0x1.uint32
|
||||
FLIP_VERTICAL* = 0x2.uint32
|
||||
|
||||
TYPE_BYTE* = 0x1400.uint32
|
||||
TYPE_UNSIGNED_BYTE* = 0x1401.uint32
|
||||
TYPE_SHORT* = 0x1402.uint32
|
||||
TYPE_UNSIGNED_SHORT* = 0x1403.uint32
|
||||
TYPE_INT* = 0x1404.uint32
|
||||
TYPE_UNSIGNED_INT* = 0x1405.uint32
|
||||
TYPE_FLOAT* = 0x1406.uint32
|
||||
TYPE_DOUBLE* = 0x140A.uint32
|
||||
|
||||
RENDERER_UNKNOWN* = 0.uint32
|
||||
RENDERER_OPENGL_1_BASE* = 1.uint32
|
||||
RENDERER_OPENGL_1* = 2.uint32
|
||||
RENDERER_OPENGL_2* = 3.uint32
|
||||
RENDERER_OPENGL_3* = 4.uint32
|
||||
RENDERER_OPENGL_4* = 5.uint32
|
||||
RENDERER_GLES_1* = 11.uint32
|
||||
RENDERER_GLES_2* = 12.uint32
|
||||
RENDERER_GLES_3* = 13.uint32
|
||||
RENDERER_D3D9* = 21.uint32
|
||||
RENDERER_D3D10* = 22.uint32
|
||||
RENDERER_D3D11* = 23.uint32
|
||||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
when defined(SDL_gpu_Static):
|
||||
cImport(SDL_gpuPath, recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
else:
|
||||
cImport(SDL_gpuPath, recurse = false, dynlib = "SDL_gpuLPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
|
|
@ -1,21 +1,57 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import sdl2
|
||||
import nimterop/[cimport, build]
|
||||
import nimterop/[cimport, build, globals]
|
||||
|
||||
const
|
||||
baseDir = SDLCacheDir
|
||||
sdlIncludeDir = baseDir / "sdl2" / "include"
|
||||
srcDir = baseDir / "sdl2_image"
|
||||
buildDir = srcDir / ".libs"
|
||||
currentPath = getProjectPath().parentDir().sanitizePath
|
||||
generatedPath = (currentPath / "generated" / "sdl2_image").replace("\\", "/")
|
||||
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:
|
||||
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={winBDir} --includedir={winIDir} --host=x86_64-w64-mingw32 CFLAGS=\"-fPIC -I{winIDir}\""
|
||||
else:
|
||||
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}\""
|
||||
|
||||
when defined(macosx):
|
||||
{.passC: "-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -fPIC".}
|
||||
else:
|
||||
{.passC: "-fPIC -I{SDLIncludeDir}".}
|
||||
|
||||
getHeader(
|
||||
"SDL_image.h",
|
||||
dlurl = "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-$1.tar.gz",
|
||||
dlurl = dlurl,
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_image"
|
||||
altNames = "SDL2_image",
|
||||
conFlags = flags,
|
||||
buildTypes = [btAutoConf]
|
||||
)
|
||||
|
||||
# static:
|
||||
static:
|
||||
when defined(macosx):
|
||||
fixStaticFile(buildDir)
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
|
|
@ -26,8 +62,11 @@ cOverride:
|
|||
ClearError* = ""
|
||||
|
||||
cPluginPath(symbolPluginPath)
|
||||
cIncludeDir(SDLIncludeDir)
|
||||
|
||||
when defined(SDL_image_Static):
|
||||
cImport(SDL_image_Path, recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
{.passL: "-lwebp -lpng -ltiff -ljpeg".}
|
||||
|
||||
when isDefined(SDLimageStatic):
|
||||
cImport(srcDir/"SDL_image.h", recurse = false, flags = &"-f=ast2 -H", nimFile = generatedPath / "sdl2_image.nim")
|
||||
else:
|
||||
cImport(SDL_image_Path, 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 -H", nimFile = generatedPath / "sdl2_image.nim")
|
||||
|
|
|
|||
|
|
@ -1,21 +1,49 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import sdl2
|
||||
import nimterop/[cimport, build]
|
||||
import nimterop/[cimport, build, globals]
|
||||
|
||||
const
|
||||
baseDir = SDLCacheDir
|
||||
sdlIncludeDir = baseDir / "sdl2" / "include"
|
||||
srcDir = baseDir / "sdl2_mixer"
|
||||
buildDir = srcDir / "build" / ".libs"
|
||||
currentPath = getProjectPath().parentDir().sanitizePath
|
||||
generatedPath = (currentPath / "generated" / "sdl2_mixer").replace("\\", "/")
|
||||
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:
|
||||
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 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}\""
|
||||
|
||||
getHeader(
|
||||
"SDL_mixer.h",
|
||||
dlurl = "https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-$1.tar.gz",
|
||||
dlurl = dlurl,
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_mixer"
|
||||
conFlags = flags,
|
||||
altNames = "SDL2_mixer",
|
||||
buildTypes = [btAutoConf]
|
||||
)
|
||||
|
||||
# static:
|
||||
static:
|
||||
when defined(macosx):
|
||||
fixStaticFile(buildDir)
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
|
|
@ -27,7 +55,7 @@ cOverride:
|
|||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
when defined(SDL_mixer_Static):
|
||||
cImport(SDL_mixer_Path, recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
when isDefined(SDLmixerStatic):
|
||||
cImport(srcDir/"SDL_mixer.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_mixer.nim")
|
||||
else:
|
||||
cImport(SDL_mixer_Path, recurse = false, dynlib = "SDL_mixer_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir/"SDL_mixer.h", recurse = false, dynlib = "SDL_mixer_LPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_mixer.nim")
|
||||
|
|
|
|||
|
|
@ -1,21 +1,49 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import sdl2
|
||||
import nimterop/[cimport, build]
|
||||
import nimterop/[cimport, build, globals]
|
||||
|
||||
const
|
||||
baseDir = SDLCacheDir
|
||||
sdlIncludeDir = baseDir / "sdl2" / "include"
|
||||
srcDir = baseDir / "sdl2_net"
|
||||
buildDir = srcDir / ".libs"
|
||||
currentPath = getProjectPath().parentDir().sanitizePath
|
||||
generatedPath = (currentPath / "generated" / "sdl2_net").replace("\\", "/")
|
||||
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:
|
||||
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 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}\""
|
||||
|
||||
getHeader(
|
||||
"SDL_net.h",
|
||||
dlurl = "https://www.libsdl.org/projects/SDL_net/release/SDL2_net-$1.tar.gz",
|
||||
dlurl = dlurl,
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_net"
|
||||
conFlags = flags,
|
||||
altNames = "SDL2_net",
|
||||
buildTypes = [btAutoConf]
|
||||
)
|
||||
|
||||
# static:
|
||||
static:
|
||||
when defined(macosx):
|
||||
fixStaticFile(buildDir)
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
|
|
@ -25,9 +53,9 @@ cOverride:
|
|||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
when defined(SDL_net_Static):
|
||||
cImport(SDL_net_Path, recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir / "SDLnetsys.h", recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
when isDefined(SDLnetStatic):
|
||||
cImport(srcDir / "SDL_net.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_net.nim")
|
||||
cImport(srcDir / "SDLnetsys.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_netsys.nim")
|
||||
else:
|
||||
cImport(SDL_net_Path, recurse = false, dynlib = "SDL_net_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir / "SDLnetsys.h", recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir / "SDL_net.h", recurse = false, dynlib = "SDL_net_LPath", flags = &"-I={sdlIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_net.nim")
|
||||
cImport(srcDir / "SDLnetsys.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_netsys.nim")
|
||||
|
|
|
|||
|
|
@ -1,26 +1,51 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import sdl2
|
||||
import nimterop/[cimport, build]
|
||||
import nimterop/[cimport, build, globals]
|
||||
|
||||
const
|
||||
baseDir = SDLCacheDir
|
||||
sdlDir = baseDir / "sdl2"
|
||||
sdlIncludeDir = sdlDir / "include"
|
||||
srcDir = baseDir / "sdl2_ttf"
|
||||
currentPath = currentSourcePath().parentDir().parentDir()
|
||||
cmakeModPath = currentPath / "cmake" / "sdl2"
|
||||
symbolPluginPath = currentPath / "sdl2" / "cleansymbols.nim"
|
||||
sdlDir = (baseDir / "sdl2").sanitizePath
|
||||
srcDir = (baseDir / "sdl2_ttf").sanitizePath
|
||||
buildDir = srcDir / ".libs"
|
||||
currentPath = getProjectPath().parentDir().sanitizePath
|
||||
generatedPath = (currentPath / "generated" / "sdl2_ttf").replace("\\", "/")
|
||||
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:
|
||||
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 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}\""
|
||||
|
||||
|
||||
getHeader(
|
||||
"SDL_ttf.h",
|
||||
dlurl = "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$1.tar.gz",
|
||||
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:
|
||||
static:
|
||||
when defined(macosx):
|
||||
fixStaticFile(buildDir)
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
|
|
@ -31,7 +56,7 @@ cOverride:
|
|||
GetError* = ""
|
||||
SetError* = ""
|
||||
|
||||
when defined(SDL_ttf_Static):
|
||||
cImport(SDL_ttf_Path, recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2 -d")
|
||||
when isDefined(SDLttfStatic):
|
||||
cImport(srcDir / "SDL_ttf.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_ttf.nim")
|
||||
else:
|
||||
cImport(SDL_ttf_Path, recurse = false, dynlib = "SDL_ttf_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
cImport(srcDir / "SDL_ttf.h", recurse = false, dynlib = "SDL_ttf_LPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_ttf.nim")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue