forked from sniper00/moon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpremake5.lua
206 lines (176 loc) · 5.84 KB
/
premake5.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
---@diagnostic disable: undefined-global
local MOON_ENABLE_MIMALLOC = true
workspace "Server"
configurations { "Debug", "Release" }
flags{"NoPCH","RelativeLinks"}
cppdialect "C++17"
location "./"
architecture "x64"
staticruntime "on"
filter "configurations:Debug"
defines { "DEBUG" }
symbols "On"
filter "configurations:Release"
defines { "NDEBUG" }
optimize "On"
symbols "On"
filter {"system:windows"}
characterset "MBCS"
systemversion "latest"
warnings "Extra"
filter { "system:linux" }
warnings "High"
filter { "system:macosx" }
warnings "High"
project "lua"
location "build/projects/%{prj.name}"
objdir "build/obj/%{prj.name}/%{cfg.buildcfg}"
targetdir "build/bin/%{cfg.buildcfg}"
kind "StaticLib"
language "C"
includedirs {"./third/lua"}
files {"./third/lua/onelua.c"}
defines {"MAKE_LIB"}
filter { "system:windows" }
disablewarnings { "4244","4324","4702","4310", "4701"}
filter { "system:linux" }
defines {"LUA_USE_LINUX"}
filter { "system:macosx" }
defines {"LUA_USE_MACOSX"}
if MOON_ENABLE_MIMALLOC then
os.execute("git submodule init")
os.execute("git submodule update")
project "mimalloc"
location "build/projects/%{prj.name}"
objdir "build/obj/%{prj.name}/%{cfg.buildcfg}"
targetdir "build/bin/%{cfg.buildcfg}"
kind "StaticLib"
language "C"
includedirs {"./third/mimalloc/include"}
files {"./third/mimalloc/src/static.c"}
end
project "moon"
location "build/projects/%{prj.name}"
objdir "build/obj/%{prj.name}/%{cfg.buildcfg}"
targetdir "build/bin/%{cfg.buildcfg}"
kind "ConsoleApp"
language "C++"
includedirs {"./","./moon-src","./moon-src/core", "./third", "./third/lua"}
files {"./moon-src/**.h", "./moon-src/**.hpp","./moon-src/**.cpp" }
links{
"lua",
"lualib",
"crypt",
"pb",
"sharetable",
"mongo",
}
defines {
"ASIO_STANDALONE" ,
"ASIO_NO_DEPRECATED",
}
if MOON_ENABLE_MIMALLOC then
links{"mimalloc"}
defines {"MOON_ENABLE_MIMALLOC"}
includedirs {"./third/mimalloc/include"}
end
filter { "system:windows" }
defines {"_WIN32_WINNT=0x0601"}
linkoptions { '/STACK:"8388608"' }
filter {"system:linux"}
links{"dl","pthread","stdc++fs"}
linkoptions {"-static-libstdc++ -static-libgcc", "-Wl,-rpath=./","-Wl,--as-needed"}
filter {"system:macosx"}
links{"dl","pthread"}
linkoptions {"-Wl,-rpath,./"}
filter "configurations:Debug"
targetsuffix "-d"
filter{"configurations:*"}
postbuildcommands{"{COPY} %{cfg.buildtarget.abspath} %{wks.location}"}
--[[
lua C/C++模块
@dir: 模块源文件所在路径,相对于当前目录的路径
@name: LUAMOD name
@normaladdon : 平台通用的附加项
@winddowsaddon : windows下的附加项
@linuxaddon : linux下的附加项
@macaddon : macosx下的附加项
使用:
模块编写规范:使用 LUAMOD_API 导出符号(windows)
注意:
默认使用C编译器编译,可以使用 *addon 参数进行更改
]]
local function add_lua_module(dir, name, normaladdon, windowsaddon, linuxaddon, macaddon )
project(name)
location("build/projects/%{prj.name}")
objdir "build/obj/%{prj.name}/%{cfg.buildcfg}"
targetdir "build/bin/%{cfg.buildcfg}"
language "C"
kind "StaticLib"
includedirs {"./", "./third","./third/lua"}
files { dir.."/**.h",dir.."/**.hpp", dir.."/**.c",dir.."/**.cpp"}
defines{"SOL_ALL_SAFETIES_ON"}
if type(normaladdon)=="function" then
normaladdon()
end
filter { "system:windows" }
if type(windowsaddon)=="function" then
windowsaddon()
end
filter {"system:linux"}
if type(linuxaddon)=="function" then
linuxaddon()
end
filter {"system:macosx"}
if type(macaddon)=="function" then
macaddon()
end
end
----------------------Lua C/C++ Modules------------------------
add_lua_module("./third/sharetable", "sharetable")
add_lua_module("./third/lcrypt", "crypt", nil, function ()
disablewarnings { "4244","4267","4456", "4459"}
end)
add_lua_module("./third/pb", "pb")--protobuf
add_lua_module("./third/lmongo", "mongo",nil, function ()
disablewarnings { "4267","4457","4456", "4459", "4996", "4244", "4310"}
end)
add_lua_module("./lualib-src", "lualib", function()
language "C++"
includedirs {"./moon-src", "./moon-src/core"}
defines {
"ASIO_STANDALONE" ,
"ASIO_NO_DEPRECATED",
}
if MOON_ENABLE_MIMALLOC then
includedirs {"./third/mimalloc/include"}
defines {"MOON_ENABLE_MIMALLOC"}
end
---json
defines{ "YYJSON_DISABLE_WRITER" }
files { "./third/yyjson/**.h", "./third/yyjson/**.c"}
---kcp
files { "./third/kcp/**.h", "./third/kcp/**.c"}
---navmesh begin
includedirs {
"./third/recastnavigation/Detour/Include",
"./third/recastnavigation/DetourCrowd/Include",
"./third/recastnavigation/DetourTileCache/Include",
"./third/recastnavigation/Recast/Include"
}
files {
"./third/recastnavigation/Detour/**.h",
"./third/recastnavigation/Detour/**.cpp",
"./third/recastnavigation/DetourCrowd/**.h",
"./third/recastnavigation/DetourCrowd/**.cpp",
"./third/recastnavigation/DetourTileCache/**.h",
"./third/recastnavigation/DetourTileCache/**.cpp",
"./third/recastnavigation/Recast/**.h",
"./third/recastnavigation/Recast/**.cpp",
"./third/fastlz/**.h",
"./third/fastlz/**.c"
}
---navmesh end
end, function ()
defines {"_WIN32_WINNT=0x0601"}
end)