Building from Source
Requirements
Section titled “Requirements”| Tool | Purpose |
|---|---|
| Git | To clone the repository with submodules |
| CMake 3.28+ | Configure the build |
| Ninja | Build backend |
| GCC or Clang (gcc/g++ or clang/clang++) | Host compiler |
| Zig | Only for cross builds (it ships its own libc) |
| Visual Studio 2022+ (C/C++ tools) | Windows native builds only |
Getting the Source
Section titled “Getting the Source”git clone --recursive https://github.com/yapb/yapbcd yapbThe submodules (ystl with nested mbedtls, linkage) are required. If you already cloned without --recursive, run git submodule update --init --recursive.
Building with build.sh (Recommended)
Section titled “Building with build.sh (Recommended)”build.sh is a helper script that wraps CMake presets:
# native dev build (host compiler, no zig needed)./build.sh
# cross build for a specific target via zig./build.sh --arch=linux-x86
# native build with clang, tuned for this machine, 8 parallel jobs./build.sh -c=clang --native -j=8Available options:
| Option | Description |
|---|---|
--arch=<preset> |
Build preset (default: release). Cross presets need zig on PATH |
-c= / --compiler= |
Host C/C++ compiler for native builds (gcc or clang) |
-j= / --jobs= |
Parallel build jobs (default: ninja auto-detects) |
--native |
Tune for this machine (-march=native) |
--skip-checks |
Skip environment probing |
-D<Var>=<Val> |
Extra CMake defines forwarded to the configure step |
Building with CMake Directly
Section titled “Building with CMake Directly”The presets mirror the CI matrix, so you can drive CMake yourself:
# native development buildcmake --preset releasecmake --build --preset releasePreset groups:
- Local presets (host compiler, no zig needed):
release,dist,linux-amd64-asan,linux-x86-asan - Cross presets (need zig on PATH):
ci-linux-x86,ci-linux-amd64,ci-linux-x86-nosimd,ci-linux-arm64,ci-linux-riscv64,ci-apple-amd64,ci-windows-x86-clang,ci-windows-amd64 - CI-only presets (their runners, not for local use):
ci-apple-arm64,ci-windows-x86,ci-windows-x86-clang-cl,ci-windows-x86-msvc-xp - Test presets (unit tests, native compiler only):
windows-tests,linux-tests
See CMakePresets.json for the full matrix.
Building on Linux
Section titled “Building on Linux”-
Install the requirements:
Terminal window sudo apt updatesudo apt install git cmake ninja-build gcc g++ gcc-multilib g++-multilib -
Get the source (see above)
-
Build:
Terminal window ./build.sh -
You’re done! The compiled library is located at
build/release/yapb.so(each preset builds intobuild/<preset>)
Building on Windows
Section titled “Building on Windows”-
Install Visual Studio with the C/C++ workload
-
Get the source (see above)
-
Either open
vc/yapb.slnin Visual Studio and build, or use the cross presets through Zig from a bash shell (Git Bash/WSL):Terminal window ./build.sh --arch=windows-x86-clang -
You’re done! The compiled library is located at
build/release/yapb.dllfor native builds, orbuild/ci-windows-x86-clang/yapb.dllfor the cross preset
Build Options
Section titled “Build Options”These CMake options can be passed with -D<Var>=<Val> (or through build.sh -D<Var>=<Val>):
| Option | Default | Description |
|---|---|---|
YAPB_64BIT |
OFF |
Build as 64-bit binary |
YAPB_NATIVE |
OFF |
Configure compiler for a native machine build (-march=native) |
YAPB_WINXP |
OFF |
Configure MSVC build for a Windows XP compatible binary |
YAPB_NOSIMD |
OFF |
Disable all SIMD/NEON optimizations |
YAPB_STATIC_LINKENT |
OFF |
Use predefined entity link list |
YAPB_LTO |
ON |
Enable link-time optimization |
YAPB_SANITIZE |
(empty) | Enable sanitizers, e.g. address or address,undefined (dev builds) |
YAPB_WITH_TLS |
ON |
Enable HTTPS support via vendored mbedtls |
YAPB_BUILD_TESTS |
OFF |
Build test host (fake engine harness, native 64-bit only) |
YAPB_WITH_AMXX |
ON |
Build AMX Mod X module (i386 only) |