diff --git a/docs/Caveats.md b/docs/Caveats.md index 746e14ecba..522d50007a 100644 --- a/docs/Caveats.md +++ b/docs/Caveats.md @@ -1,5 +1,16 @@ # Caveats + +- [Arch Linux](#arch-linux) +- [Gentoo Linux](#gentoo-linux) +- [macOS](#macos) +- [Solaris](#solaris) +- [HaikuOS](#haikuos) +- [OpenBSD](#openbsd) +- [FreeBSD](#freebsd) +- [NetBSD](#netbsd) + + ## Arch Linux - httplib AUR package is broken. Set `httplib_FORCE_BUNDLED=ON` if you have it installed. @@ -53,6 +64,8 @@ For this reason this patch is NOT applied to default on all platforms (for obvio `cubeb_devel` will also not work, either disable cubeb or uninstall it. +Still will not run flawlessly until `mesa-24` is available. Modify CMakeCache.txt with the `.so` of libGL and libGLESv2 by doing the incredibly difficult task of copy pasting them (`cp /boot/system/lib/libGL.so .`) + ## OpenBSD After configuration, you may need to modify `externals/ffmpeg/CMakeFiles/ffmpeg-build/build.make` to use `-j$(nproc)` instead of just `-j`. diff --git a/docs/Coding.md b/docs/Coding.md new file mode 100644 index 0000000000..ec524cbbf8 --- /dev/null +++ b/docs/Coding.md @@ -0,0 +1,77 @@ +# Coding guidelines + +These are mostly "suggestions", if you feel like your code is readable, comprehensible to others; and most importantly doesn't result in unreadable spaghetti you're fine to go. + +But for new developers you may find that following these guidelines will make everything x10 easier. + +## Naming conventions + +Simply put, types/classes are named as `PascalCase`, same for methods and functions like `AddElement`. Variables are named `like_this_snake_case` and constants are `IN_SCREAMING_CASE`. + +Template typenames prefer short names like `T`, `I`, `U`, if a longer name is required either `Iterator` or `perform_action` are fine as well. + +Macros must always be in `SCREAMING_CASE`. Do not use short letter macros as systems like Solaris will conflict with them; a good rule of thumb is >5 characters per macro - i.e `THIS_MACRO_IS_GOOD`, `AND_ALSO_THIS_ONE`. + +Try not using hungarian notation, if you're able. + +## Formatting + +Do not put if/while/etc braces after lines: +```c++ +// no dont do this +if (thing) +{ + some(); // ... +} + +// do this +if (thing) { + some(); // ... +} + +// or this +if (thing) + some(); // ... + +// this is also ok +if (thing) some(); +``` + +Brace rules are lax, if you can get the point across, do it: + +```c++ +// this is fine +do { + if (thing) { + return 0; + } +} while (other); + +// this is also ok --- albeit a bit more dense +do if (thing) return 0; while (other); + +// ok as well +do { + if (thing) return 0; +} while (other); +``` + +There is no 80-column limit but preferably be mindful of other developer's readability (like don't just put everything onto one line). + +```c++ +// someone is going to be mad due to this +SDL_AudioSpec obtained; +device_name.empty() ? device = SDL_OpenAudioDevice(nullptr, capture, &spec, &obtained, false) : device = SDL_OpenAudioDevice(device_name.c_str(), capture, &spec, &obtained, false); + +// maybe consider this +SDL_AudioSpec obtained; +if (device_name.empty()) { + device = SDL_OpenAudioDevice(nullptr, capture, &spec, &obtained, false); +} else { + device = SDL_OpenAudioDevice(device_name.c_str(), capture, &spec, &obtained, false); +} + +// or this is fine as well +SDL_AudioSpec obtained; +device = SDL_OpenAudioDevice(device_name.empty() ? nullptr : device_name.c_str(), capture, &spec, &obtained, false); +``` diff --git a/docs/Deps.md b/docs/Deps.md index 338d3a5dcb..162b83b5d6 100644 --- a/docs/Deps.md +++ b/docs/Deps.md @@ -86,6 +86,8 @@ On riscv64: These are commands to install all necessary dependencies on various Linux and BSD distributions, as well as macOS. Always review what you're running before you hit Enter! +Notes for writers: Include build tools as well, assume user has NOTHING installed (i.e a fresh install) but that they have updated beforehand so no `upgrade && update` or equivalent should be mentioned - except for rolling release systems like Arch. + Click on the arrows to expand.
@@ -136,6 +138,35 @@ sudo dnf install qt6-qtbase-private-devel * Fedora 36+ users with GCC 12 need Clang and should configure CMake with: `cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -B build`
+
+Alpine Linux + +First, enable the community repository; [see here](https://wiki.alpinelinux.org/wiki/Repositories#Enabling_the_community_repository). +```sh +# Enable the community repository +setup-apkrepos -c +# Install +apk add g++ git cmake make mbedtls-dev mbedtls-static mesa-dev qt6-qtbase-dev qt6-qtbase-private-dev libquazip1-qt6 ffmpeg-dev libusb-dev libtool boost-dev sdl2-dev zstd-dev vulkan-utility-libraries spirv-tools-dev openssl-dev nlohmann-json lz4-dev opus-dev jq patch +``` + +`mbedtls-static` has to be specified otherwise `libeverest.a` and `libp256m.a` will fail to be found. + +
+Void Linux + +```sh +xbps-install -Su git make cmake clang pkg-config patch mbedtls-devel SPIRV-Tools-devel SPIRV-Headers lz4 liblz4-devel boost-devel ffmpeg6-devel catch2 Vulkan-Utility-Libraries Vulkan-Headers glslang openssl-devel SDL2-devel quazip-qt6-devel qt6-base-devel qt6-qt5compat-devel fmt-devel json-c++ libenet-devel libusb-devel +``` + +Yes, `nlohmann-json` is just named `json-c++`. Why? + + +
+NixOS + +A convenience script is provided on the root of this project [shell.nix](../shell.nix). Run the usual `nix-shell`. + +
macOS @@ -173,7 +204,6 @@ For NetBSD +10.1: `pkgin install git cmake boost fmtlib SDL2 catch2 libjwt spirv [Caveats](./Caveats.md#netbsd).
-
OpenBSD @@ -185,7 +215,6 @@ pkg_add cmake nasm git boost unzip--iconv autoconf-2.72p0 bash ffmpeg glslang gm [Caveats](./Caveats.md#openbsd).
-
Solaris / OpenIndiana @@ -201,7 +230,6 @@ Then install the libraries: `sudo pkg install qt6 boost glslang libzip library/l [Caveats](./Caveats.md#solaris).
-
MSYS2 @@ -226,13 +254,13 @@ pacman -Syu --needed --noconfirm $packages * Add MinGW binaries to the PATH if they aren't already: * `echo 'PATH=/mingw64/bin:$PATH' >> ~/.bashrc` * or `echo 'PATH=/mingw64/bin:$PATH' >> ~/.zshrc` -
+
HaikuOS ```sh -pkgman install git cmake libfmt_devel nlohmann_json lz4_devel opus_devel boost1.89_devel vulkan_devel qt6_base_devel libsdl2_devel ffmpeg7_devel libx11_devel enet_devel catch2_devel quazip1_qt6_devel qt6_5compat_devel zydis_devel libusb_devel libz_devel glslang +pkgman install git cmake patch libfmt_devel nlohmann_json lz4_devel opus_devel boost1.89_devel vulkan_devel qt6_base_devel libsdl2_devel ffmpeg7_devel libx11_devel enet_devel catch2_devel quazip1_qt6_devel qt6_5compat_devel zydis_devel libusb1_devel libz_devel glslang mbedtls3 ``` [Caveats](./Caveats.md#haikuos). diff --git a/docs/README.md b/docs/README.md index 9ce0857563..b7b121532a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,6 +5,7 @@ This contains documentation created by developers. This contains build instructi - **[General Build Instructions](Build.md)** - **[Cross Compiling](CrossCompile.md)** - **[Development Guidelines](Development.md)** +- **[Coding guidelines](Coding.md)** - **[Dependencies](Deps.md)** - **[Debug Guidelines](./Debug.md)** - **[CPM - CMake Package Manager](CPMUtil.md)** diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000000..d4a67d8f97 --- /dev/null +++ b/shell.nix @@ -0,0 +1,19 @@ +let + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05"; + pkgs = import nixpkgs { config = {}; overlays = []; }; +in +pkgs.mkShellNoCC { + packages = with pkgs; [ + # essential programs + git cmake clang gnumake patch jq pkg-config + # libraries + openssl boost fmt nlohmann_json lz4 zlib zstd + enet libopus vulkan-headers vulkan-utility-libraries + spirv-tools spirv-headers simpleini vulkan-memory-allocator + vulkan-loader unzip mbedtls zydis glslang python3 httplib + cpp-jwt ffmpeg-headless libusb1 cubeb + qt6.full # eden + SDL2 # eden-cli + discord-rpc gamemode # optional components + ]; +} \ No newline at end of file diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 42c93b0a5f..1e5ba54e7b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1181,13 +1181,14 @@ if (MSVC) else() target_compile_options(core PRIVATE -Werror=conversion - -Wno-sign-conversion -Wno-cast-function-type - $<$:-fsized-deallocation> - $<$:-Wno-cast-function-type-mismatch> ) + # pre-clang19 will spam with "OH DID YOU MEAN THIS?" otherwise... + if (CXX_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19) + target_compile_options(core PRIVATE -Wno-cast-function-type-mismatch) + endif() endif() target_include_directories(core PRIVATE ${OPUS_INCLUDE_DIRS})