Add dockerfile + generation wrapper script

This commit is contained in:
Dan Balasescu 2024-10-22 17:52:46 +09:00
parent ee98235385
commit 5227b62690
No known key found for this signature in database
5 changed files with 50 additions and 1 deletions

11
Dockerfile Normal file
View File

@ -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"]

View File

@ -25,7 +25,15 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0"/>
<PackageReference Include="libclang" Version="17.0.4">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="libClangSharp" Version="17.0.4">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>

View File

@ -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

View File

@ -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",
]

14
SDL3-CS/generate_bindings.sh Executable file
View File

@ -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