From 1a3c709c1e408ea82930c976d2861b36897d0f67 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 7 Nov 2022 01:14:06 +0000 Subject: [PATCH] Add linux server build --- .gitignore | 3 ++- build_linux_server_release.sh | 3 +++ debugdraw.c | 7 ++++++- flight.service | 9 +++++++++ linux_server_install.sh | 6 ++++++ server_main.c | 10 ++++++++++ 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 build_linux_server_release.sh create mode 100644 flight.service create mode 100755 linux_server_install.sh create mode 100644 server_main.c diff --git a/.gitignore b/.gitignore index 3c0bed3..6b57312 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +flight_server flight.zip ipsettings.h @@ -7,4 +8,4 @@ x64/ *.obj *.pdb *.ilk -*.gen.h \ No newline at end of file +*.gen.h diff --git a/build_linux_server_release.sh b/build_linux_server_release.sh new file mode 100755 index 0000000..a575059 --- /dev/null +++ b/build_linux_server_release.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +gcc -o flight_server -O2 -Wall -Ithirdparty -Ithirdparty/enet/include -Ithirdparty/minilzo -Ithirdparty/Chipmunk2D/include -Ithirdparty/Chipmunk2D/include/chipmunk server_main.c server.c debugdraw.c gamestate.c sokol_impl.c thirdparty/minilzo/minilzo.c thirdparty/enet/*.c thirdparty/Chipmunk2D/src/*.c -lm -lpthread diff --git a/debugdraw.c b/debugdraw.c index c7cc30b..f85bf4f 100644 --- a/debugdraw.c +++ b/debugdraw.c @@ -1,5 +1,7 @@ +#ifdef DEBUG_RENDERING #include "sokol_gfx.h" #include "sokol_gp.h" +#endif #include "types.h" #define MAX_COMMANDS 64 @@ -40,6 +42,8 @@ static THREADLOCAL int command_i = 0; void dbg_drawall() { // return; + +#ifdef DEBUG_RENDERING sgp_set_color(0.4f, 0.8f, 0.2f, 0.8f); for (int i = 0; i < command_i; i++) { @@ -62,6 +66,7 @@ void dbg_drawall() } } } +#endif command_i = 0; } @@ -84,4 +89,4 @@ void dbg_rect(V2 center) }; command_i++; command_i %= MAX_COMMANDS; -} \ No newline at end of file +} diff --git a/flight.service b/flight.service new file mode 100644 index 0000000..50f2a85 --- /dev/null +++ b/flight.service @@ -0,0 +1,9 @@ +[Unit] +Description=Flight + +[Service] +ExecStart=/root/flight/flight_server +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/linux_server_install.sh b/linux_server_install.sh new file mode 100755 index 0000000..0c6e7c8 --- /dev/null +++ b/linux_server_install.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +./build_linux_server_release.sh +cp flight.service /etc/systemd/system/ +systemctl enable flight +systemctl start flight diff --git a/server_main.c b/server_main.c new file mode 100644 index 0000000..689b8ce --- /dev/null +++ b/server_main.c @@ -0,0 +1,10 @@ +#include "types.h" + +#define SOKOL_IMPL +#include "sokol_time.h" + +int main(int argc, char **argv) +{ + server(0); + return 0; +}