From 23b573d4fec8443bca76ea93ad2d7aa4bff8cdfe Mon Sep 17 00:00:00 2001 From: ChestnutYueyue <952134128@qq.com> Date: Sat, 21 Feb 2026 14:49:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(build):=20=E8=BF=81=E7=A7=BB=E5=88=B0M?= =?UTF-8?q?SVC=E7=BC=96=E8=AF=91=E7=B3=BB=E7=BB=9F=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0Vulkan=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除MinGW平台特定配置,改为MSVC编译器标志 - 添加Vulkan相关依赖和链接库 - 合并多个add_requires调用为单个语句 - 统一所有目标的编译器标志配置 --- xmake.lua | 70 +++++++++++++++++++++---------------------------------- 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/xmake.lua b/xmake.lua index cb16961..9d1488f 100644 --- a/xmake.lua +++ b/xmake.lua @@ -2,7 +2,6 @@ -- Extra2D - 2D Game Engine -- Build System: Xmake -- --- 支持平台: Windows (MinGW) -- 窗口后端: GLFW -- 渲染后端: OpenGL -- ============================================== @@ -29,23 +28,11 @@ option("debug_logs") set_description("Enable debug logging") option_end() --- ============================================== --- 平台配置 --- ============================================== - -set_plat("mingw") -set_arch("x86_64") - -- ============================================== -- 添加依赖包 -- ============================================== -add_requires("glm") -add_requires("nlohmann_json") -add_requires("glfw") -add_requires("zstd") -add_requires("lz4") -add_requires("zlib") +add_requires("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", "vulkan-headers", "vulkan-loader") -- ============================================== -- 引擎库目标 @@ -64,28 +51,25 @@ target("extra2d") add_includedirs("Extra2D/include", {public = true}) add_includedirs("Extra2D/include/extra2d/platform", {public = true}) - -- Windows (MinGW) 平台配置 - add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", {public = true}) - add_syslinks("winmm", "imm32", "version", "setupapi", {public = true}) + -- 依赖包 + add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", "vulkan-headers", "vulkan-loader", {public = true}) + + -- 系统库链接 + add_syslinks("winmm", "imm32", "version", "setupapi", "vulkan-1", {public = true}) -- 启用压缩库 add_defines("E2D_USE_ZSTD", "E2D_USE_LZ4", "E2D_USE_ZLIB", {public = true}) - -- 编译器标志 (C 和 C++ 共用) - add_cxflags("-Wall", "-Wextra", {force = true}) - add_cxflags("-Wno-unused-variable", "-Wno-unused-function", "-Wno-unused-parameter", {force = true}) - add_cxflags("-Wno-strict-aliasing", "-Wno-implicit-fallthrough", {force = true}) - add_cxflags("-Wno-missing-field-initializers", {force = true}) - - -- C++ 专用编译器标志 - add_cxxflags("-Wno-deprecated-copy", "-Wno-class-memaccess", {force = true}) + -- 编译器标志 (MSVC) + add_cxflags("/W4", {force = true}) + add_cxflags("/wd4100", "/wd4189", "/wd4458", "/wd4324", "/wd4310", "/wd4505", "/wd4702", {force = true}) if is_mode("debug") then add_defines("_DEBUG", {public = true}) - add_cxxflags("-O0", "-g", {force = true}) + add_cxflags("/Od", "/Zi", {force = true}) else add_defines("NDEBUG", {public = true}) - add_cxxflags("-O2", {force = true}) + add_cxflags("/O2", {force = true}) end target_end() @@ -112,20 +96,20 @@ target("extra2d_tests") -- 依赖引擎库 add_deps("extra2d") - -- 平台配置 - add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib") - add_syslinks("winmm", "imm32", "version", "setupapi") + -- 依赖包 + add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", "vulkan-headers", "vulkan-loader") + add_syslinks("winmm", "imm32", "version", "setupapi", "vulkan-1") - -- 编译器标志 - add_cxflags("-Wall", "-Wextra", {force = true}) - add_cxflags("-Wno-unused-variable", "-Wno-unused-function", "-Wno-unused-parameter", {force = true}) + -- 编译器标志 (MSVC) + add_cxflags("/W4", {force = true}) + add_cxflags("/wd4100", "/wd4189", "/wd4458", "/wd4324", "/wd4310", "/wd4505", "/wd4702", {force = true}) if is_mode("debug") then add_defines("_DEBUG") - add_cxxflags("-O0", "-g", {force = true}) + add_cxflags("/Od", "/Zi", {force = true}) else add_defines("NDEBUG") - add_cxxflags("-O2", {force = true}) + add_cxflags("/O2", {force = true}) end target_end() @@ -146,19 +130,19 @@ target("asset_packer") -- 依赖引擎库 add_deps("extra2d") - -- 平台配置 - add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib") - add_syslinks("winmm", "imm32", "version", "setupapi") + -- 依赖包 + add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", "vulkan-headers", "vulkan-loader") + add_syslinks("winmm", "imm32", "version", "setupapi", "vulkan-1") - -- 编译器标志 - add_cxflags("-Wall", "-Wextra", {force = true}) - add_cxflags("-Wno-unused-variable", "-Wno-unused-function", "-Wno-unused-parameter", {force = true}) + -- 编译器标志 (MSVC) + add_cxflags("/W4", {force = true}) + add_cxflags("/wd4100", "/wd4189", "/wd4458", "/wd4324", "/wd4310", "/wd4505", "/wd4702", {force = true}) if is_mode("debug") then add_defines("_DEBUG") - add_cxxflags("-O0", "-g", {force = true}) + add_cxflags("/Od", "/Zi", {force = true}) else add_defines("NDEBUG") - add_cxxflags("-O2", {force = true}) + add_cxflags("/O2", {force = true}) end target_end()