Skip to content

Commit

Permalink
build: Make libavif and SDL2 optional
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Feb 5, 2024
1 parent 67984a8 commit e2828ba
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
option('pipewire', type: 'feature', description: 'Screen capture via PipeWire')
option('drm_backend', type: 'feature', description: 'DRM Atomic Backend')
option('sdl2_backend', type: 'feature', description: 'SDL2 Window Backend')
option('avif_screenshots', type: 'feature', description: 'Support for saving .AVIF HDR screenshots')
option('enable_gamescope', type : 'boolean', value : true, description: 'Build Gamescope executable')
option('enable_gamescope_wsi_layer', type : 'boolean', value : true, description: 'Build Gamescope layer')
option('enable_openvr_support', type : 'boolean', value : true, description: 'OpenVR Integrations')
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,11 @@ int main(int argc, char **argv)
gamescope::IBackend::Set<gamescope::CDRMBackend>();
break;
#endif
#if HAVE_SDL2
case gamescope::GamescopeBackend::SDL:
gamescope::IBackend::Set<gamescope::CSDLBackend>();
break;
#endif
#if HAVE_OPENVR
case gamescope::GamescopeBackend::OpenVR:
gamescope::IBackend::Set<gamescope::COpenVRBackend>();
Expand Down
13 changes: 10 additions & 3 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ thread_dep = dependency('threads')
cap_dep = dependency('libcap', required: false)
epoll_dep = dependency('epoll-shim', required: false)
glm_dep = dependency('glm')
sdl_dep = dependency('SDL2')
sdl_dep = dependency('SDL2', required: get_option('sdl2_backend'))
stb_dep = dependency('stb')
avif_dep = dependency('libavif', version: '>=1.0.0')
avif_dep = dependency('libavif', version: '>=1.0.0', required: get_option('avif_screenshots'))

wlroots_dep = dependency(
'wlroots',
Expand Down Expand Up @@ -107,6 +107,14 @@ if drm_dep.found()
gamescope_cpp_args += '-DHAVE_DRM=@0@'.format(drm_dep.found().to_int())
endif

if sdl_dep.found()
src += 'sdlwindow.cpp'
gamescope_cpp_args += '-DHAVE_SDL2=@0@'.format(sdl_dep.found().to_int())
endif

if avif_dep.found()
gamescope_cpp_args += '-DHAVE_AVIF=@0@'.format(avif_dep.found().to_int())
endif

src = [
'steamcompmgr.cpp',
Expand All @@ -116,7 +124,6 @@ src = [
'headless.cpp',
'wlserver.cpp',
'modegen.cpp',
'sdlwindow.cpp',
'vblankmanager.cpp',
'rendervulkan.cpp',
'log.cpp',
Expand Down
5 changes: 5 additions & 0 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@
#include "mwm_hints.h"
#include "edid.h"

#if HAVE_AVIF
#include "avif/avif.h"
#endif

static const int g_nBaseCursorScale = 36;

Expand Down Expand Up @@ -2908,6 +2910,8 @@ paint_all(bool async)
}
}

assert( HAVE_AVIF );
#if HAVE_AVIF
avifResult avifResult = AVIF_RESULT_OK;

avifImage *pAvifImage = avifImageCreate( g_nOutputWidth, g_nOutputHeight, 10, AVIF_PIXEL_FORMAT_YUV444 );
Expand Down Expand Up @@ -2976,6 +2980,7 @@ paint_all(bool async)

xwm_log.infof( "Screenshot saved to %s", oScreenshotInfo->szScreenshotPath.c_str() );
bScreenshotSuccess = true;
#endif
}
else if (pScreenshotTexture->format() == VK_FORMAT_B8G8R8A8_UNORM)
{
Expand Down

0 comments on commit e2828ba

Please sign in to comment.