-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
113 lines (94 loc) · 3.36 KB
/
Copy pathxmake.lua
File metadata and controls
113 lines (94 loc) · 3.36 KB
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
111
112
113
set_languages("c++26")
add_rules("mode.debug", "mode.release")
add_rules("plugin.compile_commands.autoupdate", {outputdir = ".vscode"})
option("san")
set_default("none")
set_values("none", "asan", "tsan", "ubsan")
set_showmenu(true)
option_end()
if is_mode("debug") then
-- Debug STL / CRT checks
if is_plat("windows") and not is_config("toolchain", "mingw", "clang", "llvm") then
add_defines("_ITERATOR_DEBUG_LEVEL=2", "_CRTDBG_MAP_ALLOC")
elseif is_config("toolchain", "gcc", "mingw", "clang", "llvm") then
add_defines("_GLIBCXX_DEBUG", "_GLIBCXX_DEBUG_PEDANTIC")
end
local san = get_config("san")
if san == "asan" then
set_policy("build.sanitizer.address", true)
elseif san == "tsan" then
set_policy("build.sanitizer.thread", true)
elseif san == "ubsan" then
set_policy("build.sanitizer.undefined", true)
end
elseif is_mode("release") then
add_requires("mimalloc", { configs = { shared = true, debug = false }})
add_defines("TILAPIA_USE_MIMALLOC")
end
local libs = {
{ name = "Tilapia.IRLib", deps = {} },
{ name = "Tilapia.Platform", deps = {} },
{ name = "Tilapia.Protocol", deps = { "Tilapia.Platform" } },
}
local apps = {
{ name = "Tilapia.CLI", binname = "tilapia", deps = { "Tilapia.Platform", "Tilapia.Protocol" } },
{ name = "Tilapia.Daemon", binname = "tilapiad", deps = { "Tilapia.Platform", "Tilapia.Protocol" } },
{ name = "Tilapia.Runtime", binname = "tiruntime", deps = { "Tilapia.IRLib", "Tilapia.Platform", "Tilapia.Protocol" } },
{ name = "Tilapia.IRVis", binname = "tirvis", deps = { "Tilapia.IRLib" } },
}
local tests = {
{ name = "makeBin", deps = { "Tilapia.IRLib" } },
}
for _, lib in ipairs(libs) do
target(lib.name)
set_kind("static")
add_files("src/" .. lib.name .. "/**.cppm", {public = true})
local srcFiles = os.files("src/" .. lib.name .. "/**.cpp")
if #srcFiles > 0 then
add_files(srcFiles)
end
set_policy("build.c++.modules", true)
set_policy("build.optimization.lto", true)
if #lib.deps > 0 then
add_deps(table.unpack(lib.deps))
end
if is_mode("release") then
add_packages("mimalloc")
end
if is_plat("windows") then
add_links("ws2_32")
end
end
for _, app in ipairs(apps) do
target(app.name)
set_kind("binary")
add_includedirs("include/" .. app.name)
add_headerfiles("include/" .. app.name .. "/**.hpp")
add_files("src/" .. app.name .. "/**.cppm")
add_files("src/" .. app.name .. "/**.cpp")
add_packages("mimalloc")
set_policy("build.c++.modules", true)
set_policy("build.optimization.lto", true)
set_basename(app.binname)
if #app.deps > 0 then
add_deps(table.unpack(app.deps))
end
if is_mode("release") then
add_packages("mimalloc")
end
if is_plat("windows") then
add_links("ws2_32")
end
end
for _, test in ipairs(tests) do
target(test.name)
set_kind("binary")
add_files("tests/" .. test.name .. "/**.cpp")
set_policy("build.c++.modules", true)
if #test.deps > 0 then
add_deps(table.unpack(test.deps))
end
if is_plat("windows") then
add_links("ws2_32")
end
end