From 804384c19cad1da6bad0124481b201594493e4a2 Mon Sep 17 00:00:00 2001 From: Joel Linn Date: Mon, 30 Mar 2020 13:23:25 +0200 Subject: [PATCH] [SDL2] On Win, build and link statically. Keep using system lib dynamically on Unix. --- .appveyor.yml | 1 - .gitmodules | 6 +- premake5.lua | 1 + src/xenia/app/premake5.lua | 6 - src/xenia/apu/sdl/premake5.lua | 14 +- src/xenia/apu/sdl/sdl_audio_driver.h | 2 +- src/xenia/hid/sdl/premake5.lua | 14 +- src/xenia/hid/sdl/sdl_input_driver.h | 3 +- third_party/SDL2 | 1 + third_party/SDL2-devel-VC | 1 - third_party/SDL2-static.lua | 346 +++++++++++++++++++++++++++ third_party/SDL2.lua | 36 +++ 12 files changed, 391 insertions(+), 40 deletions(-) create mode 160000 third_party/SDL2 delete mode 160000 third_party/SDL2-devel-VC create mode 100644 third_party/SDL2-static.lua create mode 100644 third_party/SDL2.lua diff --git a/.appveyor.yml b/.appveyor.yml index bded48d4d..334685a61 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -48,7 +48,6 @@ after_build: IF "%CONFIGURATION%"=="Checked" SET "ARCHIVE_SWITCHES="-pI know what I am doing." --" 7z a xenia_%ARCHIVE_SUFFIX%.zip %ARCHIVE_SWITCHES% LICENSE "%APPVEYOR_BUILD_FOLDER%\build\bin\%PLATFORM%\%CONFIGURATION%\xenia.exe" "%APPVEYOR_BUILD_FOLDER%\build\bin\%PLATFORM%\%CONFIGURATION%\xenia.pdb" 7z a xenia-vfs-dump_%ARCHIVE_SUFFIX%.zip %ARCHIVE_SWITCHES% LICENSE "%APPVEYOR_BUILD_FOLDER%\build\bin\%PLATFORM%\%CONFIGURATION%\xenia-vfs-dump.exe" "%APPVEYOR_BUILD_FOLDER%\build\bin\%PLATFORM%\%CONFIGURATION%\xenia-vfs-dump.pdb" - 7z a SDL2.zip %ARCHIVE_SWITCHES% "%APPVEYOR_BUILD_FOLDER%\build\bin\%PLATFORM%\%CONFIGURATION%\SDL2.dll" before_test: - cmd: xb gentests diff --git a/.gitmodules b/.gitmodules index 03715db33..ec398defa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -49,9 +49,9 @@ [submodule "third_party/cxxopts"] path = third_party/cxxopts url = https://github.com/jarro2783/cxxopts.git -[submodule "third_party/SDL2-devel-VC"] - path = third_party/SDL2-devel-VC - url = https://github.com/xenia-project/SDL2-devel-VC.git +[submodule "third_party/SDL2"] + path = third_party/SDL2 + url = https://github.com/spurious/SDL-mirror.git [submodule "third_party/utfcpp"] path = third_party/utfcpp url = https://github.com/xenia-project/utfcpp.git diff --git a/premake5.lua b/premake5.lua index 22f7e5c5f..065463a48 100644 --- a/premake5.lua +++ b/premake5.lua @@ -223,6 +223,7 @@ solution("xenia") include("third_party/imgui.lua") include("third_party/libav.lua") include("third_party/mspack.lua") + include("third_party/SDL2.lua") include("third_party/snappy.lua") include("third_party/spirv-tools.lua") include("third_party/volk.lua") diff --git a/src/xenia/app/premake5.lua b/src/xenia/app/premake5.lua index 182779edf..fb316f840 100644 --- a/src/xenia/app/premake5.lua +++ b/src/xenia/app/premake5.lua @@ -79,7 +79,6 @@ project("xenia-app") filter("platforms:Windows") links({ - "delayimp", -- This library implements delayed loading on Windows, an MSVC exclusive feature. "xenia-apu-xaudio2", "xenia-gpu-d3d12", "xenia-hid-winkey", @@ -87,11 +86,6 @@ project("xenia-app") "xenia-ui-d3d12", }) - filter("platforms:Windows") - linkoptions({ - "/DELAYLOAD:SDL2.dll", -- SDL is not mandatory on Windows, implementations using native APIs are prefered. - }) - filter("platforms:Windows") -- Only create the .user file if it doesn't already exist. local user_file = project_root.."/build/xenia-app.vcxproj.user" diff --git a/src/xenia/apu/sdl/premake5.lua b/src/xenia/apu/sdl/premake5.lua index 883d8b0c6..995b128dd 100644 --- a/src/xenia/apu/sdl/premake5.lua +++ b/src/xenia/apu/sdl/premake5.lua @@ -14,16 +14,4 @@ project("xenia-apu-sdl") defines({ }) local_platform_files() - - filter("platforms:Windows") - -- On linux we build against the system version (libsdl2-dev) - includedirs({ - project_root.."/third_party/SDL2-devel-VC/include/", - }) - libdirs({ - project_root.."/third_party/SDL2-devel-VC/lib/x64/", - }) - -- Copy the dll to the output folder - postbuildcommands({ - "{COPY} %{prj.basedir}/"..project_root.."/third_party/SDL2-devel-VC/lib/x64/SDL2.dll %{cfg.targetdir}", - }) + sdl2_include() diff --git a/src/xenia/apu/sdl/sdl_audio_driver.h b/src/xenia/apu/sdl/sdl_audio_driver.h index 404ceaa6a..cb957105f 100644 --- a/src/xenia/apu/sdl/sdl_audio_driver.h +++ b/src/xenia/apu/sdl/sdl_audio_driver.h @@ -9,12 +9,12 @@ #ifndef XENIA_APU_SDL_SDL_AUDIO_DRIVER_H_ #define XENIA_APU_SDL_SDL_AUDIO_DRIVER_H_ -#include #include #include #include +#include "SDL.h" #include "xenia/apu/audio_driver.h" #include "xenia/base/threading.h" diff --git a/src/xenia/hid/sdl/premake5.lua b/src/xenia/hid/sdl/premake5.lua index 07fba14a7..d29b0b606 100644 --- a/src/xenia/hid/sdl/premake5.lua +++ b/src/xenia/hid/sdl/premake5.lua @@ -15,16 +15,4 @@ project("xenia-hid-sdl") defines({ }) local_platform_files() - - filter("platforms:Windows") - -- On linux we build against the system version (libsdl2-dev) - includedirs({ - project_root.."/third_party/SDL2-devel-VC/include/", - }) - libdirs({ - project_root.."/third_party/SDL2-devel-VC/lib/x64/", - }) - -- Copy the dll to the output folder - postbuildcommands({ - "{COPY} %{prj.basedir}/"..project_root.."/third_party/SDL2-devel-VC/lib/x64/SDL2.dll %{cfg.targetdir}", - }) + sdl2_include() diff --git a/src/xenia/hid/sdl/sdl_input_driver.h b/src/xenia/hid/sdl/sdl_input_driver.h index bfa16c995..542508084 100644 --- a/src/xenia/hid/sdl/sdl_input_driver.h +++ b/src/xenia/hid/sdl/sdl_input_driver.h @@ -10,12 +10,11 @@ #ifndef XENIA_HID_SDL_SDL_INPUT_DRIVER_H_ #define XENIA_HID_SDL_SDL_INPUT_DRIVER_H_ -#include - #include #include #include +#include "SDL.h" #include "xenia/hid/input_driver.h" #define HID_SDL_USER_COUNT (4) diff --git a/third_party/SDL2 b/third_party/SDL2 new file mode 160000 index 000000000..863c4bd26 --- /dev/null +++ b/third_party/SDL2 @@ -0,0 +1 @@ +Subproject commit 863c4bd26b51892864c6042ad2db474e11b08fed diff --git a/third_party/SDL2-devel-VC b/third_party/SDL2-devel-VC deleted file mode 160000 index f102d8b36..000000000 --- a/third_party/SDL2-devel-VC +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f102d8b36395200682108e88bec54bf9acd1004a diff --git a/third_party/SDL2-static.lua b/third_party/SDL2-static.lua new file mode 100644 index 000000000..a9206e300 --- /dev/null +++ b/third_party/SDL2-static.lua @@ -0,0 +1,346 @@ +-- This project resembles the build configuration on Windows only. +group("third_party") +project("SDL2") + uuid("65878768-95A1-4E7B-8DFB-B23A09E0DE7C") + kind("StaticLib") + language("C") + + defines({ + "HAVE_LIBC", + }) + links({ + "setupapi.lib", + "winmm.lib", + "imm32.lib", + "version.lib", + }) + includedirs({ + "SDL2/include", + }) + buildoptions({ + "/wd4828", -- illegal characters in file + }) + files({ + -- 1:1 from SDL.vcxproj file + + "SDL2/include/begin_code.h", + "SDL2/include/close_code.h", + "SDL2/include/SDL.h", + "SDL2/include/SDL_assert.h", + "SDL2/include/SDL_atomic.h", + "SDL2/include/SDL_audio.h", + "SDL2/include/SDL_bits.h", + "SDL2/include/SDL_blendmode.h", + "SDL2/include/SDL_clipboard.h", + "SDL2/include/SDL_config.h", + "SDL2/include/SDL_config_windows.h", + "SDL2/include/SDL_copying.h", + "SDL2/include/SDL_cpuinfo.h", + "SDL2/include/SDL_egl.h", + "SDL2/include/SDL_endian.h", + "SDL2/include/SDL_error.h", + "SDL2/include/SDL_events.h", + "SDL2/include/SDL_filesystem.h", + "SDL2/include/SDL_gamecontroller.h", + "SDL2/include/SDL_gesture.h", + "SDL2/include/SDL_haptic.h", + "SDL2/include/SDL_hints.h", + "SDL2/include/SDL_joystick.h", + "SDL2/include/SDL_keyboard.h", + "SDL2/include/SDL_keycode.h", + "SDL2/include/SDL_loadso.h", + "SDL2/include/SDL_log.h", + "SDL2/include/SDL_main.h", + "SDL2/include/SDL_messagebox.h", + "SDL2/include/SDL_mouse.h", + "SDL2/include/SDL_mutex.h", + "SDL2/include/SDL_name.h", + "SDL2/include/SDL_opengl.h", + "SDL2/include/SDL_opengl_glext.h", + "SDL2/include/SDL_opengles.h", + "SDL2/include/SDL_opengles2.h", + "SDL2/include/SDL_opengles2_gl2.h", + "SDL2/include/SDL_opengles2_gl2ext.h", + "SDL2/include/SDL_opengles2_gl2platform.h", + "SDL2/include/SDL_opengles2_khrplatform.h", + "SDL2/include/SDL_pixels.h", + "SDL2/include/SDL_platform.h", + "SDL2/include/SDL_power.h", + "SDL2/include/SDL_quit.h", + "SDL2/include/SDL_rect.h", + "SDL2/include/SDL_render.h", + "SDL2/include/SDL_revision.h", + "SDL2/include/SDL_rwops.h", + "SDL2/include/SDL_scancode.h", + "SDL2/include/SDL_sensor.h", + "SDL2/include/SDL_shape.h", + "SDL2/include/SDL_stdinc.h", + "SDL2/include/SDL_surface.h", + "SDL2/include/SDL_system.h", + "SDL2/include/SDL_syswm.h", + "SDL2/include/SDL_test.h", + "SDL2/include/SDL_test_assert.h", + "SDL2/include/SDL_test_common.h", + "SDL2/include/SDL_test_compare.h", + "SDL2/include/SDL_test_crc32.h", + "SDL2/include/SDL_test_font.h", + "SDL2/include/SDL_test_fuzzer.h", + "SDL2/include/SDL_test_harness.h", + "SDL2/include/SDL_test_images.h", + "SDL2/include/SDL_test_log.h", + "SDL2/include/SDL_test_md5.h", + "SDL2/include/SDL_test_random.h", + "SDL2/include/SDL_thread.h", + "SDL2/include/SDL_timer.h", + "SDL2/include/SDL_touch.h", + "SDL2/include/SDL_types.h", + "SDL2/include/SDL_version.h", + "SDL2/include/SDL_video.h", + "SDL2/include/SDL_vulkan.h", + "SDL2/src/audio/directsound/SDL_directsound.h", + "SDL2/src/audio/disk/SDL_diskaudio.h", + "SDL2/src/audio/dummy/SDL_dummyaudio.h", + "SDL2/src/audio/SDL_audio_c.h", + "SDL2/src/audio/SDL_audiodev_c.h", + "SDL2/src/audio/SDL_sysaudio.h", + "SDL2/src/audio/SDL_wave.h", + "SDL2/src/audio/wasapi/SDL_wasapi.h", + "SDL2/src/audio/winmm/SDL_winmm.h", + "SDL2/src/core/windows/SDL_directx.h", + "SDL2/src/core/windows/SDL_windows.h", + "SDL2/src/core/windows/SDL_xinput.h", + "SDL2/src/dynapi/SDL_dynapi.h", + "SDL2/src/dynapi/SDL_dynapi_overrides.h", + "SDL2/src/dynapi/SDL_dynapi_procs.h", + "SDL2/src/events/blank_cursor.h", + "SDL2/src/events/default_cursor.h", + "SDL2/src/events/SDL_clipboardevents_c.h", + "SDL2/src/events/SDL_displayevents_c.h", + "SDL2/src/events/SDL_dropevents_c.h", + "SDL2/src/events/SDL_events_c.h", + "SDL2/src/events/SDL_gesture_c.h", + "SDL2/src/events/SDL_keyboard_c.h", + "SDL2/src/events/SDL_mouse_c.h", + "SDL2/src/events/SDL_sysevents.h", + "SDL2/src/events/SDL_touch_c.h", + "SDL2/src/events/SDL_windowevents_c.h", + "SDL2/src/haptic/SDL_syshaptic.h", + "SDL2/src/haptic/windows/SDL_dinputhaptic_c.h", + "SDL2/src/haptic/windows/SDL_windowshaptic_c.h", + "SDL2/src/haptic/windows/SDL_xinputhaptic_c.h", + "SDL2/src/joystick/controller_type.h", + "SDL2/src/joystick/hidapi/SDL_hidapijoystick_c.h", + "SDL2/src/joystick/SDL_joystick_c.h", + "SDL2/src/joystick/SDL_sysjoystick.h", + "SDL2/src/joystick/windows/SDL_dinputjoystick_c.h", + "SDL2/src/joystick/windows/SDL_windowsjoystick_c.h", + "SDL2/src/joystick/windows/SDL_xinputjoystick_c.h", + "SDL2/src/libm/math_libm.h", + "SDL2/src/libm/math_private.h", + "SDL2/src/render/direct3d11/SDL_shaders_d3d11.h", + "SDL2/src/render/direct3d/SDL_shaders_d3d.h", + "SDL2/src/render/opengl/SDL_glfuncs.h", + "SDL2/src/render/opengl/SDL_shaders_gl.h", + "SDL2/src/render/opengles/SDL_glesfuncs.h", + "SDL2/src/render/SDL_d3dmath.h", + "SDL2/src/render/SDL_sysrender.h", + "SDL2/src/render/SDL_yuv_sw_c.h", + "SDL2/src/render/software/SDL_blendfillrect.h", + "SDL2/src/render/software/SDL_blendline.h", + "SDL2/src/render/software/SDL_blendpoint.h", + "SDL2/src/render/software/SDL_draw.h", + "SDL2/src/render/software/SDL_drawline.h", + "SDL2/src/render/software/SDL_drawpoint.h", + "SDL2/src/render/software/SDL_render_sw_c.h", + "SDL2/src/render/software/SDL_rotate.h", + "SDL2/src/SDL_dataqueue.h", + "SDL2/src/SDL_error_c.h", + "SDL2/src/sensor/dummy/SDL_dummysensor.h", + "SDL2/src/sensor/SDL_sensor_c.h", + "SDL2/src/sensor/SDL_syssensor.h", + "SDL2/src/thread/SDL_systhread.h", + "SDL2/src/thread/SDL_thread_c.h", + "SDL2/src/thread/windows/SDL_systhread_c.h", + "SDL2/src/timer/SDL_timer_c.h", + "SDL2/src/video/dummy/SDL_nullevents_c.h", + "SDL2/src/video/dummy/SDL_nullframebuffer_c.h", + "SDL2/src/video/dummy/SDL_nullvideo.h", + "SDL2/src/video/SDL_blit.h", + "SDL2/src/video/SDL_blit_auto.h", + "SDL2/src/video/SDL_blit_copy.h", + "SDL2/src/video/SDL_blit_slow.h", + "SDL2/src/video/SDL_pixels_c.h", + "SDL2/src/video/SDL_rect_c.h", + "SDL2/src/video/SDL_RLEaccel_c.h", + "SDL2/src/video/SDL_shape_internals.h", + "SDL2/src/video/SDL_sysvideo.h", + "SDL2/src/video/SDL_vulkan_internal.h", + "SDL2/src/video/SDL_yuv_c.h", + "SDL2/src/video/windows/SDL_vkeys.h", + "SDL2/src/video/windows/SDL_windowsclipboard.h", + "SDL2/src/video/windows/SDL_windowsevents.h", + "SDL2/src/video/windows/SDL_windowsframebuffer.h", + "SDL2/src/video/windows/SDL_windowskeyboard.h", + "SDL2/src/video/windows/SDL_windowsmessagebox.h", + "SDL2/src/video/windows/SDL_windowsmodes.h", + "SDL2/src/video/windows/SDL_windowsmouse.h", + "SDL2/src/video/windows/SDL_windowsopengl.h", + "SDL2/src/video/windows/SDL_windowsshape.h", + "SDL2/src/video/windows/SDL_windowsvideo.h", + "SDL2/src/video/windows/SDL_windowsvulkan.h", + "SDL2/src/video/windows/SDL_windowswindow.h", + "SDL2/src/video/windows/wmmsg.h", + "SDL2/src/video/yuv2rgb/yuv_rgb.h", + + "SDL2/src/atomic/SDL_atomic.c", + "SDL2/src/atomic/SDL_spinlock.c", + "SDL2/src/audio/directsound/SDL_directsound.c", + "SDL2/src/audio/disk/SDL_diskaudio.c", + "SDL2/src/audio/dummy/SDL_dummyaudio.c", + "SDL2/src/audio/SDL_audio.c", + "SDL2/src/audio/SDL_audiocvt.c", + "SDL2/src/audio/SDL_audiodev.c", + "SDL2/src/audio/SDL_audiotypecvt.c", + "SDL2/src/audio/SDL_mixer.c", + "SDL2/src/audio/SDL_wave.c", + "SDL2/src/audio/winmm/SDL_winmm.c", + "SDL2/src/audio/wasapi/SDL_wasapi.c", + "SDL2/src/audio/wasapi/SDL_wasapi_win32.c", + "SDL2/src/core/windows/SDL_windows.c", + "SDL2/src/core/windows/SDL_xinput.c", + "SDL2/src/cpuinfo/SDL_cpuinfo.c", + "SDL2/src/dynapi/SDL_dynapi.c", + "SDL2/src/events/SDL_clipboardevents.c", + "SDL2/src/events/SDL_displayevents.c", + "SDL2/src/events/SDL_dropevents.c", + "SDL2/src/events/SDL_events.c", + "SDL2/src/events/SDL_gesture.c", + "SDL2/src/events/SDL_keyboard.c", + "SDL2/src/events/SDL_mouse.c", + "SDL2/src/events/SDL_quit.c", + "SDL2/src/events/SDL_touch.c", + "SDL2/src/events/SDL_windowevents.c", + "SDL2/src/file/SDL_rwops.c", + "SDL2/src/filesystem/windows/SDL_sysfilesystem.c", + "SDL2/src/haptic/SDL_haptic.c", + "SDL2/src/haptic/windows/SDL_dinputhaptic.c", + "SDL2/src/haptic/windows/SDL_windowshaptic.c", + "SDL2/src/haptic/windows/SDL_xinputhaptic.c", + "SDL2/src/hidapi/windows/hid.c", + "SDL2/src/joystick/hidapi/SDL_hidapijoystick.c", + "SDL2/src/joystick/hidapi/SDL_hidapi_gamecube.c", + "SDL2/src/joystick/hidapi/SDL_hidapi_ps4.c", + "SDL2/src/joystick/hidapi/SDL_hidapi_rumble.c", + "SDL2/src/joystick/hidapi/SDL_hidapi_switch.c", + "SDL2/src/joystick/hidapi/SDL_hidapi_xbox360.c", + "SDL2/src/joystick/hidapi/SDL_hidapi_xbox360w.c", + "SDL2/src/joystick/hidapi/SDL_hidapi_xboxone.c", + "SDL2/src/joystick/SDL_gamecontroller.c", + "SDL2/src/joystick/SDL_joystick.c", + "SDL2/src/joystick/windows/SDL_dinputjoystick.c", + "SDL2/src/joystick/windows/SDL_mmjoystick.c", + "SDL2/src/joystick/windows/SDL_windowsjoystick.c", + "SDL2/src/joystick/windows/SDL_xinputjoystick.c", + "SDL2/src/libm/e_atan2.c", + "SDL2/src/libm/e_exp.c", + "SDL2/src/libm/e_fmod.c", + "SDL2/src/libm/e_log.c", + "SDL2/src/libm/e_log10.c", + "SDL2/src/libm/e_pow.c", + "SDL2/src/libm/e_rem_pio2.c", + "SDL2/src/libm/e_sqrt.c", + "SDL2/src/libm/k_cos.c", + "SDL2/src/libm/k_rem_pio2.c", + "SDL2/src/libm/k_sin.c", + "SDL2/src/libm/k_tan.c", + "SDL2/src/libm/s_atan.c", + "SDL2/src/libm/s_copysign.c", + "SDL2/src/libm/s_cos.c", + "SDL2/src/libm/s_fabs.c", + "SDL2/src/libm/s_floor.c", + "SDL2/src/libm/s_scalbn.c", + "SDL2/src/libm/s_sin.c", + "SDL2/src/libm/s_tan.c", + "SDL2/src/loadso/windows/SDL_sysloadso.c", + "SDL2/src/power/SDL_power.c", + "SDL2/src/power/windows/SDL_syspower.c", + "SDL2/src/render/direct3d11/SDL_shaders_d3d11.c", + "SDL2/src/render/direct3d/SDL_render_d3d.c", + "SDL2/src/render/direct3d11/SDL_render_d3d11.c", + "SDL2/src/render/direct3d/SDL_shaders_d3d.c", + "SDL2/src/render/opengl/SDL_render_gl.c", + "SDL2/src/render/opengl/SDL_shaders_gl.c", + "SDL2/src/render/opengles2/SDL_render_gles2.c", + "SDL2/src/render/opengles2/SDL_shaders_gles2.c", + "SDL2/src/render/SDL_d3dmath.c", + "SDL2/src/render/SDL_render.c", + "SDL2/src/render/SDL_yuv_sw.c", + "SDL2/src/render/software/SDL_blendfillrect.c", + "SDL2/src/render/software/SDL_blendline.c", + "SDL2/src/render/software/SDL_blendpoint.c", + "SDL2/src/render/software/SDL_drawline.c", + "SDL2/src/render/software/SDL_drawpoint.c", + "SDL2/src/render/software/SDL_render_sw.c", + "SDL2/src/render/software/SDL_rotate.c", + "SDL2/src/SDL.c", + "SDL2/src/SDL_assert.c", + "SDL2/src/SDL_dataqueue.c", + "SDL2/src/SDL_error.c", + "SDL2/src/SDL_hints.c", + "SDL2/src/SDL_log.c", + "SDL2/src/sensor/dummy/SDL_dummysensor.c", + "SDL2/src/sensor/SDL_sensor.c", + "SDL2/src/stdlib/SDL_getenv.c", + "SDL2/src/stdlib/SDL_iconv.c", + "SDL2/src/stdlib/SDL_malloc.c", + "SDL2/src/stdlib/SDL_qsort.c", + "SDL2/src/stdlib/SDL_stdlib.c", + "SDL2/src/stdlib/SDL_string.c", + "SDL2/src/stdlib/SDL_strtokr.c", + "SDL2/src/thread/generic/SDL_syscond.c", + "SDL2/src/thread/SDL_thread.c", + "SDL2/src/thread/windows/SDL_sysmutex.c", + "SDL2/src/thread/windows/SDL_syssem.c", + "SDL2/src/thread/windows/SDL_systhread.c", + "SDL2/src/thread/windows/SDL_systls.c", + "SDL2/src/timer/SDL_timer.c", + "SDL2/src/timer/windows/SDL_systimer.c", + "SDL2/src/video/dummy/SDL_nullevents.c", + "SDL2/src/video/dummy/SDL_nullframebuffer.c", + "SDL2/src/video/dummy/SDL_nullvideo.c", + "SDL2/src/video/SDL_blit.c", + "SDL2/src/video/SDL_blit_0.c", + "SDL2/src/video/SDL_blit_1.c", + "SDL2/src/video/SDL_blit_A.c", + "SDL2/src/video/SDL_blit_auto.c", + "SDL2/src/video/SDL_blit_copy.c", + "SDL2/src/video/SDL_blit_N.c", + "SDL2/src/video/SDL_blit_slow.c", + "SDL2/src/video/SDL_bmp.c", + "SDL2/src/video/SDL_clipboard.c", + "SDL2/src/video/SDL_egl.c", + "SDL2/src/video/SDL_fillrect.c", + "SDL2/src/video/SDL_pixels.c", + "SDL2/src/video/SDL_rect.c", + "SDL2/src/video/SDL_RLEaccel.c", + "SDL2/src/video/SDL_shape.c", + "SDL2/src/video/SDL_stretch.c", + "SDL2/src/video/SDL_surface.c", + "SDL2/src/video/SDL_video.c", + "SDL2/src/video/SDL_vulkan_utils.c", + "SDL2/src/video/SDL_yuv.c", + "SDL2/src/video/windows/SDL_windowsclipboard.c", + "SDL2/src/video/windows/SDL_windowsevents.c", + "SDL2/src/video/windows/SDL_windowsframebuffer.c", + "SDL2/src/video/windows/SDL_windowskeyboard.c", + "SDL2/src/video/windows/SDL_windowsmessagebox.c", + "SDL2/src/video/windows/SDL_windowsmodes.c", + "SDL2/src/video/windows/SDL_windowsmouse.c", + "SDL2/src/video/windows/SDL_windowsopengl.c", + "SDL2/src/video/windows/SDL_windowsopengles.c", + "SDL2/src/video/windows/SDL_windowsshape.c", + "SDL2/src/video/windows/SDL_windowsvideo.c", + "SDL2/src/video/windows/SDL_windowsvulkan.c", + "SDL2/src/video/windows/SDL_windowswindow.c", + "SDL2/src/video/yuv2rgb/yuv_rgb.c", + }) diff --git a/third_party/SDL2.lua b/third_party/SDL2.lua new file mode 100644 index 000000000..ab4c68d34 --- /dev/null +++ b/third_party/SDL2.lua @@ -0,0 +1,36 @@ +-- +-- On Linux we build against the system version (libsdl2-dev for building), +-- since SDL2 is our robust API there like DirectX is on Windows. +-- + +local sdl2_sys_includedirs = {} +local third_party_path = os.getcwd() + +if os.istarget("windows") then + -- build ourselves + include("SDL2-static.lua") +else + -- use system libraries + local result, code, what = os.outputof("sdl2-config --cflags") + if result then + for inc in string.gmatch(result, "-I([%S]+)") do + table.insert(sdl2_sys_includedirs, inc) + end + else + error("Failed to run 'sdl2-config'. Are libsdl2 development files installed?") + end +end + + +-- +-- Call this function in project scope to include the SDL2 headers. +-- +function sdl2_include() + filter("platforms:Windows") + includedirs({ + path.getrelative(".", third_party_path) .. "/SDL2/include", + }) + filter("platforms:Linux") + includedirs(sdl2_sys_includedirs) + filter({}) +end