Adjusted SDL build script to work with SDL3 (kind of).

This commit is contained in:
Patrick 2024-09-11 09:00:26 +02:00
parent 1b8d6e175b
commit 941f94a7b6
2 changed files with 29 additions and 6 deletions

View File

@ -0,0 +1,13 @@
diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake
index a08895c64..d3873387d 100644
--- a/cmake/GetGitRevisionDescription.cmake
+++ b/cmake/GetGitRevisionDescription.cmake
@@ -143,7 +143,7 @@ function(get_git_head_revision _refspecvar _hashvar)
string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir
${worktree_ref})
string(STRIP ${git_worktree_dir} git_worktree_dir)
- _git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR)
+ set(GIT_DIR "${git_worktree_dir}")
set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD")
endif()
else()

View File

@ -6,22 +6,32 @@ from SCons.Script import *
def _git_cook(env: Environment, repo: dict) -> dict:
checkout_root = repo['checkout_root']
build_result = env.CMakeProject(project_root=checkout_root, generate_args = ['-DSDL_STATIC=ON', '-DSDL_SHARED=OFF'])
libs = []
if platform.system() == 'Windows':
if env['BUILD_TYPE'] == 'debug':
libs.append('SDL2-staticd')
lib_names = ['SDL2-staticd', 'SDL3-staticd']
else:
libs.append('SDL2-static')
lib_names = ['SDL2-static', 'SDL3-static']
libs.extend(('kernel32', 'user32', 'gdi32', 'winmm', 'imm32', 'ole32', 'oleaut32', 'version', 'uuid', 'advapi32', 'setupapi', 'shell32', 'dinput8'))
else:
if env['BUILD_TYPE'] == 'debug':
libs.append('SDL2d')
lib_names = ['SDL2d', 'SDL3']
else:
libs.append('SDL2')
lib_names = ['SDL2', 'SDL3']
lib_file = None
is_sdl3 = False
for lib_name in lib_names:
lib_file = env.FindLib(lib_name, paths=build_result['LIBPATH'], allow_fail=True)
if lib_file:
is_sdl3 = "SDL3" in lib_name
break
if not lib_file:
env.Error('Could not find SDL lib file.')
libs.insert(0, lib_file)
return {
'LIBPATH': build_result['LIBPATH'],
'CPPPATH': [os.path.join(build_result['install_dir'], 'include/SDL2')], # SDL is really weird about include paths ...
'CPPPATH': [os.path.join(build_result['install_dir'], (is_sdl3 and 'include' or 'include/SDL2'))], # SDL is really weird about include paths ...
'LIBS': libs
}