-
-
Notifications
You must be signed in to change notification settings - Fork 723
/
xmake.lua
100 lines (86 loc) · 2.73 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
-- project
set_project("tbox")
-- set xmake minimum version
set_xmakever("2.8.2")
-- set project version
set_version("1.7.6", {build = "%Y%m%d", soname = true})
-- set warning all as error
set_warnings("all", "error")
-- set language: c99
stdc = "c99"
set_languages(stdc)
-- add defines to config.h
set_configvar("_GNU_SOURCE", 1)
set_configvar("_REENTRANT", 1)
-- add module directories
add_moduledirs("xmake")
-- disable some compiler errors
add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=expansion-to-defined", "-Wno-error=empty-body")
add_mxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing", "-Wno-error=expansion-to-defined", "-Wno-error=empty-body")
if has_config("coroutine") then
-- https://github.com/tboox/tbox/issues/218
add_cxflags("gcc::-Wno-error=dangling-pointer")
end
-- set wasm toolchain
if is_plat("wasm") then
add_requires("emscripten")
set_toolchains("emcc@emscripten")
end
-- set cosmocc toolchain, e.g. xmake f -p linux --cosmocc=y
if has_config("cosmocc") then
add_requires("cosmocc")
set_toolchains("@cosmocc")
set_policy("build.ccache", false)
end
-- add build modes
add_rules("mode.release", "mode.debug", "mode.profile", "mode.coverage", "mode.valgrind", "mode.asan", "mode.tsan", "mode.ubsan")
if is_mode("debug") then
add_defines("__tb_debug__")
end
if is_mode("valgrind") then
add_defines("__tb_valgrind__")
end
if is_mode("asan") then
add_defines("__tb_sanitize_address__")
end
if is_mode("tsan") then
add_defines("__tb_sanitize_thread__")
end
-- small or micro?
if has_config("small", "micro") then
add_defines("__tb_small__")
set_configvar("TB_CONFIG_SMALL", 1)
if is_mode("release", "profile") and
-- coroutine maybe crash if we enable lto on windows, we disable small mode.
-- TODO we should fix it in context code later
-- https://github.com/tboox/tbox/issues/175
not has_config("coroutine") then
set_optimize("smallest")
end
add_cxflags("-fno-stack-protector")
end
-- for the windows platform (msvc)
if is_plat("windows") then
add_defines("NOCRYPT", "NOGDI")
if is_mode("debug") then
add_cxflags("-Gs", "-RTC1")
set_runtimes("MTd")
else
set_runtimes("MT")
end
add_syslinks("ws2_32", "user32")
elseif is_plat("android") then
add_syslinks("m", "c")
elseif is_plat("mingw", "msys", "cygwin") then
add_syslinks("ws2_32", "user32", "pthread", "m")
elseif is_plat("haiku") then
add_syslinks("pthread", "network", "m", "c")
else
add_syslinks("pthread", "dl", "m", "c")
end
-- enable backtrace symbols for linux
if is_plat("linux") and is_mode("debug") then
add_ldflags("-rdynamic")
end
-- include project sources
includes("src")