2026-02-11 19:40:26 +08:00
|
|
|
-- ==============================================
|
|
|
|
|
-- Extra2D 引擎库共享配置
|
|
|
|
|
-- 被主项目和示例共享使用
|
2026-02-15 12:36:36 +08:00
|
|
|
--
|
2026-02-20 12:48:36 +08:00
|
|
|
-- 窗口后端: GLFW
|
|
|
|
|
-- 渲染后端: OpenGL
|
2026-02-11 19:40:26 +08:00
|
|
|
-- ==============================================
|
|
|
|
|
|
|
|
|
|
-- 获取当前平台
|
|
|
|
|
local function get_current_plat()
|
|
|
|
|
return get_config("plat") or os.host()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 定义 Extra2D 引擎库目标
|
|
|
|
|
function define_extra2d_engine()
|
|
|
|
|
target("extra2d")
|
|
|
|
|
set_kind("static")
|
|
|
|
|
|
2026-02-20 16:36:31 +08:00
|
|
|
-- 引擎核心源文件
|
|
|
|
|
add_files("Extra2D/src/**.cpp")
|
2026-02-11 19:40:26 +08:00
|
|
|
|
2026-02-20 12:48:36 +08:00
|
|
|
-- GLFW 窗口后端源文件
|
2026-02-20 13:07:43 +08:00
|
|
|
add_files("Extra2D/src/platform/glfw/*.cpp")
|
2026-02-15 00:22:24 +08:00
|
|
|
|
2026-02-11 19:40:26 +08:00
|
|
|
-- 头文件路径
|
|
|
|
|
add_includedirs("Extra2D/include", {public = true})
|
|
|
|
|
add_includedirs("Extra2D/include/extra2d/platform", {public = true})
|
|
|
|
|
|
|
|
|
|
-- 平台配置
|
2026-02-15 12:36:36 +08:00
|
|
|
local plat = get_current_plat()
|
|
|
|
|
|
2026-02-11 19:40:26 +08:00
|
|
|
if plat == "switch" then
|
2026-02-15 12:36:36 +08:00
|
|
|
-- Nintendo Switch 平台配置
|
2026-02-11 19:40:26 +08:00
|
|
|
local devkitPro = os.getenv("DEVKITPRO") or "C:/devkitPro"
|
|
|
|
|
add_includedirs(devkitPro .. "/portlibs/switch/include", {public = true})
|
|
|
|
|
add_linkdirs(devkitPro .. "/portlibs/switch/lib")
|
2026-02-17 00:06:31 +08:00
|
|
|
|
2026-02-20 12:48:36 +08:00
|
|
|
-- GLFW 后端
|
2026-02-20 16:36:31 +08:00
|
|
|
add_syslinks("glfw", "nx", "m", {public = true})
|
2026-02-15 12:36:36 +08:00
|
|
|
elseif plat == "mingw" or plat == "windows" then
|
|
|
|
|
-- Windows (MinGW) 平台配置
|
2026-02-20 22:15:01 +08:00
|
|
|
add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", {public = true})
|
2026-02-20 16:36:31 +08:00
|
|
|
add_syslinks("winmm", "imm32", "version", "setupapi", {public = true})
|
2026-02-15 12:36:36 +08:00
|
|
|
elseif plat == "linux" then
|
|
|
|
|
-- Linux 平台配置
|
2026-02-20 22:15:01 +08:00
|
|
|
add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", {public = true})
|
2026-02-20 16:36:31 +08:00
|
|
|
add_syslinks("dl", "pthread", {public = true})
|
2026-02-15 12:36:36 +08:00
|
|
|
elseif plat == "macosx" then
|
|
|
|
|
-- macOS 平台配置
|
2026-02-20 22:15:01 +08:00
|
|
|
add_packages("glm", "nlohmann_json", "glfw", "zstd", "lz4", "zlib", {public = true})
|
2026-02-20 16:36:31 +08:00
|
|
|
add_frameworks("Cocoa", "IOKit", "CoreVideo", {public = true})
|
2026-02-11 19:40:26 +08:00
|
|
|
end
|
|
|
|
|
|
2026-02-20 22:15:01 +08:00
|
|
|
-- 启用压缩库
|
|
|
|
|
add_defines("E2D_USE_ZSTD", "E2D_USE_LZ4", "E2D_USE_ZLIB", {public = true})
|
|
|
|
|
|
2026-02-11 19:40:26 +08:00
|
|
|
-- 编译器标志 (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})
|
|
|
|
|
|
|
|
|
|
if is_mode("debug") then
|
2026-02-20 16:36:31 +08:00
|
|
|
add_defines("_DEBUG", {public = true})
|
2026-02-11 19:40:26 +08:00
|
|
|
add_cxxflags("-O0", "-g", {force = true})
|
|
|
|
|
else
|
|
|
|
|
add_defines("NDEBUG", {public = true})
|
|
|
|
|
add_cxxflags("-O2", {force = true})
|
|
|
|
|
end
|
|
|
|
|
target_end()
|
|
|
|
|
end
|