-
Notifications
You must be signed in to change notification settings - Fork 60
/
xmake.lua
executable file
·160 lines (140 loc) · 4.63 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
add_rules("mode.debug", "mode.release")
--add_requires("boost","mysql", "openssl", "libgd", "asio", "zlib", "brotli", "libqrencode", "libpng", "freetype")
-- add_defines("release")
if is_mode("release") then
else
add_defines("DEBUG")
end
set_languages("c++20")
set_encodings("utf-8")
if is_plat("windows") then
add_defines("WIN32")
add_defines("WIN32_LEAN_AND_MEAN")
add_syslinks("advapi32")
set_runtimes("MD")
if is_mode("debug") then
add_defines("_DISABLE_VECTOR_ANNOTATION")
add_defines("_DISABLE_STRING_ANNOTATION")
end
end
if is_plat("mingw") then
add_defines("WIN32_LEAN_AND_MEAN")
end
add_requires("openssl","asio","zlib", "brotli")
add_includedirs("common")
add_includedirs("controller")
add_includedirs("vendor/httpcli")
add_includedirs("viewsrc/include")
add_includedirs("websockets/include")
add_includedirs("vendor/httpserver/include")
add_includedirs("vendor/httpserver/include/utility")
add_includedirs("orm")
add_includedirs("orm/include")
add_includedirs("models/cms/include")
add_includedirs("models/include")
add_includedirs("models")
add_includedirs("controller/include")
add_includedirs("controller/include/admin")
add_includedirs("controller/include/superadmin")
add_includedirs("libs")
add_includedirs("libs/department")
add_includedirs("libs/img")
add_includedirs("libs/types")
add_includedirs("libs/ipdata")
add_includedirs("libs/markdown")
add_includedirs("libs/pinyin")
--download https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.35-winx64.zip
--copy include lib to current workspace
add_includedirs("include", "include/mysql")
for _, dir in ipairs(os.dirs("$(buildir)/libs/**")) do
add_includedirs(dir)
end
for _, dir in ipairs(os.dirs("$(buildir)/orm/**")) do
add_includedirs(dir)
end
for _, dir in ipairs(os.dirs("$(buildir)/controller/**")) do
add_includedirs(dir)
end
for _, dir in ipairs(os.dirs("$(buildir)/vendor/**")) do
add_includedirs(dir)
end
for _, dir in ipairs(os.dirs("$(buildir)/orm/include")) do
add_includedirs(dir)
end
for _, dir in ipairs(os.dirs("$(buildir)/models/**")) do
add_includedirs(dir)
end
target("paozhu_pre")
set_kind("binary")
add_files("vendor/httpcli/autopickmethod.cpp")
add_files("vendor/httpserver/src/md5.cpp")
target("paozhu")
if is_mode("debug") then
set_policy("build.sanitizer.address", true)
end
set_kind("binary")
add_deps("paozhu_pre")
-- add_packages("boost")
add_packages("asio")
add_packages("openssl")
add_packages("zlib")
-- add_packages("libgd")
-- add_packages("libqrencode")
-- add_packages("libpng")
-- add_packages("freetype")
add_packages("mysql")
add_packages("brotli")
add_files("models/**.cpp")
add_files("vendor/httpserver/**.cpp")
add_files("common/**.cpp")
add_files("controller/src/**.cpp")
add_files("viewsrc/view/**.cpp")
add_files("libs/**.cpp")
add_files("test/test.cpp")
on_load(function (target)
if is_plat("linux", "macosx") then
target:add("links", "pthread")
elseif is_plat("windows") then
target:add("links", "ws2_32")
if os.isdir("include") then
target:add({includedirs = "./include"})
end
if os.isdir("lib") then
for _, linkdir in ipairs({"./lib"}) do
if os.isdir(linkdir) then
target:add("linkdirs", linkdir)
target:add("links", "mysqlclient")
end
end
end
end
end)
after_build(function (target)
if is_mode("debug") then
cprint("${red}enable asan also need copy dll from VS install dir. \nsuch as from \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\Hostx64\\x64\\clang_rt.asan_dynamic-x86_64.dll\"")
end
end)
target("paozhu_empty")
set_kind("binary")
add_files("vendor/httpcli/autoemptymethod.cpp")
add_deps("paozhu_pre")
target("paozhu_cli")
set_kind("binary")
add_files("vendor/httpcli/http_cli.cpp")
add_packages("mysql")
on_load(function (target)
if is_plat("windows") then
target:add("links", "ws2_32")
if os.isdir("include") then
target:add({includedirs = "./include"})
end
if os.isdir("lib") then
for _, linkdir in ipairs({"./lib"}) do
if os.isdir(linkdir) then
target:add("linkdirs", linkdir)
target:add("links", "mysqlclient")
end
end
end
end
end)