Merge pull request #169 from smoogipoo/dockerfile

Add dockerfile + generation wrapper script
This commit is contained in:
Susko3 2024-10-28 13:23:18 +00:00 committed by GitHub
commit 0ef3dbab09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 52 additions and 4 deletions

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM ubuntu:24.04
RUN apt-get update && \
apt-get install -y dotnet-sdk-8.0 python3 git build-essential
WORKDIR /tmp
COPY .config/dotnet-tools.json .config/dotnet-tools.json
COPY SDL3-CS/SDL3-CS.csproj SDL3-CS/SDL3-CS.csproj
RUN dotnet tool restore && \
dotnet restore --ucr SDL3-CS/SDL3-CS.csproj
WORKDIR /
RUN echo '#!/bin/bash' >> entrypoint.sh && \
echo 'export LD_LIBRARY_PATH="$(echo ~/.nuget/packages/libclang.runtime.*/*/runtimes/*/native):$(echo ~/.nuget/packages/libclangsharp.runtime.*/*/runtimes/*/native):${LD_LIBRARY_PATH:-}"' >> entrypoint.sh && \
echo 'export CPLUS_INCLUDE_PATH="$(echo /usr/lib/gcc/*/*/include):/usr/include:${CPLUS_INCLUDE_PATH:-}"' >> entrypoint.sh && \
echo 'python3 SDL3-CS/generate_bindings.py "$@"' >> entrypoint.sh && \
chmod +x entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -25,7 +25,15 @@
</ItemGroup> </ItemGroup>
<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>
<ItemGroup> <ItemGroup>

View File

@ -28,7 +28,6 @@ using System.Runtime.InteropServices;
namespace SDL namespace SDL
{ {
[NativeTypeName("int")]
public enum SDL_AudioFormat : uint public enum SDL_AudioFormat : uint
{ {
SDL_AUDIO_UNKNOWN = 0x0000U, SDL_AUDIO_UNKNOWN = 0x0000U,

View File

@ -89,7 +89,6 @@ namespace SDL
SDL_PACKEDLAYOUT_1010102, SDL_PACKEDLAYOUT_1010102,
} }
[NativeTypeName("int")]
public enum SDL_PixelFormat : uint public enum SDL_PixelFormat : uint
{ {
SDL_PIXELFORMAT_UNKNOWN = 0, SDL_PIXELFORMAT_UNKNOWN = 0,
@ -240,7 +239,6 @@ namespace SDL
SDL_CHROMA_LOCATION_TOPLEFT = 3, SDL_CHROMA_LOCATION_TOPLEFT = 3,
} }
[NativeTypeName("int")]
public enum SDL_Colorspace : uint public enum SDL_Colorspace : uint
{ {
SDL_COLORSPACE_UNKNOWN = 0, SDL_COLORSPACE_UNKNOWN = 0,

View File

@ -6,6 +6,7 @@
SDL_SLOW_MEMCPY SDL_SLOW_MEMCPY
SDL_SLOW_MEMMOVE SDL_SLOW_MEMMOVE
SDL_SLOW_MEMSET SDL_SLOW_MEMSET
SDL_DISABLE_ALLOCA
# Prevent SDL from using compiler intrinsics __builtin_mul_overflow and __builtin_add_overflow. # Prevent SDL from using compiler intrinsics __builtin_mul_overflow and __builtin_add_overflow.
--additional --additional

View File

@ -24,6 +24,7 @@ Example:
import json import json
import pathlib import pathlib
import platform
import re import re
import subprocess import subprocess
import sys import sys
@ -260,6 +261,13 @@ base_command = [
"char=byte", "char=byte",
"wchar_t *=IntPtr", # wchar_t has a platform-defined size "wchar_t *=IntPtr", # wchar_t has a platform-defined size
"bool=SDLBool", # treat bool as C# helper type "bool=SDLBool", # treat bool as C# helper type
"__va_list=byte*",
"__va_list_tag=byte",
"Sint64=long",
"Uint64=ulong",
"--with-type",
"*=int", # all enum types should be ints by default
"--nativeTypeNamesToStrip", "--nativeTypeNamesToStrip",
"unsigned int", "unsigned int",
@ -268,9 +276,18 @@ base_command = [
"SDL_FUNCTION_POINTER_IS_VOID_POINTER", "SDL_FUNCTION_POINTER_IS_VOID_POINTER",
"SDL_SINT64_C(c)=c ## LL", "SDL_SINT64_C(c)=c ## LL",
"SDL_UINT64_C(c)=c ## ULL", "SDL_UINT64_C(c)=c ## ULL",
"SDL_DECLSPEC=", # Not supported by llvm
# Undefine platform-specific macros - these will be defined on a per-case basis later.
"--additional", "--additional",
"--undefine-macro=_WIN32", "--undefine-macro=_WIN32",
"--undefine-macro=linux",
"--undefine-macro=__linux",
"--undefine-macro=__linux__",
"--undefine-macro=unix",
"--undefine-macro=__unix",
"--undefine-macro=__unix__",
"--undefine-macro=__APPLE__",
] ]
@ -346,6 +363,11 @@ def should_skip(solo_headers: list[Header], header: Header):
def main(): def main():
solo_headers = [make_header_fuzzy(header_name) for header_name in sys.argv[1:]] solo_headers = [make_header_fuzzy(header_name) for header_name in sys.argv[1:]]
if platform.system() != "Windows":
base_command.extend([
"--include-directory", csproj_root / "include"
])
prepare_sdl_source() prepare_sdl_source()
sdl_api = get_sdl_api_dump() sdl_api = get_sdl_api_dump()

View File

@ -0,0 +1 @@
// dummy process.h when building for SDL_PLATFORM_WINDOWS on non-windows systems