-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
189 lines (167 loc) · 6.31 KB
/
xmake.lua
File metadata and controls
189 lines (167 loc) · 6.31 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
add_rules("mode.debug", "mode.release", "mode.coverage")
add_rules("plugin.vsxmake.autoupdate")
add_repositories("concerto-xrepo https://github.com/ConcertoEngine/xmake-repo.git main")
-- package("concerto-core")
-- on_fetch(function (package)
-- local concerto_core = "C:/Users/Arthur/Documents/Git/ConcertoEngine/ConcertoCore/install"
-- return {
-- linkdirs = { path.join(concerto_core, "lib") },
-- includedirs = { path.join(concerto_core, "include")},
-- links = { "concerto-core" }
-- }
-- end)
-- add_configs("asserts", {description = "Enable asserts.", default = false, type = "boolean"})
-- add_configs("enet", {description = "Enable ENet support.", default = false, type = "boolean"})
-- on_load(function (package)
-- if package:config("enet") then
-- package:add("deps", "enet")
-- end
-- if package:config("asserts") then
-- package:add("defines", "CCT_ENABLE_ASSERTS")
-- end
-- if package:is_plat("windows") then
-- package:add("syslinks", "user32", "kernel32")
-- end
-- if package:has_tool("cxx", "cl", "clang_cl") then
-- package:add("cxxflags", "/Zc:preprocessor", { public = true })
-- end
-- if not package:config("shared") then
-- package:add("defines", "CCT_CORE_LIB_STATIC")
-- end
-- end)
-- package_end()
add_requires("concerto-core", {configs = {asserts = true, shared = is_kind("static") and false or true }})
add_requires("toml11")
add_requires("libllvm", {configs = {clang = true} })
add_requires("cxxopts")
option("tests", { default = false, description = "Enable unit tests"})
add_defines("CCT_ENABLE_ASSERTS")
if has_config("tests") then
add_requires("catch2")
end
if is_plat("windows") then
set_runtimes(is_mode("debug") and "MDd" or "MD")
end
if is_mode("coverage") then
if not is_plat("windows") then
add_links("gcov")
end
end
includes("Xmake/rules/**.lua")
function add_files_to_target(p)
for _, dir in ipairs(os.filedirs(p)) do
relative_dir = path.relative(dir, "Src/")
if os.isdir(dir) then
add_files(path.join("Src", relative_dir, "*.cpp"))
add_files(path.join("Src", relative_dir, "*.refl.hpp"))
add_headerfiles(path.join("Src", "(" .. relative_dir .. "/*.hpp)"))
add_headerfiles(path.join("Src", "(" .. relative_dir .. "/*.inl)"))
else
local ext = path.extension(relative_dir)
if ext == ".hpp" or ext == ".inl" then
add_headerfiles(path.join("Src", "(" .. relative_dir .. ")"))
elseif ext == ".cpp" then
add_files(path.join("Src", relative_dir))
end
end
end
end
target("concerto-pkg-generator")
set_kind("binary")
set_languages("cxx20")
add_rpathdirs("$ORIGIN")
local files = { ".", "ClangParser", "CppGenerator", "HeaderGenerator", "FileGenerator" }
for _, dir in ipairs(files) do
add_files_to_target("Src/Concerto/PackageGenerator/" .. dir, false)
end
add_includedirs("Src/", { public = true })
add_packages("concerto-core", "toml11", "libllvm", "cxxopts")
set_policy("build.fence", true)
add_defines("CCT_PKG_GENERATOR_BUILD")
if is_mode("debug") then
set_symbols("debug")
end
if is_plat("windows") then
set_runtimes("MT")
end
on_config(function(package)
import("core.project.project")
local llvm = project.required_package("libllvm")
assert(llvm, "libllvm not found!")
local llvm_lib = path.join(llvm:installdir(), "lib")
local concerto_core = project.required_package("concerto-core")
assert(concerto_core, "concerto-core not found!")
local concerto_core_lib = path.join(concerto_core:installdir(), "lib")
package:add("rpathdirs", llvm_lib, concerto_core_lib)
end)
target("concerto-reflection")
set_kind("$(kind)")
set_languages("cxx20")
add_rpathdirs("$ORIGIN")
add_defines("CCT_REFLECTION_BUILD", { public = false })
add_defines("CCT_ENABLE_ASSERTS")
add_includedirs("Src/", { public = true })
if is_kind("static") then
add_defines("CCT_REFLECTION_STATIC", { public = true })
end
local files = {
".",
"Class",
"Enumeration",
"EnumIterator",
"EnumValue",
"GenericClass",
"GlobalNamespace",
"MemberVariable",
"Method",
"Namespace",
"Object",
"Package",
"PackageLoader",
"Registry",
"TemplateClass",
"Signal",
}
for _, dir in ipairs(files) do
add_files_to_target("Src/Concerto/Reflection/" .. dir, true)
end
add_deps("concerto-pkg-generator")
add_packages("concerto-core", { public = true })
add_rules("cct_cpp_reflect")
if is_mode("debug") then
set_symbols("debug")
end
set_policy("build.across_targets_in_parallel", false)
add_cxxflags("cl::/Zc:preprocessor")
if has_config("tests") then
target("concerto-reflection-tests")
set_kind("binary")
set_languages("cxx20")
add_rpathdirs("$ORIGIN")
add_files("Src/Tests/*.cpp", "Src/Tests/*.refl.hpp")
add_packages("catch2")
add_deps("concerto-reflection")
add_rules("cct_cpp_reflect")
add_includedirs(".", { public = true }) -- temporary
add_includedirs("Src/Tests/", { public = true })
add_headerfiles("Src/Tests/**.hpp")
add_defines("CCT_REFLECTION_TESTS_BUILD", { public = false })
add_defines("CCT_ENABLE_ASSERTS")
if is_plat("windows") then
add_cxflags("/Zc:preprocessor")
end
if is_mode("debug") then
set_symbols("debug")
end
add_cxxflags("cl::/Zc:preprocessor")
on_config(function(package)
import("core.project.project")
local llvm = project.required_package("libllvm")
assert(llvm, "libllvm not found!")
local llvm_lib = path.join(llvm:installdir(), "lib")
local concerto_core = project.required_package("concerto-core")
assert(concerto_core, "concerto-core not found!")
local concerto_core_lib = path.join(concerto_core:installdir(), "lib")
package:add("rpathdirs", llvm_lib, concerto_core_lib)
end)
end