refactor(build): 迁移到MSVC编译系统并添加Vulkan支持

- 移除MinGW平台特定配置,改为MSVC编译器标志
- 添加Vulkan相关依赖和链接库
- 合并多个add_requires调用为单个语句
- 统一所有目标的编译器标志配置
This commit is contained in:
ChestnutYueyue 2026-02-21 14:49:48 +08:00
parent 68c3f786f6
commit 23b573d4fe
1 changed files with 27 additions and 43 deletions

View File

@ -2,7 +2,6 @@
-- Extra2D - 2D Game Engine -- Extra2D - 2D Game Engine
-- Build System: Xmake -- Build System: Xmake
-- --
-- 支持平台: Windows (MinGW)
-- 窗口后端: GLFW -- 窗口后端: GLFW
-- 渲染后端: OpenGL -- 渲染后端: OpenGL
-- ============================================== -- ==============================================
@ -29,23 +28,11 @@ option("debug_logs")
set_description("Enable debug logging") set_description("Enable debug logging")
option_end() option_end()
-- ==============================================
-- 平台配置
-- ==============================================
set_plat("mingw")
set_arch("x86_64")
-- ============================================== -- ==============================================
-- 添加依赖包 -- 添加依赖包
-- ============================================== -- ==============================================
add_requires("glm") add_requires("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", "vulkan-headers", "vulkan-loader")
add_requires("nlohmann_json")
add_requires("glfw")
add_requires("zstd")
add_requires("lz4")
add_requires("zlib")
-- ============================================== -- ==============================================
-- 引擎库目标 -- 引擎库目标
@ -64,28 +51,25 @@ target("extra2d")
add_includedirs("Extra2D/include", {public = true}) add_includedirs("Extra2D/include", {public = true})
add_includedirs("Extra2D/include/extra2d/platform", {public = true}) add_includedirs("Extra2D/include/extra2d/platform", {public = true})
-- Windows (MinGW) 平台配置 -- 依赖包
add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", {public = true}) add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", "vulkan-headers", "vulkan-loader", {public = true})
add_syslinks("winmm", "imm32", "version", "setupapi", {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}) add_defines("E2D_USE_ZSTD", "E2D_USE_LZ4", "E2D_USE_ZLIB", {public = true})
-- 编译器标志 (C 和 C++ 共用) -- 编译器标志 (MSVC)
add_cxflags("-Wall", "-Wextra", {force = true}) add_cxflags("/W4", {force = true})
add_cxflags("-Wno-unused-variable", "-Wno-unused-function", "-Wno-unused-parameter", {force = true}) add_cxflags("/wd4100", "/wd4189", "/wd4458", "/wd4324", "/wd4310", "/wd4505", "/wd4702", {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})
if is_mode("debug") then if is_mode("debug") then
add_defines("_DEBUG", {public = true}) add_defines("_DEBUG", {public = true})
add_cxxflags("-O0", "-g", {force = true}) add_cxflags("/Od", "/Zi", {force = true})
else else
add_defines("NDEBUG", {public = true}) add_defines("NDEBUG", {public = true})
add_cxxflags("-O2", {force = true}) add_cxflags("/O2", {force = true})
end end
target_end() target_end()
@ -112,20 +96,20 @@ target("extra2d_tests")
-- 依赖引擎库 -- 依赖引擎库
add_deps("extra2d") add_deps("extra2d")
-- 平台配置 -- 依赖包
add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib") add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", "vulkan-headers", "vulkan-loader")
add_syslinks("winmm", "imm32", "version", "setupapi") add_syslinks("winmm", "imm32", "version", "setupapi", "vulkan-1")
-- 编译器标志 -- 编译器标志 (MSVC)
add_cxflags("-Wall", "-Wextra", {force = true}) add_cxflags("/W4", {force = true})
add_cxflags("-Wno-unused-variable", "-Wno-unused-function", "-Wno-unused-parameter", {force = true}) add_cxflags("/wd4100", "/wd4189", "/wd4458", "/wd4324", "/wd4310", "/wd4505", "/wd4702", {force = true})
if is_mode("debug") then if is_mode("debug") then
add_defines("_DEBUG") add_defines("_DEBUG")
add_cxxflags("-O0", "-g", {force = true}) add_cxflags("/Od", "/Zi", {force = true})
else else
add_defines("NDEBUG") add_defines("NDEBUG")
add_cxxflags("-O2", {force = true}) add_cxflags("/O2", {force = true})
end end
target_end() target_end()
@ -146,19 +130,19 @@ target("asset_packer")
-- 依赖引擎库 -- 依赖引擎库
add_deps("extra2d") add_deps("extra2d")
-- 平台配置 -- 依赖包
add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib") add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", "vulkan-headers", "vulkan-loader")
add_syslinks("winmm", "imm32", "version", "setupapi") add_syslinks("winmm", "imm32", "version", "setupapi", "vulkan-1")
-- 编译器标志 -- 编译器标志 (MSVC)
add_cxflags("-Wall", "-Wextra", {force = true}) add_cxflags("/W4", {force = true})
add_cxflags("-Wno-unused-variable", "-Wno-unused-function", "-Wno-unused-parameter", {force = true}) add_cxflags("/wd4100", "/wd4189", "/wd4458", "/wd4324", "/wd4310", "/wd4505", "/wd4702", {force = true})
if is_mode("debug") then if is_mode("debug") then
add_defines("_DEBUG") add_defines("_DEBUG")
add_cxxflags("-O0", "-g", {force = true}) add_cxflags("/Od", "/Zi", {force = true})
else else
add_defines("NDEBUG") add_defines("NDEBUG")
add_cxxflags("-O2", {force = true}) add_cxflags("/O2", {force = true})
end end
target_end() target_end()