2026-02-11 19:40:26 +08:00
|
|
|
-- ==============================================
|
|
|
|
|
-- Extra2D 引擎库共享配置
|
|
|
|
|
-- 被主项目和示例共享使用
|
|
|
|
|
-- ==============================================
|
|
|
|
|
|
|
|
|
|
-- 获取当前平台
|
|
|
|
|
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-25 06:46:13 +08:00
|
|
|
add_files("src/**.cpp")
|
2026-02-25 06:05:34 +08:00
|
|
|
add_files("third_party/glad/src/glad.c")
|
2026-02-11 19:40:26 +08:00
|
|
|
|
2026-02-25 06:46:13 +08:00
|
|
|
add_includedirs("include", {public = true})
|
2026-02-25 06:05:34 +08:00
|
|
|
add_includedirs("third_party/glad/include", {public = true})
|
2026-02-25 06:08:58 +08:00
|
|
|
add_includedirs("third_party", {public = true})
|
2026-02-11 19:40:26 +08:00
|
|
|
|
|
|
|
|
local plat = get_current_plat()
|
2026-02-27 20:46:16 +08:00
|
|
|
if plat == "mingw" then
|
|
|
|
|
add_defines("_UNICODE", "UNICODE")
|
|
|
|
|
add_packages("glm", "libsdl2", "libsdl2_mixer", {public = true})
|
|
|
|
|
add_syslinks("opengl32", "glu32", "winmm", "imm32", "version", "setupapi", {public = true})
|
|
|
|
|
elseif plat == "switch" then
|
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")
|
|
|
|
|
add_syslinks("SDL2_mixer", "SDL2", "opusfile", "opus", "vorbisidec", "ogg",
|
|
|
|
|
"modplug", "mpg123", "FLAC", "GLESv2", "EGL", "glapi", "drm_nouveau",
|
|
|
|
|
{public = true})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
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})
|
|
|
|
|
|
|
|
|
|
add_cxxflags("-Wno-deprecated-copy", "-Wno-class-memaccess", {force = true})
|
|
|
|
|
|
|
|
|
|
if is_mode("debug") then
|
|
|
|
|
add_defines("E2D_DEBUG", "_DEBUG", {public = true})
|
|
|
|
|
add_cxxflags("-O0", "-g", {force = true})
|
|
|
|
|
else
|
|
|
|
|
add_defines("NDEBUG", {public = true})
|
|
|
|
|
add_cxxflags("-O2", {force = true})
|
|
|
|
|
end
|
|
|
|
|
target_end()
|
|
|
|
|
end
|