forked from sniper00/moon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpremake5.lua
More file actions
177 lines (157 loc) · 5.99 KB
/
premake5.lua
File metadata and controls
177 lines (157 loc) · 5.99 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
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
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/**.h", "./third/lua/**.c"}
removefiles("./third/lua/luac.c")
removefiles("./third/lua/lua.c")
filter { "system:windows" }
disablewarnings { "4244","4324","4702","4310", "4701"}
-- defines {"LUA_BUILD_AS_DLL"}
filter { "system:linux" }
defines {"LUA_USE_LINUX"}
-- links{"dl"}
filter { "system:macosx" }
defines {"LUA_USE_MACOSX"}
-- links{"dl"}
-- filter{"configurations:*"}
-- postbuildcommands{"{COPY} %{cfg.buildtarget.abspath} %{wks.location}"}
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","./third/mimalloc/include"}
files {"./moon-src/**.h", "./moon-src/**.hpp","./moon-src/**.cpp" }
links{
"lua",
"aoi",
"crypt",
"pb",
"sharetable",
"clonefunc",
"kcp",
-- "mimalloc",
"mongo",
"navmesh"
}
defines {
"ASIO_STANDALONE" ,
"ASIO_NO_DEPRECATED",
--"MOON_ENABLE_MIMALLOC"
}
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, winddowsaddon, linuxaddon, macaddon )
project(name)
location("build/projects/%{prj.name}")
objdir "build/obj/%{prj.name}/%{cfg.buildcfg}"--编译生成的中间文件目录
targetdir "build/bin/%{cfg.buildcfg}"--目标文件目录
kind "StaticLib" -- 静态库 StaticLib, 动态库 SharedLib
includedirs {"./", "./third","./third/lua"} --头文件搜索目录
files { dir.."/**.h",dir.."/**.hpp", dir.."/**.c",dir.."/**.cpp"} --需要编译的文件, **.c 递归搜索匹配的文件
--targetprefix "" -- linux 下需要去掉动态库 'lib' 前缀
language "C"
defines{"SOL_ALL_SAFETIES_ON"}
if type(normaladdon)=="function" then
normaladdon()
end
filter { "system:windows" }
--links{"lua"} -- windows 版需要链接 lua 库
--defines {"LUA_BUILD_AS_DLL","LUA_LIB"} -- windows下动态库导出宏定义
if type(winddowsaddon)=="function" then
winddowsaddon()
end
filter {"system:linux"}
if type(linuxaddon)=="function" then
linuxaddon()
end
filter {"system:macosx"}
-- links{"lua"}
if type(macaddon)=="function" then
macaddon()
end
--filter{"configurations:*"}
--postbuildcommands{"{COPY} %{cfg.buildtarget.abspath} %{wks.location}/clib"}
end
-----------------------------------------------------------------------------------
--[[
Lua C/C++扩展 在下面添加
]]
add_lua_module("./third/sharetable", "sharetable")
add_lua_module("./third/clonefunc", "clonefunc")--for hotfix
add_lua_module("./third/lcrypt", "crypt")
add_lua_module("./third/pb", "pb")--protobuf
add_lua_module("./third/lmongo", "mongo")--mongo
-------------------------laoi--------------------
add_lua_module("./lualib-src/laoi", "aoi",function()
language "C++"
end)
-------------------------kcp--------------------
add_lua_module("./lualib-src/lkcp", "kcp", function()
language "C++"
files { "./third/kcp/**.h", "./third/kcp/**.c"}
end)
-------------------------navmesh--------------------
add_lua_module("./lualib-src/lnavmesh", "navmesh", function()
language "C++"
includedirs {"./third/recastnavigation/Detour/Include"}
includedirs {"./third/recastnavigation/DetourCrowd/Include"}
includedirs {"./third/recastnavigation/DetourTileCache/Include"}
includedirs {"./third/recastnavigation/Recast/Include"}
files { "./third/recastnavigation/Detour/**.h", "./third/recastnavigation/Detour/**.cpp"}
files { "./third/recastnavigation/DetourCrowd/**.h", "./third/recastnavigation/DetourCrowd/**.cpp"}
files { "./third/recastnavigation/DetourTileCache/**.h", "./third/recastnavigation/DetourTileCache/**.cpp"}
files { "./third/recastnavigation/Recast/**.h", "./third/recastnavigation/Recast/**.cpp"}
files { "./third/fastlz/**.h", "./third/fastlz/**.c"}
end)