forked from iqiyi/libfiber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmake.lua
134 lines (118 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
123
124
125
126
127
128
129
130
131
132
133
134
-- add rules
add_rules("mode.debug", "mode.release")
-- for the windows platform (msvc)
if is_plat("windows") then
if is_mode("release") then
add_cxflags("-MT")
elseif is_mode("debug") then
add_cxflags("-MTd")
end
add_ldflags("-nodefaultlib:\"msvcrt.lib\"")
add_links("kernel32", "user32", "gdi32", "winspool", "comdlg32", "advapi32", "ws2_32")
else
add_links("pthread", "dl")
end
-- define target: fiber
target("fiber")
-- set kind: static/shared
set_kind("$(kind)")
-- add deps: acl
-- add_deps("acl")
-- add source files
add_files("src/**.c")
-- add include directories
add_includedirs("src", "include")
-- add headers
add_headers("include/(**.h)")
set_headerdir("$(buildir)/include/fiber")
-- add flags
add_cxflags("-std=gnu99")
-- add defines
add_defines("USE_JMP")
-- samples: client
target("client")
set_kind("binary")
add_deps("fiber")
add_files("samples/patch.c")
add_files("samples/client/*.c")
if is_plat("windows") then
add_files("samples/getopt.c")
end
-- samples: server
target("server")
set_kind("binary")
add_deps("fiber")
add_files("samples/patch.c")
add_files("samples/server/*.c")
if is_plat("windows") then
add_files("samples/getopt.c")
end
-- benchmark: libco_server
target("libco_server")
set_default(false)
set_kind("binary")
add_deps("fiber")
add_files("benchmark/patch.cpp")
add_files("benchmark/libco/*.cpp")
if is_plat("windows") then
add_files("samples/getopt.c")
end
-- benchmark: libgo_server
target("libgo_server")
set_default(false)
set_kind("binary")
add_deps("fiber")
add_files("benchmark/patch.cpp")
add_files("benchmark/libgo/*.cpp")
if is_plat("windows") then
add_files("samples/getopt.c")
end
-- benchmark: libmill_server
target("libmill_server")
set_default(false)
set_kind("binary")
add_deps("fiber")
add_files("benchmark/patch.cpp")
add_files("benchmark/libmill/*.c")
if is_plat("windows") then
add_files("samples/getopt.c")
end
-- benchmark: tbox_server
target("tbox_server")
set_default(false)
set_kind("binary")
add_deps("fiber")
add_files("benchmark/patch.cpp")
add_files("benchmark/tbox/*.c")
if is_mode("debug") then
add_defines("__tb_debug__")
end
if is_plat("windows") then
add_files("samples/getopt.c")
end
on_load(function (target)
target:add(import("lib.detect.find_package")("tbox", {packagedirs = path.join(os.projectdir(), "package")}))
end)
-- Usage
--
-- Only compile libfiber.a
--
-- $ xmake
--
-- Compile and run server and client
--
-- $ xmake r server
-- $ xmake r client
--
-- Compile and run tbox_server (Linux and macOS)
--
-- $ git clone https://github.com/tboox/tbox.git --depth 1
-- $ cd tbox; xmake f --coroutine=y --demo=n -c; xmake install; cd -
-- $ xmake r tbox_server
--
-- Compile and run tbox_server (Windows)
--
-- $ git clone https://github.com/tboox/tbox.git --depth 1
-- $ cd tbox; xmake f --coroutine=y --demo=n -c; xmake p -o ../libfiber/pkg; cd ..
-- $ xmake r tbox_server
--