-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
157 lines (134 loc) · 5.42 KB
/
xmake.lua
File metadata and controls
157 lines (134 loc) · 5.42 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
set_project("fishnet")
set_version("2.0.0")
set_languages("c++20")
option("bedrock")
set_default(false)
set_showmenu(true)
set_description("Include Minecraft Bedrock extension (src-bedrock/)")
option_end()
option("examples")
set_default(false)
set_showmenu(true)
set_description("Build example programs")
option_end()
rule("fishnet.platform")
on_load(function (target)
if target:is_plat("windows") then
target:add("cxxflags", "/W4", "/utf-8", {tools = {"cl", "clang_cl"}})
target:add("cxxflags", "/wd4251", {tools = {"cl", "clang_cl"}})
target:add("cxxflags", "/wd4275", {tools = {"cl", "clang_cl"}})
else
target:add("cxxflags", "-Wall", "-Wextra", "-Wpedantic")
target:add("cxxflags", "-Wno-unused-parameter")
end
if is_mode("debug") then
target:add("defines", "FISHNET_DEBUG")
if target:is_plat("windows") then
target:add("cxxflags", "/Zi", "/Od", "/FS", {tools = {"cl", "clang_cl"}})
target:add("ldflags", "/DEBUG", {tools = {"link"}})
else
target:add("cxxflags", "-g", "-O0")
end
elseif is_mode("release") then
if target:is_plat("windows") then
target:add("cxxflags", "/O2", "/DNDEBUG", {tools = {"cl", "clang_cl"}})
target:add("ldflags", "/OPT:REF", "/OPT:ICF", {tools = {"link"}})
else
target:add("cxxflags", "-O2", "-DNDEBUG")
target:add("cxxflags", "-ffunction-sections", "-fdata-sections")
target:add("ldflags", "-Wl,--gc-sections", {tools = {"gcc", "gxx", "clang", "clangxx"}})
end
end
end)
rule_end()
rule("fishnet.shared")
on_load(function (target)
target:add("defines", "FISHNET_EXPORTS")
if not target:is_plat("windows") then
target:add("cxxflags", "-fvisibility=hidden")
target:add("cxxflags", "-fvisibility-inlines-hidden")
end
if target:is_plat("linux") then
local ver = target:version()
if ver and ver.major then
local ok, major = pcall(function() return ver:major() end)
if ok and major then
target:add("ldflags", "-Wl,-soname,lib" .. target:name() .. ".so." .. major,
{tools = {"gcc", "gxx", "clang", "clangxx"}})
end
end
end
if target:is_plat("macosx") then
target:add("ldflags", "-Wl,-install_name,@rpath/lib" .. target:name() .. ".dylib",
{tools = {"gcc", "gxx", "clang", "clangxx"}})
end
if target:is_plat("windows") and is_mode("debug") then
target:add("ldflags", "/PDB:" .. target:name() .. ".pdb", {tools = {"link"}})
end
end)
rule_end()
rule("fishnet.link")
on_load(function (target)
if target:is_plat("windows") then
target:add("syslinks", "ws2_32", "iphlpapi")
elseif target:is_plat("linux") then
target:add("syslinks", "pthread")
elseif target:is_plat("macosx") then
end
end)
rule_end()
rule("fishnet.example")
on_load(function (target)
if target:is_plat("linux") then
target:add("ldflags", "-Wl,-rpath,$ORIGIN", {tools = {"gcc", "gxx", "clang", "clangxx"}})
elseif target:is_plat("macosx") then
target:add("ldflags", "-Wl,-rpath,@executable_path", {tools = {"gcc", "gxx", "clang", "clangxx"}})
end
end)
rule_end()
target("fishnet")
set_kind("shared")
add_rules("fishnet.platform", "fishnet.shared", "fishnet.link")
add_files("src/core/**.cpp")
add_files("src/server/**.cpp")
add_files("src/client/**.cpp")
add_includedirs("src/include", {public = true})
if has_config("bedrock") then
add_files("src-bedrock/core/**.cpp")
add_includedirs("src-bedrock/include", {public = true})
add_defines("FISHNET_BEDROCK", {public = true})
end
set_targetdir("bin/$(mode)/$(plat)")
set_objectdir("build/$(mode)/$(plat)/obj/fishnet")
if has_config("examples") then
target("example_server")
set_kind("binary")
add_rules("fishnet.platform", "fishnet.example")
add_files("examples/server.cpp")
add_deps("fishnet")
set_targetdir("bin/$(mode)/$(plat)")
set_objectdir("build/$(mode)/$(plat)/obj/example_server")
target("example_client")
set_kind("binary")
add_rules("fishnet.platform", "fishnet.example")
add_files("examples/client.cpp")
add_deps("fishnet")
set_targetdir("bin/$(mode)/$(plat)")
set_objectdir("build/$(mode)/$(plat)/obj/example_client")
if has_config("bedrock") then
target("example_bedrock_server")
set_kind("binary")
add_rules("fishnet.platform", "fishnet.example")
add_files("examples/bedrock_server.cpp")
add_deps("fishnet")
set_targetdir("bin/$(mode)/$(plat)")
set_objectdir("build/$(mode)/$(plat)/obj/example_bedrock_server")
target("example_bedrock_client")
set_kind("binary")
add_rules("fishnet.platform", "fishnet.example")
add_files("examples/bedrock_client.cpp")
add_deps("fishnet")
set_targetdir("bin/$(mode)/$(plat)")
set_objectdir("build/$(mode)/$(plat)/obj/example_bedrock_client")
end
end