Skip to content

Commit

Permalink
Merge branch 'libsdl-org-main'
Browse files Browse the repository at this point in the history
  • Loading branch information
capehill committed Jul 26, 2024
2 parents b1ac613 + 0056aa1 commit 00548a0
Show file tree
Hide file tree
Showing 589 changed files with 24,772 additions and 15,938 deletions.
70 changes: 70 additions & 0 deletions .github/actions/setup-msvc-libusb-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: 'Setup libusb for MSBC'
description: 'Greet someone'
inputs:
version:
description: 'libusb version'
required: true
default: '1.0.27'
arch:
description: "libusb architecture (x86 or x64)"
rqeuired: true
outputs:
root:
description: "libusb root directory"
value: ${{ steps.final.outputs.root }}
runs:
using: 'composite'
steps:
- name: 'Restore cached libusb-${{ inputs.version }}.7z'
id: cache-restore
uses: actions/cache/restore@v4
with:
path: 'C:\temp\libusb-${{ inputs.version }}.7z'
key: libusb-msvc-${{ inputs.version }}
- name: 'Download libusb ${{ inputs.version }}'
if: ${{ !steps.cache-restore.outputs.cache-hit }}
shell: pwsh
run: |
Invoke-WebRequest "https://github.com/libusb/libusb/releases/download/v${{ inputs.version }}/libusb-${{ inputs.version }}.7z" -OutFile "C:\temp\libusb-${{ inputs.version }}.7z"
- name: 'Cache libusb-${{ inputs.version }}.7z'
if: ${{ !steps.cache-restore.outputs.cache-hit }}
uses: actions/cache/save@v4
with:
path: 'C:\temp\libusb-${{ inputs.version }}.7z'
key: libusb-msvc-${{ inputs.version }}
- name: 'Extract libusb'
shell: pwsh
run: |
7z "-oC:\temp\libusb-${{ inputs.version }}" x "C:\temp\libusb-${{ inputs.version }}.7z"
- name: 'Set output vars'
id: final
shell: pwsh
run: |
if ('${{ inputs.arch }}' -eq 'x86') {
$archdir = "MS32";
} elseif ('${{ inputs.arch }}' -eq 'x64') {
$archdir = "MS64";
} else {
write-host "Invalid arch=${{ inputs.arch }}"
exit 1
}
$libusb_incdir = "C:\temp\libusb-${{ inputs.version }}\include";
$libusb_libdir = "C:\temp\libusb-${{ inputs.version }}\VS2022\${archdir}\dll";
$libusb_header = "${libusb_incdir}\libusb.h";
$libusb_implib = "${libusb_libdir}\libusb-1.0.lib";
$libusb_dll = "${libusb_libdir}\libusb-1.0.dll";
if (!(Test-Path "${libusb_header}")) {
write-host "${libusb_header} does not exist!"
exit 1
}
if (!(Test-Path "${libusb_implib}")){
write-host "${libusb_implib} does not exist!"
exit 1
}
if (!(Test-Path "${libusb_dll}")) {
write-host "${libusb_dll} does not exist!"
exit 1
}
echo "root=${libusb_incdir};${libusb_libdir}" >> $env:GITHUB_OUTPUT
62 changes: 62 additions & 0 deletions .github/actions/setup-ninja/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Setup ninja'
description: 'Setup ninja'
inputs:
version:
description: 'Ninja version'
default: '1.12.1'
runs:
using: 'composite'
steps:
- name: 'Calculate variables'
id: calc
shell: sh
run: |
case "${{ runner.os }}-${{ runner.arch }}" in
"Linux-X86" | "Linux-X64")
archive="ninja-linux.zip"
;;
"Linux-ARM64")
archive="ninja-linux-aarch64.zip"
;;
"macOS-X86" | "macOS-X64" | "macOS-ARM64")
archive="ninja-mac.zip"
;;
"Windows-X86" | "Windows-X64")
archive="ninja-win.zip"
;;
"Windows-ARM64")
archive="ninja-winarm64.zip"
;;
*)
echo "Unsupported ${{ runner.os }}-${{ runner.arch }}"
exit 1;
;;
esac
echo "archive=${archive}" >> ${GITHUB_OUTPUT}
echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT}
- name: 'Restore cached ${{ steps.calc.outputs.archive }}'
id: cache-restore
uses: actions/cache/restore@main
with:
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
- name: 'Download ninja ${{ inputs.version }} for ${{ runner.os }} (${{ runner.arch }})'
if: ${{ !steps.cache-restore.outputs.cache-hit }}
shell: pwsh
run: |
Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v${{ inputs.version }}/${{ steps.calc.outputs.archive }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
- name: 'Cache ${{ steps.calc.outputs.archive }}'
if: ${{ !steps.cache-restore.outputs.cache-hit }}
uses: actions/cache/save@main
with:
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
- name: 'Extract libusb'
shell: pwsh
run: |
7z "-o${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" x "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
- name: 'Set output variables'
id: final
shell: pwsh
run: |
echo "${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" >> $env:GITHUB_PATH
85 changes: 52 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the SDL source code and run \"cmake -S ${CMAKE_SOURCE_DIR} -B .\" from there")
endif()

# MSVC runtime library flags are selected by an abstraction.
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)

# See docs/release_checklist.md
project(SDL3 LANGUAGES C VERSION "3.1.2")

Expand Down Expand Up @@ -55,10 +52,10 @@ include("${SDL3_SOURCE_DIR}/cmake/sdltargets.cmake")
include("${SDL3_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake")
include("${SDL3_SOURCE_DIR}/cmake/3rdparty.cmake")
include("${SDL3_SOURCE_DIR}/cmake/PreseedMSVCCache.cmake")
include("${SDL3_SOURCE_DIR}/cmake/PreseedEmscriptenCache.cmake")

SDL_DetectCompiler()
SDL_DetectTargetCPUArchitectures(SDL_CPUS)
SDL_Preseed_CMakeCache()

# Increment this if there is an incompatible change - but if that happens,
# we should rename the library from SDL3 to SDL4, at which point this would
Expand Down Expand Up @@ -159,20 +156,6 @@ if(WINDOWS OR MACOS OR IOS OR TVOS OR VISIONOS OR WATCHOS)
endif()

if(MSVC)
dep_option(SDL_STATIC_VCRT "Use /MT for static VC runtimes" ON "NOT WINDOWS_STORE" OFF)
if(SDL_STATIC_VCRT)
if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()

if(NOT SDL_LIBC)
# Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
foreach(flag_var
Expand Down Expand Up @@ -270,11 +253,17 @@ else()
set(SDL_RPATH_DEFAULT OFF)
endif()

set(SDL_PRESEED_AVAILABLE OFF)
if(COMMAND SDL_Preseed_CMakeCache)
set(SDL_PRESEED_AVAILABLE ON)
endif()

# Allow some projects to be built conditionally.
set_option(SDL_DISABLE_INSTALL "Disable installation of SDL3" ${SDL3_SUBPROJECT})
cmake_dependent_option(SDL_DISABLE_INSTALL_CPACK "Create binary SDL3 archive using CPack" ${SDL3_SUBPROJECT} "NOT SDL_DISABLE_INSTALL" ON)
cmake_dependent_option(SDL_DISABLE_INSTALL_DOCS "Install docs for SDL3" ON "NOT SDL_DISABLE_INSTALL;NOT SDL_FRAMEWORK" ON)
set_option(SDL_DISABLE_UNINSTALL "Disable uninstallation of SDL3" OFF)
cmake_dependent_option(SDL_PRESEED "Preseed CMake cache to speed up configuration" ON "${SDL_PRESEED_AVAILABLE}" OFF)

cmake_dependent_option(SDL_DISABLE_ANDROID_JAR "Disable creation of SDL3.jar" ${SDL3_SUBPROJECT} "ANDROID" ON)

Expand Down Expand Up @@ -305,7 +294,7 @@ dep_option(SDL_DUMMYAUDIO "Support the dummy audio driver" ON "SDL_AUDI
dep_option(SDL_DUMMYVIDEO "Use dummy video driver" ON "SDL_VIDEO" OFF)
dep_option(SDL_IBUS "Enable IBus support" ON "${UNIX_SYS}" OFF)
dep_option(SDL_OPENGL "Include OpenGL support" ON "SDL_VIDEO;NOT IOS;NOT VISIONOS;NOT TVOS;NOT WATCHOS" OFF)
dep_option(SDL_OPENGLES "Include OpenGL ES support" ON "SDL_VIDEO;NOT IOS;NOT VISIONOS;NOT TVOS;NOT WATCHOS" OFF)
dep_option(SDL_OPENGLES "Include OpenGL ES support" ON "SDL_VIDEO;NOT VISIONOS;NOT TVOS;NOT WATCHOS" OFF)
set_option(SDL_PTHREADS "Use POSIX threads for multi-threading" ${SDL_PTHREADS_DEFAULT})
dep_option(SDL_PTHREADS_SEM "Use pthread semaphores" ON "SDL_PTHREADS" OFF)
dep_option(SDL_OSS "Support the OSS audio API" ${SDL_OSS_DEFAULT} "UNIX_SYS OR RISCOS;SDL_AUDIO" OFF)
Expand Down Expand Up @@ -341,8 +330,8 @@ dep_option(SDL_WASAPI "Use the Windows WASAPI audio driver" ON "WIN
dep_option(SDL_RENDER_D3D "Enable the Direct3D render driver" ON "SDL_RENDER" OFF)
dep_option(SDL_RENDER_METAL "Enable the Metal render driver" ON "SDL_RENDER;${APPLE}" OFF)
dep_option(SDL_VIVANTE "Use Vivante EGL video driver" ON "${UNIX_SYS};SDL_CPU_ARM32" OFF)
dep_option(SDL_VULKAN "Enable Vulkan support" ON "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR WINDOWS" OFF)
dep_option(SDL_RENDER_VULKAN "Enable the Vulkan render driver" ON "SDL_RENDER;SDL_VULKAN;ANDROID OR APPLE OR LINUX OR WINDOWS" OFF)
dep_option(SDL_VULKAN "Enable Vulkan support" ON "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR FREEBSD OR WINDOWS" OFF)
dep_option(SDL_RENDER_VULKAN "Enable the Vulkan render driver" ON "SDL_RENDER;SDL_VULKAN" OFF)
dep_option(SDL_METAL "Enable Metal support" ON "APPLE" OFF)
dep_option(SDL_KMSDRM "Use KMS DRM video driver" ${UNIX_SYS} "SDL_VIDEO" OFF)
dep_option(SDL_KMSDRM_SHARED "Dynamically load KMS DRM support" ON "SDL_KMSDRM" OFF)
Expand Down Expand Up @@ -371,6 +360,9 @@ dep_option(SDL_INSTALL_TESTS "Install test-cases" OFF "NOT SDL_DISABLE_INSTALL
dep_option(SDL_TESTS_LINK_SHARED "link tests to shared SDL library" "${SDL_SHARED}" "SDL_SHARED;SDL_STATIC" "${SDL_SHARED}")
set(SDL_TESTS_TIMEOUT_MULTIPLIER "1" CACHE STRING "Timeout multiplier to account for really slow machines")

set_option(SDL_EXAMPLES "Build the examples directory")
dep_option(SDL_EXAMPLES_LINK_SHARED "link examples to shared SDL library" "${SDL_SHARED}" "SDL_SHARED;SDL_STATIC" "${SDL_SHARED}")

if(VITA)
set_option(VIDEO_VITA_PIB "Build with PSVita piglet gles2 support" OFF)
set_option(VIDEO_VITA_PVR "Build with PSVita PVR gles/gles2 support" OFF)
Expand All @@ -380,6 +372,10 @@ if(NOT (SDL_SHARED OR SDL_STATIC))
message(FATAL_ERROR "SDL_SHARED and SDL_STATIC cannot both be disabled")
endif()

if(SDL_PRESEED)
SDL_Preseed_CMakeCache()
endif()

if(SDL_SHARED)
add_library(SDL3-shared SHARED)
add_library(SDL3::SDL3-shared ALIAS SDL3-shared)
Expand Down Expand Up @@ -428,8 +424,8 @@ if (LIBC_IS_GLIBC AND CMAKE_SIZEOF_VOID_P EQUAL 4)
endif()

if(WINDOWS_STORE)
sdl_compile_definitions(PRIVATE "SDL_BUILDING_WINRT=1")
sdl_compile_options(PRIVATE "-ZW")
sdl_compile_definitions(PRIVATE "SDL_BUILDING_WINRT=1" "WINAPI_FAMILY=WINAPI_FAMILY_APP")
sdl_compile_options(PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:/ZW>" "$<$<COMPILE_LANGUAGE:CXX>:-EHsc>")
endif()

check_linker_supports_version_file(HAVE_WL_VERSION_SCRIPT)
Expand Down Expand Up @@ -1356,6 +1352,10 @@ if(ANDROID)
if(VULKAN_PASSED_ANDROID_CHECKS)
set(SDL_VIDEO_VULKAN 1)
set(HAVE_VULKAN TRUE)
if(SDL_RENDER_VULKAN)
set(SDL_VIDEO_RENDER_VULKAN 1)
set(HAVE_RENDER_VULKAN TRUE)
endif()
endif()
endif()
endif()
Expand Down Expand Up @@ -1950,16 +1950,27 @@ elseif(WINDOWS)
set(SDL_THREAD_GENERIC_COND_SUFFIX 1)
set(SDL_THREAD_GENERIC_RWLOCK_SUFFIX 1)
set(SDL_THREAD_WINDOWS 1)
sdl_sources(
"${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syscond.c"
"${SDL3_SOURCE_DIR}/src/thread/generic/SDL_sysrwlock.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_syscond_cv.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_sysmutex.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_sysrwlock_srw.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_syssem.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_systhread.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_systls.c"
)
if(WINDOWS_STORE)
sdl_sources(
"${SDL3_SOURCE_DIR}/src/thread/stdcpp/SDL_syscond.cpp"
"${SDL3_SOURCE_DIR}/src/thread/stdcpp/SDL_sysmutex.cpp"
"${SDL3_SOURCE_DIR}/src/thread/stdcpp/SDL_sysrwlock.cpp"
"${SDL3_SOURCE_DIR}/src/thread/stdcpp/SDL_systhread.cpp"
"${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syssem.c"
)
else()
sdl_sources(
"${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syscond.c"
"${SDL3_SOURCE_DIR}/src/thread/generic/SDL_sysrwlock.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_syscond_cv.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_sysmutex.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_sysrwlock_srw.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_syssem.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_systhread.c"
"${SDL3_SOURCE_DIR}/src/thread/windows/SDL_systls.c"
)
endif()

set(HAVE_SDL_THREADS TRUE)

if(SDL_SENSOR AND HAVE_SENSORSAPI_H AND NOT WINDOWS_STORE)
Expand Down Expand Up @@ -2103,6 +2114,7 @@ elseif(WINDOWS)
endif()
endif()

enable_language(RC)
sdl_glob_sources(SHARED "${SDL3_SOURCE_DIR}/src/core/windows/*.rc")
if(MINGW OR CYGWIN)
sdl_pc_link_options("-mwindows")
Expand Down Expand Up @@ -3623,6 +3635,13 @@ if(SDL_TESTS)
add_subdirectory(test)
endif()

##### Examples subproject (must appear after the install/uninstall targets) #####

if(SDL_EXAMPLES)
set(HAVE_EXAMPLES ON)
add_subdirectory(examples)
endif()

##### Fix Objective C builds #####
string(APPEND CMAKE_OBJC_FLAGS " ${CMAKE_C_FLAGS}")

Expand Down
5 changes: 3 additions & 2 deletions VisualC-GDK/SDL/SDL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
<ClCompile Include="..\..\src\dialog\SDL_dialog_utils.c" />
<ClCompile Include="..\..\src\filesystem\SDL_filesystem.c" />
<ClCompile Include="..\..\src\filesystem\windows\SDL_sysfsops.c" />
<ClCompile Include="..\..\src\main\gdk\SDL_sysmain_runapp.cpp">
<ClCompile Include="..\..\src\main\gdk\SDL_sysmain_runapp.cpp" />
<ClCompile Include="..\..\src\main\generic\SDL_sysmain_callbacks.c" />
<ClCompile Include="..\..\src\main\SDL_main_callbacks.c" />
<ClCompile Include="..\..\src\main\SDL_runapp.c" />
Expand Down Expand Up @@ -558,6 +558,7 @@
<ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
<ClInclude Include="..\..\src\video\SDL_rect_c.h" />
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
<ClInclude Include="..\..\src\video\SDL_surface_c.h" />
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\..\src\video\SDL_vulkan_internal.h" />
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
Expand Down Expand Up @@ -863,4 +864,4 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>
</Project>
3 changes: 2 additions & 1 deletion VisualC-GDK/SDL/SDL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@
<ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
<ClInclude Include="..\..\src\video\SDL_rect_c.h" />
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
<ClInclude Include="..\..\src\video\SDL_surface_c.h" />
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\..\src\video\SDL_vulkan_internal.h" />
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
Expand All @@ -462,4 +463,4 @@
<ItemGroup>
<ResourceCompile Include="..\..\src\core\windows\version.rc" />
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion VisualC-GDK/tests/testgdk/src/testgdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ loop()
/* Check for events */
while (SDL_PollEvent(&event)) {
if (event.type == SDL_EVENT_KEY_DOWN && !event.key.repeat) {
SDL_Log("Initial SDL_EVENT_KEY_DOWN: %s", SDL_GetScancodeName(event.key.keysym.scancode));
SDL_Log("Initial SDL_EVENT_KEY_DOWN: %s", SDL_GetScancodeName(event.key.scancode));
}
#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
/* On Xbox, ignore the keydown event because the features aren't supported */
Expand Down
3 changes: 2 additions & 1 deletion VisualC-WinRT/SDL-UWP.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<ClInclude Include="..\src\video\SDL_pixels_c.h" />
<ClInclude Include="..\src\video\SDL_rect_c.h" />
<ClInclude Include="..\src\video\SDL_RLEaccel_c.h" />
<ClInclude Include="..\src\video\SDL_surface_c.h" />
<ClInclude Include="..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\src\video\SDL_sysvidocapture.h" />
<ClInclude Include="..\src\video\SDL_yuv_c.h" />
Expand Down Expand Up @@ -917,4 +918,4 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>
</Project>
5 changes: 4 additions & 1 deletion VisualC-WinRT/SDL-UWP.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@
<ClInclude Include="..\src\video\SDL_RLEaccel_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\src\video\SDL_surface_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\src\video\SDL_sysvideo.h">
<Filter>Source Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -973,4 +976,4 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
</Project>
Loading

0 comments on commit 00548a0

Please sign in to comment.