-
Notifications
You must be signed in to change notification settings - Fork 8
/
xmake.lua
131 lines (113 loc) · 3.56 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
set_project("Luna")
add_moduledirs("Tools/xmake/modules")
add_rules("mode.debug", "mode.profile", "mode.release")
add_defines("LUNA_MANUAL_CONFIG_DEBUG_LEVEL")
if is_mode("debug") then
add_defines("LUNA_DEBUG_LEVEL=2")
elseif is_mode("profile") then
add_defines("LUNA_DEBUG_LEVEL=1")
else
add_defines("LUNA_DEBUG_LEVEL=0")
end
option("shared")
set_default(true)
set_showmenu(true)
set_description("Build All SDK Modules as Shared Library.")
add_defines("LUNA_BUILD_SHARED_LIB")
option_end()
option("contract_assertion")
set_default(false)
set_showmenu(true)
set_description("Enables contract assertions. This is always enabled in debug build.")
option_end()
option("thread_safe_assertion")
set_default(false)
set_showmenu(true)
set_description("Enables thread safe assertions. This is always enabled in debug build.")
add_defines("LUNA_ENABLE_THREAD_SAFE_ASSERTION")
option_end()
option("build_tests")
set_default(true)
set_showmenu(true)
set_description("Whether to build tests for Luna SDK")
option_end()
option("memory_profiler")
set_default(true)
set_showmenu(true)
set_description("Whether to forcly enable memory profiler for Luna SDK. The memory profiler will still be enabled in Debug and Profile mode.")
add_defines("LUNA_ENABLE_MEMORY_PROFILER")
option_end()
function get_default_rhi_api()
local default_rhi_api = false
if is_os("windows") then
default_rhi_api = "D3D12"
elseif is_os("macosx", "ios") then
default_rhi_api = "Metal"
elseif is_os("linux", "android") then
default_rhi_api = "Vulkan"
end
if default_rhi_api == false then
raise("No Graphics API is present for the current platform!")
end
return default_rhi_api
end
option("rhi_api")
set_default(get_default_rhi_api())
set_showmenu(true)
if is_os("windows") then
set_values("D3D12", "Vulkan")
elseif is_os("macosx", "ios") then
set_values("Metal")
elseif is_os("linux", "android") then
set_values("Vulkan")
end
set_description("The Graphics API to use for Luna SDK")
option_end()
if is_config("rhi_api", "Vulkan") then
add_requires("volk", {configs = {header_only = true}})
add_requires("vulkan-memory-allocator")
elseif is_config("rhi_api", "D3D12") then
add_requires("d3d12-memory-allocator", {configs = {toolchains = "msvc"}}) -- currently d3d12-memory-allocator does not support clang-cl.
end
function add_luna_sdk_options()
add_options("shared", "contract_assertion", "thread_safe_assertion", "memory_profiler")
-- Contract assertion is always enabled in debug mode.
if has_config("contract_assertion") or is_mode("debug") then
add_defines("LUNA_ENABLE_CONTRACT_ASSERTION")
end
end
function luna_sdk_module_target(target_name)
target(target_name)
add_luna_sdk_options()
set_group("Modules")
if has_config("shared") then
set_kind("shared")
else
set_kind("static")
end
set_basename("Luna" .. target_name)
set_exceptions("none")
end
function set_luna_sdk_test()
add_luna_sdk_options()
set_group("Tests")
end
function set_luna_sdk_program()
add_luna_sdk_options()
set_group("Programs")
set_kind("binary")
end
add_includedirs("Modules")
set_languages("c99", "cxx17")
if is_os("windows") then
add_defines("_WINDOWS")
add_defines("UNICODE")
add_defines("_UNICODE")
add_defines("NOMINMAX")
add_defines("_CRT_SECURE_NO_WARNINGS")
end
includes("Modules")
includes("Programs")
if has_config("build_tests") then
includes("Tests")
end