-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmake.lua
122 lines (95 loc) · 3.17 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
set_project("onion")
set_version("0.0.0")
add_rules("mode.debug", "mode.release")
option("warnings_as_errors", {description = "Treat warnings as errors.", default = false})
option("enable_lto", {description = "Enable link-time optimization for onion shared library.", default = false})
option("build_tests", {description = "Build onion tests.", default = false})
option("build_examples", {description = "Build onion examples.", default = false})
option("build_benchmarks", {description = "Build onion benchmarks.", default = false})
add_requires("llhttp >=9.2.1")
if is_plat("linux") then
add_requires("liburing >=2.8")
end
if has_config("build_tests") then
add_requires("gtest >=1.15.0")
end
if has_config("build_benchmarks") then
add_requires("abseil")
add_requires("benchmark")
add_requires("unordered_dense")
end
target("onion")
set_kind("$(kind)")
set_default(true)
set_languages("cxx23")
set_warnings("allextra")
add_headerfiles("include/onion/*.hpp")
add_files("src/onion/*.cpp")
add_includedirs("include", {public = true})
if is_mode("debug") then
set_symbols("debug")
else
set_symbols("hidden")
end
-- definitions for shared libraries.
if is_kind("shared") then
add_defines("ONION_BUILD_SHARED_LIBS=1", {public = false})
add_defines("ONION_SHARED_LIBS=1", {public = true})
if has_config("enable_lto") then
set_policy("build.optimization.lto", true)
end
end
-- compile options.
add_cxxflags("/permissive-", {tools = {"cl", "clang_cl"}})
add_cxxflags("-Woverloaded-virtual", {tools = {"gcc", "clang", "appleclang"}})
if has_config("warnings_as_errors") then
add_cxxflags("/WX", {tools = {"cl", "clang_cl"}})
add_cxxflags("-Werror", {tools = {"gcc", "clang", "appleclang"}})
end
-- link external libraries.
add_packages("llhttp")
-- link system libraries.
if is_plat("windows") then
add_syslinks("ws2_32", {public = true})
elseif is_plat("linux") then
add_packages("liburing", {public = true})
end
target_end()
if has_config("build_tests") then
target("onion-test")
set_kind("binary")
set_languages("cxx23")
add_files("tests/**.cpp")
add_deps("onion")
add_packages("gtest")
target_end()
end
if has_config("build_examples") then
target("onion-tcp-echo-server")
set_kind("binary")
set_languages("cxx23")
add_files("examples/tcp_echo_server.cpp")
add_deps("onion")
target_end()
target("onion-udp-echo-server")
set_kind("binary")
set_languages("cxx23")
add_files("examples/udp_echo_server.cpp")
add_deps("onion")
target_end()
target("onion-http-server")
set_kind("binary")
set_languages("cxx23")
add_files("examples/http_server.cpp")
add_deps("onion")
target_end()
end
if has_config("build_benchmarks") then
target("onion-benchmark")
set_kind("binary")
set_languages("cxx23")
add_files("benchmarks/*.cpp")
add_deps("onion")
add_packages("abseil", "benchmark", "unordered_dense")
target_end()
end