add FreeBSD build target

Signed-off-by: Lucca Jiménez Könings <development@jimkoen.com>
This commit is contained in:
Lucca Jiménez Könings 2024-01-19 09:46:27 +01:00 committed by Lion
parent 9915c83363
commit f82572077f
4 changed files with 29 additions and 5 deletions

View File

@ -42,7 +42,7 @@ We only allow building unmodified (original) source code for public use. `master
## Supported Operating Systems
The code itself supports (latest stable) Linux and Windows. In terms of actual build support, for now we usually only distribute Windows binaries and Linux. For any other distro or OS, you just have to find the same libraries listed in [Runtime Dependencies](#runtime-dependencies) further down the page, and it should build fine.
The code itself supports (latest stable) Linux, Windows andcurrently supported production releases of FreeBSD. In terms of actual build support, for now we usually only distribute Windows binaries and Linux. For any other distro or OS, you just have to find the same libraries listed in [Runtime Dependencies](#runtime-dependencies) further down the page, and it should build fine.
Recommended compilers: MSVC, GCC, CLANG.
@ -72,6 +72,14 @@ You can build on **Windows, Linux** or other platforms by following these steps:
When you make changes to the code, you only have to run step 4 again.
It's a similar situation on FreeBSD, although build dependencies can be universally installed from ports via pkg:
```
pkg install git cmake-core zip bash devel/ninja devel/pkgconf lua53
```
Then follow the linux build instructions beginning from step 3. **Note**: Running the initial cmake command will compile vcpkg from source, as vcpkg has no native FreeBSD port - this may take some time.
**Note**: On systems with a single logical CPU core, `make` may fail to build the server when using the `--parallel` option when calling CMake.
### Runtime Dependencies
These are needed to *run* the server.

View File

@ -9,7 +9,14 @@
#include <termios.h>
#include <unistd.h>
char _getch();
#endif // unix
#endif // linux
#ifdef BEAMMP_FREEBSD
#include <errno.h>
#include <termios.h>
#include <unistd.h>
char _getch();
#endif // freebsd
// ======================= APPLE ========================

View File

@ -3,11 +3,13 @@
// one of BEAMMP_{WINDOWS,LINUX,APPLE} will be set at the end of this
// clang-format off
#if !defined(BEAMMP_WINDOWS) && !defined(BEAMMP_UNIX) && !defined(BEAMMP_APPLE)
#if !defined(BEAMMP_WINDOWS) && !defined(BEAMMP_UNIX) && !defined(BEAMMP_APPLE) && !defined(BEAMMP_FREEBSD)
#if defined(_WIN32) || defined(__CYGWIN__)
#define BEAMMP_WINDOWS
#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__unix__) || defined(__unix) || defined(unix)
#elif defined(__linux__) || defined(__linux) || defined(linux)
#define BEAMMP_LINUX
#elif defined(__FreeBSD__)
#define BEAMMP_FREEBSD
#elif defined(__APPLE__) || defined(__MACH__)
#define BEAMMP_APPLE
#else

View File

@ -274,7 +274,9 @@ void RegisterThread(const std::string& str) {
#elif defined(BEAMMP_APPLE)
ThreadId = std::to_string(getpid()); // todo: research if 'getpid()' is a valid, posix compliant alternative to 'gettid()'
#elif defined(BEAMMP_LINUX)
ThreadId = std::to_string(gettid());
ThreadId = std::to_string(gettid()); //todo: 'gettid()' may not produce the inted behavior, as tid's can be the same as pid's when the calling process only has one thread (according to this StackOverflow answer: https://stackoverflow.com/a/8787888). gettid is also a linux specific call (not in posix standard). consider to refactor this in a posix compliant way (maybe 'pthread_self()'?).
#elif defined(BEAMMP_FREEBSD)
ThreadId = std::to_string(getpid());
#endif
if (Application::Settings.DebugModeEnabled) {
std::ofstream ThreadFile(".Threads.log", std::ios::app);
@ -289,6 +291,11 @@ TEST_CASE("RegisterThread") {
CHECK(threadNameMap.at(std::this_thread::get_id()) == "MyThread");
}
#ifdef BEAMMP_FREEBSD
#undef major
#undef minor
#endif
Version::Version(uint8_t major, uint8_t minor, uint8_t patch)
: major(major)
, minor(minor)