From 6b2b9abc5940e87ac912f396b7f8ffc0fec87e2b Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Wed, 18 Nov 2026 16:38:34 +0900 Subject: [PATCH] feat(compat.sdl3): switches no-render and no-hidapi for 3.4.18 (revision 1) Two features, off by default, so the default build is the one it was: each sets an upstream *_DISABLED define at the end of the generated SDL_build_config.h, after every platform's config (MCPP_FEATURE_ is defined for the package's own units). - no-render: SDL_RENDER_DISABLED, the 2D renderer and its back ends - no-hidapi: SDL_HIDAPI_DISABLED, and SDL_JOYSTICK_HIDAPI undefined, so HIDAPI's game-controller drivers go (evdev's joystick path stays) 3.4.18's packaging is revision 1 with floor 1: the generated header is part of the installed payload, so installed copies are replaced to take the switches. Measured on Linux x64 (GCC 16, -O3) in a program on SDL_GPU and SDL_Renderer loading 18,473,342 bytes: no-hidapi 18,226,585 (-246,757), its window, input and GPU tests passing; both switches 17,998,177 (-475,165). With no-render, SDL_CreateRenderer reports "SDL not built with rendering support". --- pkgs/c/compat.sdl3.lua | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pkgs/c/compat.sdl3.lua b/pkgs/c/compat.sdl3.lua index ee2576c0..2251599f 100644 --- a/pkgs/c/compat.sdl3.lua +++ b/pkgs/c/compat.sdl3.lua @@ -184,6 +184,10 @@ package = { ["3.4.18"] = { url = "https://github.com/libsdl-org/SDL/archive/refs/tags/release-3.4.18.tar.gz", sha256 = "c4b08b950bd29d83caae0ab8d884298d27046a9d30700fb42841c50992665c90", + -- 1: the switches no-render and no-hidapi, read at the top of + -- the generated SDL_build_config.h (installed copies take them). + revision = 1, + floor = 1, }, }, macosx = { @@ -198,6 +202,10 @@ package = { ["3.4.18"] = { url = "https://github.com/libsdl-org/SDL/archive/refs/tags/release-3.4.18.tar.gz", sha256 = "c4b08b950bd29d83caae0ab8d884298d27046a9d30700fb42841c50992665c90", + -- 1: the switches no-render and no-hidapi, read at the top of + -- the generated SDL_build_config.h (installed copies take them). + revision = 1, + floor = 1, }, }, windows = { @@ -212,6 +220,10 @@ package = { ["3.4.18"] = { url = "https://github.com/libsdl-org/SDL/archive/refs/tags/release-3.4.18.tar.gz", sha256 = "c4b08b950bd29d83caae0ab8d884298d27046a9d30700fb42841c50992665c90", + -- 1: the switches no-render and no-hidapi, read at the top of + -- the generated SDL_build_config.h (installed copies take them). + revision = 1, + floor = 1, }, }, }, @@ -856,6 +868,17 @@ typedef unsigned int uintptr_t; #endif /* platform config */ +/* The package's switches (features `no-render`, `no-hidapi`), after every + platform's config so they win over its defines: mcpp defines + MCPP_FEATURE_ for this package's own units when one is on. */ +#ifdef MCPP_FEATURE_NO_RENDER +#define SDL_RENDER_DISABLED 1 +#endif +#ifdef MCPP_FEATURE_NO_HIDAPI +#define SDL_HIDAPI_DISABLED 1 +#undef SDL_JOYSTICK_HIDAPI +#endif + #endif /* SDL_build_config_h_ */ ]==], }, @@ -929,6 +952,21 @@ typedef unsigned int uintptr_t; targets = { ["sdl3"] = { kind = "lib" } }, deps = {}, + -- Subsystems an application may leave out, each a switch: mcpp's + -- MCPP_FEATURE_ turns on the `*_DISABLED` define at the top of + -- SDL_build_config.h above. Off by default: the default build is the + -- one it always was. + -- no-render the 2D renderer (SDL_Renderer: its software, GPU and + -- Vulkan back ends, and the blitters and pixel + -- conversions only it reaches); SDL_GPU, windows, + -- surfaces and events stay + -- no-hidapi HIDAPI's game-controller drivers (the evdev joystick + -- path stays) + features = { + ["no-render"] = {}, + ["no-hidapi"] = {}, + }, + linux = { sources = { "*/src/core/linux/SDL_evdev.c",