update SDL3 to latest commit

This commit is contained in:
Sasha Szpakowski
2024-10-06 20:30:44 -03:00
parent 1b0fdc338b
commit 9e5eb1b018
1426 changed files with 242456 additions and 103496 deletions
+36 -15
View File
@@ -1,13 +1,26 @@
# This cmake build script is meant for verifying the various CMake configuration scripts.
cmake_minimum_required(VERSION 3.12)
project(sdl_test LANGUAGES C)
if(WINDOWS_STORE)
enable_language(CXX)
add_compile_options(/ZW)
set_source_files_properties(ain_cli.c main_gui.c PROPERTIES LANGUAGE CXX)
project(SDL_cmake_selftest LANGUAGES C)
include(CheckLanguage)
# FIXME: how to target ios/tvos with Swift?
# https://gitlab.kitware.com/cmake/cmake/-/issues/20104
if(APPLE AND CMAKE_SYSTEM_NAME MATCHES ".*(Darwin|MacOS).*")
# multiple values for CMAKE_OSX_ARCHITECTURES not supported with Swift
list(LENGTH CMAKE_OSX_ARCHITECTURES count_osx_archs)
if(count_osx_archs LESS_EQUAL 1)
check_language(Swift)
if(CMAKE_Swift_COMPILER)
enable_language(Swift)
endif()
endif()
endif()
message(STATUS "CMAKE_SYSTEM_NAME= ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR= ${CMAKE_SYSTEM_PROCESSOR}")
include(GenerateExportHeader)
if(ANDROID)
@@ -41,8 +54,6 @@ add_feature_info("TEST_FULL" TEST_FULL "Build full SDL testsuite")
find_package(SDL3 REQUIRED CONFIG COMPONENTS Headers)
add_library(headers_test_slash OBJECT inc_sdl_slash.c)
target_link_libraries(headers_test_slash PRIVATE SDL3::Headers)
add_library(headers_test_noslash OBJECT inc_sdl_noslash.c)
target_link_libraries(headers_test_noslash PRIVATE SDL3::Headers)
if(TEST_SHARED)
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3-shared)
@@ -72,6 +83,12 @@ if(TEST_SHARED)
add_executable(sdltest-shared sdltest.c)
target_link_libraries(sdltest-shared PRIVATE SDL3::SDL3_test SDL3::SDL3-shared)
endif()
if(CMAKE_Swift_COMPILER)
add_executable(swift-shared main.swift)
target_include_directories(swift-shared PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift")
target_link_libraries(swift-shared PRIVATE SDL3::SDL3-shared)
endif()
endif()
if(TEST_STATIC)
@@ -79,19 +96,23 @@ if(TEST_STATIC)
add_executable(gui-static WIN32 main_gui.c)
target_link_libraries(gui-static PRIVATE SDL3::SDL3-static)
option(SDL_STATIC_PIC "SDL static library has been built with PIC")
if(SDL_STATIC_PIC OR WIN32)
add_library(sharedlib-static SHARED main_lib.c)
target_link_libraries(sharedlib-static PRIVATE SDL3::SDL3-static)
generate_export_header(sharedlib-static EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
target_compile_definitions(sharedlib-static PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-static_export.h\"")
set_target_properties(sharedlib-static PROPERTIES C_VISIBILITY_PRESET "hidden")
endif()
# Assume SDL library has been built with `set(CMAKE_POSITION_INDEPENDENT_CODE ON)`
add_library(sharedlib-static SHARED main_lib.c)
target_link_libraries(sharedlib-static PRIVATE SDL3::SDL3-static)
generate_export_header(sharedlib-static EXPORT_MACRO_NAME MYLIBRARY_EXPORT)
target_compile_definitions(sharedlib-static PRIVATE "EXPORT_HEADER=\"${CMAKE_CURRENT_BINARY_DIR}/sharedlib-static_export.h\"")
set_target_properties(sharedlib-static PROPERTIES C_VISIBILITY_PRESET "hidden")
if(TEST_TEST)
add_executable(sdltest-static sdltest.c)
target_link_libraries(sdltest-static PRIVATE SDL3::SDL3_test SDL3::SDL3-static)
endif()
if(CMAKE_Swift_COMPILER)
add_executable(swift-static main.swift)
target_include_directories(swift-static PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift")
target_link_libraries(swift-static PRIVATE SDL3::SDL3-static)
endif()
endif()
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3)
-8
View File
@@ -1,8 +0,0 @@
#include "SDL.h"
#include "SDL_main.h"
void inc_sdl_noslash(void) {
SDL_SetMainReady();
SDL_Init(0);
SDL_Quit();
}
+13
View File
@@ -0,0 +1,13 @@
/* Contributed by Piotr Usewicz (https://github.com/pusewicz) */
import SDL3
guard SDL_Init(SDL_INIT_VIDEO) else {
fatalError("SDL_Init error: \(String(cString: SDL_GetError()))")
}
var sdlVersion = SDL_GetVersion()
print("SDL version: \(sdlVersion)")
SDL_Quit()
+1 -1
View File
@@ -5,7 +5,7 @@
int main(int argc, char *argv[])
{
SDL_SetMainReady();
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_Log("Could not initialize SDL: %s\n", SDL_GetError());
return 1;
}
+2 -2
View File
@@ -5,7 +5,7 @@ int main(int argc, char *argv[])
{
SDL_Window *window = NULL;
SDL_Surface *screenSurface = NULL;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("Could not initialize SDL: %s\n", SDL_GetError());
return 1;
}
@@ -15,7 +15,7 @@ int main(int argc, char *argv[])
return 1;
}
screenSurface = SDL_GetWindowSurface(window);
SDL_FillSurfaceRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xff, 0xff, 0xff));
SDL_FillSurfaceRect(screenSurface, NULL, SDL_MapSurfaceRGB(screenSurface, 0xff, 0xff, 0xff));
SDL_UpdateWindowSurface(window);
SDL_Delay(100);
SDL_DestroyWindow(window);
+1 -1
View File
@@ -17,7 +17,7 @@ int MYLIBRARY_EXPORT mylibrary_work(void);
int mylibrary_init(void) {
SDL_SetMainReady();
if (SDL_Init(0) < 0) {
if (!SDL_Init(0)) {
SDL_Log("Could not initialize SDL: %s\n", SDL_GetError());
return 1;
}
@@ -0,0 +1,4 @@
module SDL3 [extern_c] {
header "shim.h"
export *
}
+3
View File
@@ -0,0 +1,3 @@
/* Contributed by Piotr Usewicz (https://github.com/pusewicz) */
#include <SDL3/SDL.h>