-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
120 lines (113 loc) · 3.72 KB
/
xmake.lua
File metadata and controls
120 lines (113 loc) · 3.72 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
add_rules("mode.debug", "mode.release")
option("libtype")
set_default("static")
set_values("static", "shared")
set_showmenu(true)
option_end()
if is_plat("windows") and not has_config("vs_runtime") then
set_runtimes("MD")
end
option("ipv6")
set_default(true)
set_showmenu(true)
set_description("Enable IPv6 support")
add_defines("RAKNET_SUPPORT_IPV6")
target("RakNet")
set_kind("$(libtype)")
set_languages("cxx17")
add_includedirs("include/raknet")
add_files("src/**.cpp")
add_options("ipv6")
if is_mode("debug") then
set_symbols("debug")
else
set_optimize("aggressive")
end
if is_plat("windows") then
add_defines(
"NOMINMAX",
"UNICODE",
"_CRT_SECURE_NO_WARNINGS",
"_WINSOCK_DEPRECATED_NO_WARNINGS"
)
add_cxflags(
"/EHsc",
"/utf-8"
)
if is_mode("release") then
add_cxflags(
"/O2",
"/Ob3"
)
end
if is_config("libtype", "shared") then
add_defines("_RAKNET_EXPORT")
add_syslinks("ws2_32")
end
else
add_cxflags(
"-fexceptions",
"-pedantic",
"-Wno-pedantic",
"-Wno-unused-result",
"-Wno-format-truncation"
)
if is_mode("release") then
add_cxflags(
"-O3"
)
end
if is_config("libtype", "shared") then
add_defines("_RAKNET_EXPORT")
add_cxflags(
"-fvisibility=hidden",
"-fvisibility-inlines-hidden"
)
if is_plat("linux") then
add_shflags(
"-static-libstdc++",
"-static-libgcc",
"-Wl,--no-undefined"
)
add_syslinks("pthread")
else
add_shflags("-dynamiclib")
end
end
end
if is_config("libtype", "shared") then
after_build(function (target)
local plat = target:plat()
local arch = target:arch()
local name = target:name()
if arch == "x64" then
arch = "x86_64" -- Fix arch name on Windows
end
local target_file = target:targetfile()
local filename = path.filename(target_file)
local output_dir = path.join(os.projectdir(), "bin/" .. name .. "-" .. plat .. "-" .. arch)
os.mkdir(output_dir)
local artifact_dir = path.join(os.projectdir(), "artifacts")
os.mkdir(artifact_dir)
os.cp(target_file, path.join(output_dir, filename))
if plat == "macosx" then -- Fix rpath on MacOS
os.run("install_name_tool -id @rpath/" .. filename .. " " .. path.join(output_dir, filename))
end
local zip_file = path.join(os.projectdir(), "bin/" .. name .. "-" .. plat .. "-" .. arch .. ".zip")
os.rm(zip_file)
if plat == "windows" then
local win_src = output_dir:gsub("/", "\\")
local win_dest = zip_file:gsub("/", "\\")
local command = string.format(
'powershell -Command "Compress-Archive -Path \'%s\\*\' -DestinationPath \'%s\'"',
win_src,
win_dest
)
os.exec(command)
else
os.exec("zip -rj -q '%s' '%s'", zip_file, output_dir)
end
os.mv(zip_file, artifact_dir)
cprint("${bright green}[Shared Library]: ${reset}".. filename .. " already generated to " .. output_dir)
end)
end