-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
240 lines (199 loc) · 8.32 KB
/
xmake.lua
File metadata and controls
240 lines (199 loc) · 8.32 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
set_xmakever("2.7.3")
set_allowedmodes( "release",
"releasedbg",
"debug",
{default = "debug"})
-- add_requires("glslang", {configs = {binaryonly = true}})
option("unity_build_enabled", { default = true, description =
"Enable Unity build - single module cpp file compilation" })
option("tracy_profiler", { default = true,
description = "Enable profiling with tracy" });
option("address_sanitizer", { default = false,
description = "Enable fast checkng of memory integrity" });
target( "tachyon_engine" )
set_kind( "binary" )
set_languages( "c++20" )
add_deps(
"tachyon_shaders",
"tracy",
"lua_static"
)
set_toolchains( "clang" )
set_policy("build.ccache", true)
local tachyon_lib_source = "external/tachyon_lib/source/"
if has_config( "unity_build_enabled" ) then
add_files(
"source/build_control/unity.cpp",
tachyon_lib_source.."build_control/tachyon_lib_unity_core.cpp"
-- "source/modules/*.mpp"
)
else
add_files(
"source/*.cpp",
"source/modules/*.mpp",
"external/tachyon_lib/source/*.cpp"
)
end
add_includedirs( "source",
"external/spdlog/include/",
"external/tracy/public/tracy/",
"external/tracy/",
"external/lua",
"external/fmt/include",
"external/tachyon_lib/source" )
before_build( function( target )
for _, batch in pairs(target:sourcebatches()) do
print( batch )
end
end)
-- Speed up compilation with pre-compiled headers
set_pcxxheader( "source/include_core.h" )
set_pcxxheader( "source/include_stl.h" )
set_pcxxheader( "external/tachyon_lib/source/include_tachyon_lib_core.h" )
-- asan must be linked first
if has_config( "address_sanitizer" ) then
print( "ENABLED Address sanitizer")
-- add_links( "ubsan" )
add_links( "asan" )
end
-- Linux --
add_links( "dl", "X11", "GL", "uuid", "vulkan" )
add_defines(
'TRIANGULATE_PROJECT_ROOT="$(projectdir)"',
"TYON_LIB_MERGED_UNITY=0"
)
set_policy("check.auto_ignore_flags", false)
if is_mode( "release" ) then
-- set_policy("build.optimization.lto", true)
set_optimize("faster")
elseif is_mode ( "debug" ) then
set_optimize( "none" )
end
-- TODO: Add error list from VMEC project
-- TODO: Make all warnings errors on shipping build to force fixing everything
-- Temporary cxxflags to safe the effort of full converting to xmake --
-- Using lld linker instead of mold for now for error messages
-- Reconsider if the build gets slow
add_cxxflags( "clang::-g",
"-g",
-- "-analyze",
-- "-fuse-ld=lld",
"-fuse-ld=mold",
"-march=native",
"-stdlib=libstdc++",
-- "-std=c++20",
-- TODO: Needs to fixed for future clang versions
-- "-fmodules-ts",
-- Generate a control flow graph
"gcc::-fdump-tree-all-graph",
-- Preprocessor Only Output (have fun finding the source files in xmake)
-- "-E",
-- Enable Tracy Profiler
"-DTRACY_ENABLE=1",
-- Can't Make this flag work
-- "-DTRACY_ON_DEMAND=1",
-- Performance Flags
-- "-msse",
-- Warnings
"clang::-Wpedantic",
"-Wall",
-- Whitelist Errors
-- #import is a Obj-C language extension and easily confused with C++ modules
"clang::-Werror=import-preprocessor-directive-pedantic",
-- Platform unknown pragmas lead to some insanely annoying and
-- unexpected When they fail silentlys
"clang::-Werror=unknown-pragmas",
-- Non-Void functions that don't return can crash *at runtime*
"clang::-Werror=return-type",
"clang::-Werror=inconsistent-missing-override",
-- Shadowing
"clang::-Werror=shadow-all",
-- Has inconsistent behaviour and behaves like reinterpret cast, never use
-- "clang::-Werror=old-style-cast",
-- Always bad, reading uninitialized corrupts data
"-Werror=uninitialized",
-- Missing enumeration cases is indicative of a logic issue or missing code
"-Werror=switch",
-- Missing breaks can cause really nasty bugs, try to annotate all intentional fallthroughs
"-Werror=implicit-fallthrough",
-- Copy asignment in statement often is indicative of a logic error.
"-Werror=parentheses",
-- Disable Warnings
"clang::-Wno-unused-value",
"clang::-Wno-padded",
"clang::-Wno-c++98-compat",
"clang::-Wno-c++98-compat-pedantic ",
"clang::-Wno-documentation-unknown-command ",
"clang::-Wno-unreachable-code-break",
"clang::-Wno-unused-variable",
"clang::-Wno-unused-private-field",
"clang::-Wno-abstract-final-class",
-- Breaks fmtlib
"clang::-Wno-invalid-constexpr",
-- Only runs on extra semicolons that do nothing, pointless.
"-Wno-extra-semi-stmt",
-- "-fsanitize=thread",
-- "-fsanitize=undefined",
-- "-fsanitize=dataflow",
-- "-fsanitize=cfi", -- Control Flow Integrity
-- "-fsanitize=kcfi", -- Kernel Indirect Call Forward-Edge Control Flow Integrity
-- "-fsanitize=safe-stack",
{tools = "clang" }
)
if has_config( "address_sanitizer" ) then
add_cxxflags( "-fsanitize=address" )
-- add_cxxflags( "-fsanitize=memory", "-fPIE", "-pie" )
end
target( "tracy" )
set_kind( "static" )
add_files( "external/tracy/public/TracyClient.cpp" )
add_includedirs( "external/tracy/public/tracy/",
"external/tracy/" )
set_languages( "c++20" )
set_toolchains( "clang" )
add_links( "pthread" )
if has_config( "unity_build_enabled" ) then
add_cxxflags( "-DTRACY_ENABLE=1" )
end
add_cxxflags( "-DTRACY_ENABLE=1",
"-g",
"-pthread" )
target( "tachyon_shaders" )
set_kind( "object" )
add_packages("glslang")
add_rules("utils.glsl2spv", {outputdir = "build/shaders"} )
-- set_targetdir("$(builddir)/shaders")
add_files("source/shaders/*.vert",
"source/shaders/*.frag")
add_installfiles( "build/shaders/*spv", {prefixdir = "share/tachyon_engine/shaders"} )
after_build( function( target )
import("core.project.config")
output_dir = (target:targetdir() or "") .. "/shaders"
build_root = config.get("buildir")
print( "output_dir: %s", output_dir )
print( "build_root: %s", build_root )
-- Copy shaders into build directory so it can find them more easily per-build mode
shader_dir = build_root.."/shaders/"
os.tryrm( output_dir )
error = os.trycp( shader_dir, output_dir )
print("Copy binary shaders to output directory success:", error )
end )
target( "tachyon_tests" )
set_kind( "binary" )
set_languages( "c++20" )
set_default( false )
add_tests( "catch2" )
add_links( "external/catch2/build/src/catch2/libCatch2.a" )
add_files( "tests/*.cpp" )
add_includedirs( "../tracy",
"external/spdlog/include/",
"external/catch2/src/",
"tests/",
"source" )
add_defines( 'TRIANGULATE_PROJECT_ROOT="$(projectdir)"' )
target( "lua_static" )
set_kind( "static" )
add_defines( "MAKE_LIB=1" )
add_files( "external/lua/onelua.c" )
target( "catch2" )
set_kind( "phony" )