build: 根据平台环境配置SDL2的Wayland支持

在Linux平台下检测XDG_SESSION_TYPE环境变量,动态启用SDL2的Wayland后端支持。修改xmake.lua构建配置以适配不同显示服务器环境。
This commit is contained in:
ChestnutYueyue 2026-02-15 15:35:26 +08:00
parent 0700bad5d9
commit 78680138c2
1 changed files with 13 additions and 1 deletions

View File

@ -85,8 +85,20 @@ end
if target_plat ~= "switch" then
add_requires("glm")
add_requires("nlohmann_json")
add_requires("libsdl2")
local sdl2_configs = {
configs = {
wayland = false
}
}
if target_plat == "linux" then
local is_wayland = os.getenv("XDG_SESSION_TYPE") == "wayland"
if is_wayland then
sdl2_configs.configs.wayland = true
end
end
add_requires("libsdl2", sdl2_configs)
end
-- ==============================================
-- 加载构建目标