-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpremake5.lua
More file actions
268 lines (242 loc) · 7.98 KB
/
premake5.lua
File metadata and controls
268 lines (242 loc) · 7.98 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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
debug_libs = { "System" }
release_libs = debug_libs
solution "netcode"
kind "ConsoleApp"
dotnetframework "4.6.1"
language "C#"
platforms { "x64" }
nuget { "Portable.BouncyCastle:1.8.4" }
configurations { "Debug", "Release" }
flags { }
configuration "Debug"
symbols "On"
defines { "DEBUG" }
links { debug_libs }
configuration "Release"
symbols "Off"
optimize "Speed"
links { release_libs }
project "test"
files { "test.cs", "netcode.cs", "netcode_test.cs" }
project "soak"
files { "soak.cs", "netcode.cs" }
project "profile"
files { "profile.cs", "netcode.cs" }
project "client"
files { "client.cs", "netcode.cs" }
project "server"
files { "server.cs", "netcode.cs" }
project "client_server"
files { "client_server.cs", "netcode.cs" }
if os.ishost "windows" then
-- Windows
newaction
{
trigger = "solution",
description = "Create and open the netcode.io solution",
execute = function ()
os.execute "premake5 vs2015"
os.execute "start netcode.sln"
end
}
newaction
{
trigger = "docker",
description = "Build and run a netcode.io.net server inside a docker container",
execute = function ()
os.execute "docker run --rm --privileged alpine hwclock -s" -- workaround for clock getting out of sync on macos. see https://docs.docker.com/docker-for-mac/troubleshoot/#issues
os.execute "rmdir /s/q docker\\netcode.io.net & mkdir docker\\netcode.io.net \z
&& copy *.cs docker\\netcode.io.net\\ \z
&& copy premake5.lua docker\\netcode.io.net\\ \z
&& cd docker \z
&& docker build -t \"netcodeio:netcode.io.net-server\" . \z
&& rmdir /s/q netcode.io.net \z
&& docker run -ti -p 40000:40000/udp netcodeio:netcode.io.net-server"
end
}
-- todo: create shortcuts here too for windows for consistency
else
-- MacOSX and Linux.
newaction
{
trigger = "solution",
description = "Create and open the netcode.io solution",
execute = function ()
os.execute [[
dotnet new console --force -o _test -n test && rm _test/Program.cs
dotnet add _test package Portable.BouncyCastle
cp test.cs netcode.cs netcode_test.cs _test]]
os.execute [[
dotnet new console --force -o _soak -n soak && rm _soak/Program.cs
dotnet add _soak package Portable.BouncyCastle
cp soak.cs netcode.cs _soak]]
os.execute [[
dotnet new console --force -o _profile -n profile && rm _profile/Program.cs
dotnet add _profile package Portable.BouncyCastle
cp profile.cs netcode.cs _profile]]
os.execute [[
dotnet new console --force -o _client -n client && rm _client/Program.cs
dotnet add _client package Portable.BouncyCastle
cp client.cs netcode.cs _client]]
os.execute [[
dotnet new console --force -o _server -n server && rm _server/Program.cs
dotnet add _server package Portable.BouncyCastle
cp server.cs netcode.cs _server]]
os.execute [[
dotnet new console --force -o _client_server -n client_server && rm _client_server/Program.cs
dotnet add _client_server package Portable.BouncyCastle
cp client_server.cs netcode.cs _client_server]]
os.execute [[
dotnet new sln --force -n netcode
dotnet sln add _*/*.csproj]]
end
}
newaction
{
trigger = "test",
description = "Build and run all unit tests",
execute = function ()
os.execute "test ! -d _test && premake5 solution"
os.execute "dotnet build -o ../bin _test/test.csproj && dotnet ./bin/test.dll"
end
}
newaction
{
trigger = "soak",
description = "Build and run soak test",
execute = function ()
os.execute "test ! -d _soak && premake5 solution"
os.execute "dotnet build -o ../bin _soak/soak.csproj && dotnet ./bin/soak.dll"
end
}
newaction
{
trigger = "profile",
description = "Build and run profile tet",
execute = function ()
os.execute "test ! -d _profile && premake5 solution"
os.execute "dotnet build -o ../bin _profile/profile.csproj && dotnet ./bin/profile.dll"
end
}
newaction
{
trigger = "client",
description = "Build and run the client",
execute = function ()
os.execute "test ! -d _client && premake5 solution"
os.execute "dotnet build -o ../bin _client/client.csproj && dotnet ./bin/client.dll"
end
}
newaction
{
trigger = "server",
description = "Build and run the server",
execute = function ()
os.execute "test ! -d _server && premake5 solution"
os.execute "dotnet build -o ../bin _server/server.csproj && dotnet ./bin/server.dll"
end
}
newaction
{
trigger = "client_server",
description = "Build and run the client/server testbed",
execute = function ()
os.execute "test ! -d _client_server && premake5 solution"
os.execute "dotnet build -o ../bin _client_server/client_server.csproj && dotnet ./bin/client_server.dll"
end
}
newaction
{
trigger = "docker",
description = "Build and run a netcode.io.net server inside a docker container",
execute = function ()
os.execute "docker run --rm --privileged alpine hwclock -s" -- workaround for clock getting out of sync on macos. see https://docs.docker.com/docker-for-mac/troubleshoot/#issues
os.execute "rm -rf docker/netcode.io.net && mkdir -p docker/netcode.io.net \z
&& cp *.cs docker/netcode.io.net \z
&& cp premake5.lua docker/netcode.io.net \z
&& cd docker \z
&& docker build -t \"netcodeio:netcode.io.net-server\" . \z
&& rm -rf netcode.io.net \z
&& docker run -ti -p 40000:40000/udp netcodeio:netcode.io.net-server"
end
}
newaction
{
trigger = "stress",
description = "Launch 256 client instances to stress test the server",
execute = function ()
os.execute "test ! -d _client && premake5 solution"
if os.execute "dotnet build -o ../bin _client/client.csproj" == true then
for i = 0, 255 do
os.execute "dotnet ./bin/client.dll &"
end
end
end
}
newaction
{
trigger = "loc",
description = "Count lines of code",
execute = function ()
os.execute "wc -l *.cs"
end
}
end
newaction
{
trigger = "clean",
description = "Clean all build files and output",
execute = function ()
files_to_delete =
{
"Makefile",
"app.config",
"packages.config",
"*.make",
"*.txt",
"*.zip",
"*.tar.gz",
"*.db",
"*.opendb",
"*.csproj",
"*.csproj.user",
"*.sln",
"*.xcodeproj",
"*.xcworkspace"
}
directories_to_delete =
{
"_client",
"_client_server",
"_profile",
"_server",
"_soak",
"_test",
"obj",
"ipch",
"bin",
".vs",
"Debug",
"Release",
"release",
"packages",
"cov-int",
"docs",
"xml",
"docker/netcode.io.net"
}
for i,v in ipairs( directories_to_delete ) do
os.rmdir( v )
end
if not os.ishost "windows" then
os.execute "find . -name .DS_Store -delete"
for i,v in ipairs( files_to_delete ) do
os.execute( "rm -f " .. v )
end
else
for i,v in ipairs( files_to_delete ) do
os.execute( "del /F /Q " .. v )
end
end
end
}