-
Notifications
You must be signed in to change notification settings - Fork 8
/
xmake.lua
110 lines (91 loc) · 3.13 KB
/
xmake.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
set_project("Doodle")
set_version("0.1.0")
add_rules("mode.debug", "mode.release")
add_requires("fmt", "assimp", "boost", "stb", "spdlog", "nlohmann_json", "glfw", "glm", "entt", "nativefiledialog-extended")
add_requires("glad", {configs = {extensions = "GL_ARB_bindless_texture"}})
add_requires("imgui v1.91.0-docking", {configs = {glfw_opengl3 = true}})
add_requires("imnodes")
add_requireconfs("pybind11.python", {override = true, version = "3.10"})
add_requires("pybind11")
if is_os("windows") then
add_defines("DOO_PLATFORM_WINDOWS")
elseif is_os("linux") then
add_defines("DOO_PLATFORM_LINUX")
elseif is_os("macosx") then
add_defines("DOO_PLATFORM_MACOS")
end
set_optimize("fastest")
set_languages("c++20")
add_rules("plugin.compile_commands.autoupdate", {outputdir = ".vscode"})
-- 在构建后调用创建符号链接的函数
after_build(function (target)
os.cp("assets/", target:targetdir())
os.cp("config/", target:targetdir())
end)
function traverse_directory(path)
add_headerfiles(path .. "/**.h")
add_includedirs(path)
for _, dir in ipairs(os.dirs(path .. "/*")) do
add_headerfiles(dir .. "/**.h")
add_includedirs(dir)
end
end
function build_doodle()
add_defines("DOO_BUILD_DLL")
-- 添加源文件
add_files("Doodle/src/**.cpp")
-- 添加所有子目录到包含路径
traverse_directory("Doodle/src")
-- 添加预编译头
set_pcxxheader("Doodle/src/pch.h")
-- 添加依赖库
add_packages("fmt", "assimp", "boost", "stb", "spdlog", "imgui", "imnodes", "nlohmann_json", "glfw", "glad", "glm", "entt", "nativefiledialog-extended")
add_packages("pybind11")
if is_mode("debug") then
add_defines("DOO_ENABLE_ASSERTS")
add_defines("DOO_HIDE_SPLASH")
set_optimize("none")
else
set_optimize("fastest")
end
add_defines("IMGUI_DEFINE_MATH_OPERATORS", "UNICODE")
add_files("deps/ImGuizmo/*.cpp")
add_headerfiles("deps/ImGuizmo/*.h")
add_includedirs("deps/ImGuizmo")
end
target("Doodle")
set_kind("shared")
build_doodle()
target("doodle")
add_deps("Doodle")
add_defines("DOO_BUILD_PYTHON")
add_files("Doodle/pybind11/**.cpp")
add_rules("python.library", {soabi = true})
add_packages("pybind11")
build_doodle()
after_build(function (target)
local targetdir = target:targetdir()
local pythondir = targetdir .. "/python"
os.mkdir(pythondir)
os.cp(target:targetfile(), pythondir .. "/doodle.pyd")
os.cp("assets/", pythondir)
os.cp("config/", pythondir)
os.cp("python/*", pythondir)
end)
target("Sandbox")
set_kind("binary")
-- 添加源文件
add_files("Sandbox/src/**.cpp")
-- 添加依赖库
add_deps("Doodle")
traverse_directory("Doodle/src")
add_headerfiles("deps/ImGuizmo/*.h")
add_includedirs("deps/ImGuizmo")
add_packages("boost", "spdlog", "imgui", "imnodes", "imguizmo", "glm", "entt")
if is_mode("debug") then
add_defines("DOO_ENABLE_ASSERTS")
add_defines("DOO_HIDE_SPLASH")
set_optimize("none")
else
set_optimize("fastest")
end