diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..62e25d1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:24.04 + +RUN apt-get update && apt-get install -y \ + dotnet-sdk-8.0 \ + python3 \ + git \ + build-essential + +RUN ln -s /usr/bin/python3 /usr/bin/python + +SHELL ["/bin/bash", "-c"] \ No newline at end of file diff --git a/SDL3-CS/SDL3-CS.csproj b/SDL3-CS/SDL3-CS.csproj index 04e55fd..dd15bdd 100644 --- a/SDL3-CS/SDL3-CS.csproj +++ b/SDL3-CS/SDL3-CS.csproj @@ -25,7 +25,15 @@ - + + + + all + + + + all + diff --git a/SDL3-CS/SDL3/SDL_stdinc.rsp b/SDL3-CS/SDL3/SDL_stdinc.rsp index 375011b..be9a12d 100644 --- a/SDL3-CS/SDL3/SDL_stdinc.rsp +++ b/SDL3-CS/SDL3/SDL_stdinc.rsp @@ -6,6 +6,7 @@ SDL_SLOW_MEMCPY SDL_SLOW_MEMMOVE SDL_SLOW_MEMSET +SDL_DISABLE_ALLOCA # Prevent SDL from using compiler intrinsics __builtin_mul_overflow and __builtin_add_overflow. --additional diff --git a/SDL3-CS/generate_bindings.py b/SDL3-CS/generate_bindings.py index fa06475..5b888e1 100644 --- a/SDL3-CS/generate_bindings.py +++ b/SDL3-CS/generate_bindings.py @@ -260,12 +260,27 @@ base_command = [ "char=byte", "wchar_t *=IntPtr", # wchar_t has a platform-defined size "bool=SDLBool", # treat bool as C# helper type + "__va_list=byte*", "--define-macro", "SDL_FUNCTION_POINTER_IS_VOID_POINTER", + "SDL_DECLSPEC=", # Not supported by llvm + # Undefine platform-specific macros - these will be defined on a per-case basis later. "--additional", "--undefine-macro=_WIN32", + "--undefine-macro=linux", + "--undefine-macro=__linux", + "--undefine-macro=__linux__", + "--undefine-macro=unix", + "--undefine-macro=__unix", + "--undefine-macro=__unix__", + "--undefine-macro=__APPLE__", + # GCC and LLVM use `long int` => int64, whereas MSVC uses `long long int` => int64. + # In terms of C# code gen, it's more accurate if we disable these to force LL, so + # that they're transformed to longs instead of ints. + "--undefine-macro=__LP64__", + "--undefine-macro=_LP64", ] diff --git a/SDL3-CS/generate_bindings.sh b/SDL3-CS/generate_bindings.sh new file mode 100755 index 0000000..0bb0ff4 --- /dev/null +++ b/SDL3-CS/generate_bindings.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -eu +pushd "$(dirname "$0")/../" >/dev/null + +dotnet tool restore +dotnet restore --ucr SDL3-CS/SDL3-CS.csproj + +export LD_LIBRARY_PATH="$(echo ~/.nuget/packages/libclang.runtime.*/*/runtimes/*/native):$(echo ~/.nuget/packages/libclangsharp.runtime.*/*/runtimes/*/native):${LD_LIBRARY_PATH:-}" +export CPLUS_INCLUDE_PATH="$(echo /usr/lib/gcc/*/*/include):/usr/include:${CPLUS_INCLUDE_PATH:-}" + +python3 SDL3-CS/generate_bindings.py + +popd >/dev/null