Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
273429b5c9 | ||
|
|
5d757b3170 |
13 changed files with 245 additions and 580 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -3,8 +3,6 @@
|
|||
!*.*
|
||||
|
||||
build
|
||||
generated/
|
||||
|
||||
*.out
|
||||
*.exe
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
76
README.md
76
README.md
|
|
@ -1,61 +1,37 @@
|
|||
# nim-sdl2
|
||||
## Welcome to GitHub Pages
|
||||
|
||||
NOTE: This project is not in a ready to use state yet. Working on adding support for Windows & Linux.
|
||||
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.
|
||||
|
||||
Autogenerated Nim bindings around SDL2. These bindings should be complete.
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
## Installation
|
||||
Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for
|
||||
|
||||
```
|
||||
nimble install nim_sdl2
|
||||
```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 
|
||||
```
|
||||
|
||||
## Usage
|
||||
For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/).
|
||||
|
||||
Examples are coming. To import (and use all libs except sdl2_gpu), use
|
||||
### Jekyll Themes
|
||||
|
||||
```nim
|
||||
import sdl2
|
||||
import sdl2 / sdl2_gpu
|
||||
```
|
||||
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.
|
||||
|
||||
If you want to only use specific libs, import individually:
|
||||
### Support or Contact
|
||||
|
||||
```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.
|
||||
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.
|
||||
|
|
|
|||
1
_config.yml
Normal file
1
_config.yml
Normal file
|
|
@ -0,0 +1 @@
|
|||
theme: jekyll-theme-slate
|
||||
7
nim.cfg
7
nim.cfg
|
|
@ -0,0 +1,7 @@
|
|||
-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
|
||||
13
sdl2.nimble
13
sdl2.nimble
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "0.3.0"
|
||||
version = "0.1.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", "https://github.com/jyapayne/nimterop#head"
|
||||
requires "nim >= 1.0.6", "nimterop#head", "regex"
|
||||
|
||||
when gorgeEx("nimble path nimterop").exitCode == 0:
|
||||
import nimterop/docs
|
||||
|
|
@ -20,11 +20,4 @@ else:
|
|||
task docs, "Do nothing": discard
|
||||
|
||||
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()
|
||||
exec "nimble c -f -r src/sdl2.nim"
|
||||
|
|
@ -1,41 +1,28 @@
|
|||
import macros, nimterop / plugin
|
||||
import strutils
|
||||
import strutils, regex
|
||||
import sets
|
||||
|
||||
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 firstLetterLower(m: RegexMatch, s: string): string =
|
||||
if m.groupsCount > 0 and m.group(0).len > 0:
|
||||
return s[m.group(0)[0]].toLowerAscii
|
||||
|
||||
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 camelCase(m: RegexMatch, s: string): string =
|
||||
if m.groupsCount > 0 and m.group(0).len > 0:
|
||||
return s[m.group(0)[0]].toUpperAscii
|
||||
|
||||
template removeBeginning(str, rep: string): string =
|
||||
if str.startsWith(rep):
|
||||
str[rep.len .. ^1]
|
||||
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]]
|
||||
|
||||
const replacements = [
|
||||
"GPU_",
|
||||
"SDL_",
|
||||
"TTF_",
|
||||
"SDLNet_",
|
||||
"Mix_",
|
||||
"IMG_"
|
||||
re"^GPU_(.)",
|
||||
re"^SDL_(.)",
|
||||
re"^TTF_(.)",
|
||||
re"^SDLNet_(.)",
|
||||
re"^Mix_(.)",
|
||||
re"^IMG_(.)"
|
||||
]
|
||||
const underscoreReg = re"_(.)"
|
||||
|
||||
const EVENT_TYPES = toHashSet([
|
||||
"FIRSTEVENT",
|
||||
|
|
@ -122,10 +109,15 @@ proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
|||
|
||||
for rep in replacements:
|
||||
if sym.kind == nskProc:
|
||||
sym.name = lowerFirstLetter(sym.name, rep)
|
||||
try:
|
||||
sym.name = sym.name.replace(rep, firstLetterLower)
|
||||
except:
|
||||
discard
|
||||
else:
|
||||
sym.name = removeBeginning(sym.name, rep)
|
||||
|
||||
try:
|
||||
sym.name = sym.name.replace(rep, nothing)
|
||||
except:
|
||||
discard
|
||||
|
||||
if sym.name.startsWith("SDLK_"):
|
||||
sym.name = sym.name.replace("SDLK_", "KEYCODE_")
|
||||
|
|
@ -147,10 +139,10 @@ proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
|||
sym.name = "SDLPRIX64"
|
||||
|
||||
if sym.kind == nskField:
|
||||
sym.name = camelCase(sym.name)
|
||||
sym.name = sym.name.replace(underscoreReg, camelCase)
|
||||
if sym.name == "type":
|
||||
sym.name = "kind"
|
||||
|
||||
# if INT_TYPES.contains(sym.name):
|
||||
# sym.name = sym.name.replace("S", "")
|
||||
# sym.name = sym.name.toLowerAscii() & "_ty"
|
||||
# sym.name = sym.name.toLowerAscii() & "_ty"
|
||||
|
|
@ -1,104 +1,26 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import nimterop/[cimport, build, globals]
|
||||
import nimterop/[cimport, build]
|
||||
|
||||
const
|
||||
SDLCacheDir* = getProjectCacheDir("nimsdl2")
|
||||
SDLCacheDir* = currentSourcePath.parentDir().parentDir() / "build" #getProjectCacheDir("nimsdl2")
|
||||
baseDir = SDLCacheDir
|
||||
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\""
|
||||
srcDir = baseDir / "sdl2"
|
||||
buildDir = srcDir / "buildcache"
|
||||
symbolPluginPath = currentSourcePath.parentDir() / "cleansymbols.nim"
|
||||
|
||||
getHeader(
|
||||
"SDL.h",
|
||||
dlurl = dlurl,
|
||||
dlurl = "https://www.libsdl.org/release/SDL2-$1.tar.gz",
|
||||
outdir = srcDir,
|
||||
conFlags = flags,
|
||||
altNames = "SDL2",
|
||||
buildTypes = [btAutoConf]
|
||||
cmakeFlags = "-DSDL_STATIC_PIC=ON"
|
||||
)
|
||||
|
||||
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", "NULL"
|
||||
"assert_data",
|
||||
# "SDL_AssertState", "SDL_AssertData", "SDL_threadID", "SDL_Keycode", "SDL_HapticConstant", "SDL_HapticRamp", "SDL_HapticLeftRight", "SDL_HapticCustom", "SDL_HapticPause", "SDL_Log"
|
||||
]
|
||||
# cDebug()
|
||||
|
|
@ -176,69 +98,33 @@ 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:
|
||||
proc getLibOutput(output: string): string =
|
||||
for line in output.split('\l'):
|
||||
if "lSDL2" in line:
|
||||
return line.strip()#.replace("-lSDL2 ", "").replace("-lSDL2main ", "")
|
||||
|
||||
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"
|
||||
else:
|
||||
const cmd = &"cd {srcDir.sanitizePath} && bash ./sdl2-config --static-libs"
|
||||
const conf = execAction(cmd).output.getLibOutput.replace("-lSDL2", SDLStaticLib)
|
||||
when SDL_Static:
|
||||
const conf = staticExec(&"cd {srcDir}; ./sdl2-config --static-libs || (./configure --silent; ./sdl2-config --static-libs)").replace("-lSDL2 ", "").split('\n')[^1]
|
||||
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
|
||||
const conf = staticExec(&"cd {srcDir}; ./sdl2-config --libs || (./configure --silent; ./sdl2-config --libs)").split('\n')[^1]
|
||||
{.passL: conf.}
|
||||
|
||||
when defined(linux):
|
||||
{.passL: &"{conf} -Wl,--no-as-needed -ldl -lsndio".}
|
||||
else:
|
||||
{.passL: &"{conf}".}
|
||||
|
||||
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".}
|
||||
when defined(SDL_Static):
|
||||
cImport(SDL_Path, recurse = true, flags = "-f=ast2 -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_")
|
||||
else:
|
||||
{.passC: "-fPIC".}
|
||||
cImport(SDL_Path, recurse = true, dynlib = "SDL_LPath", flags = "-f=ast2 -DDOXYGEN_SHOULD_IGNORE_THIS -E__,_ -F__,_")
|
||||
|
||||
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")
|
||||
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)
|
||||
|
||||
const SDLDyLibPath* = findDynlib()
|
||||
const SDLMainLib* = buildDir / "libSDL2main.a"
|
||||
const SDLStaticLib* = buildDir / "libSDL2.a"
|
||||
|
||||
const
|
||||
WINDOWPOS_UNDEFINED* = WINDOWPOS_UNDEFINED_DISPLAY(0)
|
||||
|
|
@ -250,4 +136,4 @@ const
|
|||
BUTTON_MMASK* = sdl_button(BUTTON_MIDDLE)
|
||||
BUTTON_RMASK* = sdl_button(BUTTON_RIGHT)
|
||||
BUTTON_X1MASK* = sdl_button(BUTTON_X1)
|
||||
BUTTON_X2MASK* = sdl_button(BUTTON_X2)
|
||||
BUTTON_X2MASK* = sdl_button(BUTTON_X2)
|
||||
|
|
@ -1,55 +1,33 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import sdl2
|
||||
import nimterop/[cimport, build, globals]
|
||||
import nimterop/[cimport, build]
|
||||
|
||||
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"
|
||||
|
||||
defs = """
|
||||
SDL2gfxPrimitivesSetVer=1.0.4
|
||||
SDL2gfxPrimitivesDL
|
||||
SDL2gfxPrimitivesStatic
|
||||
SDL2gfxStatic
|
||||
"""
|
||||
getHeader(
|
||||
"SDL2_gfxPrimitives.h",
|
||||
dlurl = "http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-$1.tar.gz",
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_gfx,SDL_gfx"
|
||||
)
|
||||
|
||||
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()
|
||||
# static:
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
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"
|
||||
)
|
||||
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")
|
||||
|
|
@ -1,46 +1,24 @@
|
|||
import macros
|
||||
import os, strformat, strutils
|
||||
import sdl2
|
||||
import glew
|
||||
import nimterop/[build, cimport, globals]
|
||||
import nimterop/[build, cimport]
|
||||
|
||||
const
|
||||
baseDir = SDLCacheDir
|
||||
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
|
||||
sdlDir = baseDir / "sdl2"
|
||||
sdlIncludeDir = sdlDir / "include"
|
||||
srcDir = baseDir / "sdl2_gpu"
|
||||
currentPath = currentSourcePath().parentDir().parentDir()
|
||||
cmakeModPath = currentPath / "cmake" / "sdl2"
|
||||
symbolPluginPath = currentPath / "sdl2" / "cleansymbols.nim"
|
||||
|
||||
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"
|
||||
# )
|
||||
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"
|
||||
)
|
||||
|
||||
static:
|
||||
cSkipSymbol @["Log"]
|
||||
|
|
@ -48,72 +26,6 @@ static:
|
|||
# cDisableCaching()
|
||||
|
||||
cOverride:
|
||||
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
|
||||
|
||||
NONE* = 0.uint32
|
||||
FEATURE_NON_POWER_OF_TWO* = 0x1.uint32
|
||||
FEATURE_RENDER_TARGETS* = 0x2.uint32
|
||||
FEATURE_BLEND_EQUATIONS* = 0x4.uint32
|
||||
FEATURE_BLEND_FUNC_SEPARATE* = 0x8.uint32
|
||||
FEATURE_BLEND_EQUATIONS_SEPARATE* = 0x10.uint32
|
||||
FEATURE_GL_BGR* = 0x20.uint32
|
||||
FEATURE_GL_BGRA* = 0x40.uint32
|
||||
FEATURE_GL_ABGR* = 0x80.uint32
|
||||
FEATURE_VERTEX_SHADER* = 0x100.uint32
|
||||
FEATURE_FRAGMENT_SHADER* = 0x200.uint32
|
||||
FEATURE_PIXEL_SHADER* = 0x200.uint32
|
||||
FEATURE_GEOMETRY_SHADER* = 0x400.uint32
|
||||
FEATURE_WRAP_REPEAT_MIRRORED* = 0x800.uint32
|
||||
FEATURE_CORE_FRAMEBUFFER_OBJECTS* = 0x1000.uint32
|
||||
INIT_ENABLE_VSYNC* = 0x1.uint32
|
||||
INIT_DISABLE_VSYNC* = 0x2.uint32
|
||||
INIT_DISABLE_DOUBLE_BUFFER* = 0x4.uint32
|
||||
INIT_DISABLE_AUTO_VIRTUAL_RESOLUTION* = 0x8.uint32
|
||||
INIT_REQUEST_COMPATIBILITY_PROFILE* = 0x10.uint32
|
||||
INIT_USE_ROW_BY_ROW_TEXTURE_UPLOAD_FALLBACK* = 0x20.uint32
|
||||
INIT_USE_COPY_TEXTURE_UPLOAD_FALLBACK* = 0x40.uint32
|
||||
|
||||
POINTS* = 0x0.uint32
|
||||
LINES* = 0x1.uint32
|
||||
LINE_LOOP* = 0x2.uint32
|
||||
LINE_STRIP* = 0x3.uint32
|
||||
TRIANGLES* = 0x4.uint32
|
||||
TRIANGLE_STRIP* = 0x5.uint32
|
||||
TRIANGLE_FAN* = 0x6.uint32
|
||||
|
||||
BATCH_XY* = 0x1.uint32
|
||||
BATCH_XYZ* = 0x2.uint32
|
||||
BATCH_ST* = 0x4.uint32
|
||||
BATCH_RGB* = 0x8.uint32
|
||||
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
|
||||
|
|
@ -121,42 +33,52 @@ 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)
|
||||
|
||||
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
|
||||
const
|
||||
NONE* = 0.uint32
|
||||
FEATURE_NON_POWER_OF_TWO* = 0x1.uint32
|
||||
FEATURE_RENDER_TARGETS* = 0x2.uint32
|
||||
FEATURE_BLEND_EQUATIONS* = 0x4.uint32
|
||||
FEATURE_BLEND_FUNC_SEPARATE* = 0x8.uint32
|
||||
FEATURE_BLEND_EQUATIONS_SEPARATE* = 0x10.uint32
|
||||
FEATURE_GL_BGR* = 0x20.uint32
|
||||
FEATURE_GL_BGRA* = 0x40.uint32
|
||||
FEATURE_GL_ABGR* = 0x80.uint32
|
||||
FEATURE_VERTEX_SHADER* = 0x100.uint32
|
||||
FEATURE_FRAGMENT_SHADER* = 0x200.uint32
|
||||
FEATURE_PIXEL_SHADER* = 0x200.uint32
|
||||
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
|
||||
INIT_DISABLE_AUTO_VIRTUAL_RESOLUTION* = 0x8.uint32
|
||||
INIT_REQUEST_COMPATIBILITY_PROFILE* = 0x10.uint32
|
||||
INIT_USE_ROW_BY_ROW_TEXTURE_UPLOAD_FALLBACK* = 0x20.uint32
|
||||
INIT_USE_COPY_TEXTURE_UPLOAD_FALLBACK* = 0x40.uint32
|
||||
|
||||
POINTS* = 0x0.uint32
|
||||
LINES* = 0x1.uint32
|
||||
LINE_LOOP* = 0x2.uint32
|
||||
LINE_STRIP* = 0x3.uint32
|
||||
TRIANGLES* = 0x4.uint32
|
||||
TRIANGLE_STRIP* = 0x5.uint32
|
||||
TRIANGLE_FAN* = 0x6.uint32
|
||||
|
||||
BATCH_XY* = 0x1.uint32
|
||||
BATCH_XYZ* = 0x2.uint32
|
||||
BATCH_ST* = 0x4.uint32
|
||||
BATCH_RGB* = 0x8.uint32
|
||||
BATCH_RGBA* = 0x10.uint32
|
||||
BATCH_RGB8* = 0x20.uint32
|
||||
BATCH_RGBA8* = 0x40.uint32
|
||||
|
||||
BATCH_XY_ST* = (BATCH_XY or BATCH_ST)
|
||||
BATCH_XYZ_ST* = (BATCH_XYZ or BATCH_ST)
|
||||
BATCH_XY_RGB* = (BATCH_XY or BATCH_RGB)
|
||||
|
|
@ -172,3 +94,35 @@ let
|
|||
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,57 +1,21 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import sdl2
|
||||
import nimterop/[cimport, build, globals]
|
||||
import nimterop/[cimport, build]
|
||||
|
||||
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 = dlurl,
|
||||
dlurl = "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-$1.tar.gz",
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_image",
|
||||
conFlags = flags,
|
||||
buildTypes = [btAutoConf]
|
||||
altNames = "SDL2_image"
|
||||
)
|
||||
|
||||
static:
|
||||
when defined(macosx):
|
||||
fixStaticFile(buildDir)
|
||||
# static:
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
|
|
@ -62,11 +26,8 @@ cOverride:
|
|||
ClearError* = ""
|
||||
|
||||
cPluginPath(symbolPluginPath)
|
||||
cIncludeDir(SDLIncludeDir)
|
||||
|
||||
{.passL: "-lwebp -lpng -ltiff -ljpeg".}
|
||||
|
||||
when isDefined(SDLimageStatic):
|
||||
cImport(srcDir/"SDL_image.h", recurse = false, flags = &"-f=ast2 -H", nimFile = generatedPath / "sdl2_image.nim")
|
||||
when defined(SDL_image_Static):
|
||||
cImport(SDL_image_Path, recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
else:
|
||||
cImport(srcDir/"SDL_image.h", recurse = false, dynlib = "SDL_image_LPath", flags = &"-f=ast2 -H", nimFile = generatedPath / "sdl2_image.nim")
|
||||
cImport(SDL_image_Path, recurse = false, dynlib = "SDL_image_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
|
|
|
|||
|
|
@ -1,49 +1,21 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import sdl2
|
||||
import nimterop/[cimport, build, globals]
|
||||
import nimterop/[cimport, build]
|
||||
|
||||
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 = dlurl,
|
||||
dlurl = "https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-$1.tar.gz",
|
||||
outdir = srcDir,
|
||||
conFlags = flags,
|
||||
altNames = "SDL2_mixer",
|
||||
buildTypes = [btAutoConf]
|
||||
altNames = "SDL2_mixer"
|
||||
)
|
||||
|
||||
static:
|
||||
when defined(macosx):
|
||||
fixStaticFile(buildDir)
|
||||
# static:
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
|
|
@ -55,7 +27,7 @@ cOverride:
|
|||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
when isDefined(SDLmixerStatic):
|
||||
cImport(srcDir/"SDL_mixer.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_mixer.nim")
|
||||
when defined(SDL_mixer_Static):
|
||||
cImport(SDL_mixer_Path, recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
else:
|
||||
cImport(srcDir/"SDL_mixer.h", recurse = false, dynlib = "SDL_mixer_LPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_mixer.nim")
|
||||
cImport(SDL_mixer_Path, recurse = false, dynlib = "SDL_mixer_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
|
|
|
|||
|
|
@ -1,49 +1,21 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import sdl2
|
||||
import nimterop/[cimport, build, globals]
|
||||
import nimterop/[cimport, build]
|
||||
|
||||
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 = dlurl,
|
||||
dlurl = "https://www.libsdl.org/projects/SDL_net/release/SDL2_net-$1.tar.gz",
|
||||
outdir = srcDir,
|
||||
conFlags = flags,
|
||||
altNames = "SDL2_net",
|
||||
buildTypes = [btAutoConf]
|
||||
altNames = "SDL2_net"
|
||||
)
|
||||
|
||||
static:
|
||||
when defined(macosx):
|
||||
fixStaticFile(buildDir)
|
||||
# static:
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
|
|
@ -53,9 +25,9 @@ cOverride:
|
|||
|
||||
cPluginPath(symbolPluginPath)
|
||||
|
||||
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")
|
||||
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")
|
||||
else:
|
||||
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")
|
||||
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")
|
||||
|
|
@ -1,51 +1,26 @@
|
|||
import macros
|
||||
import os, strutils, strformat
|
||||
import sdl2
|
||||
import nimterop/[cimport, build, globals]
|
||||
import nimterop/[cimport, build]
|
||||
|
||||
const
|
||||
baseDir = SDLCacheDir
|
||||
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}\""
|
||||
|
||||
sdlDir = baseDir / "sdl2"
|
||||
sdlIncludeDir = sdlDir / "include"
|
||||
srcDir = baseDir / "sdl2_ttf"
|
||||
currentPath = currentSourcePath().parentDir().parentDir()
|
||||
cmakeModPath = currentPath / "cmake" / "sdl2"
|
||||
symbolPluginPath = currentPath / "sdl2" / "cleansymbols.nim"
|
||||
|
||||
getHeader(
|
||||
"SDL_ttf.h",
|
||||
dlurl = dlurl,
|
||||
dlurl = "https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$1.tar.gz",
|
||||
outdir = srcDir,
|
||||
altNames = "SDL2_ttf",
|
||||
conFlags = flags,
|
||||
buildTypes = [btAutoConf]
|
||||
cmakeFlags = &"-DCMAKE_C_FLAGS=-I{sdlIncludeDir} -DCMAKE_MODULE_PATH={cmakeModPath} " &
|
||||
&"-DSDL2MAIN_LIBRARY={SDLMainLib} -DSDL2_LIBRARY={SDLDyLibPath} -DSDL2_PATH={sdlDir}"
|
||||
)
|
||||
|
||||
static:
|
||||
when defined(macosx):
|
||||
fixStaticFile(buildDir)
|
||||
# static:
|
||||
# cDebug()
|
||||
# cDisableCaching()
|
||||
|
||||
|
|
@ -56,7 +31,7 @@ cOverride:
|
|||
GetError* = ""
|
||||
SetError* = ""
|
||||
|
||||
when isDefined(SDLttfStatic):
|
||||
cImport(srcDir / "SDL_ttf.h", recurse = false, flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_ttf.nim")
|
||||
when defined(SDL_ttf_Static):
|
||||
cImport(SDL_ttf_Path, recurse = false, flags = &"-I={sdlIncludeDir} -f=ast2 -d")
|
||||
else:
|
||||
cImport(srcDir / "SDL_ttf.h", recurse = false, dynlib = "SDL_ttf_LPath", flags = &"-I={SDLIncludeDir} -f=ast2 -H", nimFile = generatedPath / "sdl2_ttf.nim")
|
||||
cImport(SDL_ttf_Path, recurse = false, dynlib = "SDL_ttf_LPath", flags = &"-I={sdlIncludeDir} -f=ast2")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue