-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
106 lines (91 loc) · 3.63 KB
/
Copy pathxmake.lua
File metadata and controls
106 lines (91 loc) · 3.63 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
set_project("fishnet")
set_version("2.2.4")
set_languages("c++20")
option("bedrock")
set_default(false)
set_showmenu(true)
set_description("Include Minecraft Bedrock extension")
option_end()
if has_config("bedrock") then
add_requires("openssl")
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")
end
end)
rule_end()
target("fishnet")
set_kind("shared")
add_rules("fishnet.platform", "fishnet.shared", "fishnet.link")
add_files("src/**.cpp")
add_includedirs("include", {public = true})
add_headerfiles("include/(**.h)")
if has_config("bedrock") then
add_packages("openssl")
add_files("src-bedrock/**.cpp")
add_includedirs("include-bedrock", {public = true})
add_headerfiles("include-bedrock/(**.h)")
add_defines("FISHNET_BEDROCK", {public = true})
end
set_targetdir("bin/$(mode)/$(plat)")
set_objectdir("build/$(mode)/$(plat)/obj/fishnet")