Skip to main content

Building Ygégé from Source

This guide explains how to build Ygégé from source on different platforms.

Prerequisites

All Platforms

  • Rust (stable toolchain)
  • Git

Platform-Specific Requirements

Linux (Debian/Ubuntu)

sudo apt-get update
sudo apt-get install -y build-essential cmake perl pkg-config libclang-dev

Windows

Install the following via Chocolatey:

choco install cmake strawberryperl pkgconfiglite llvm nasm -y

Or download manually:

macOS

brew install cmake pkg-config llvm

Building

Standard Build

# Clone the repository
git clone https://github.com/UwUDev/ygege.git
cd ygege

# Build in release mode
cargo build --release

# Binary will be at: target/release/ygege (or ygege.exe on Windows)

With Build Information

To include commit, date, and branch information:

# Linux/macOS
BUILD_COMMIT=$(git rev-parse HEAD) \
BUILD_DATE=$(git log -1 --pretty=%ct) \
BUILD_BRANCH=$(git rev-parse --abbrev-ref HEAD) \
cargo build --release

# Windows (PowerShell)
$env:BUILD_COMMIT = git rev-parse HEAD
$env:BUILD_DATE = git log -1 --pretty=%ct
$env:BUILD_BRANCH = git rev-parse --abbrev-ref HEAD
cargo build --release

Cross-Compilation (Linux only)

For ARM64 (aarch64)

# Install cross-compilation tools
sudo apt-get install -y crossbuild-essential-arm64

# Add Rust target
rustup target add aarch64-unknown-linux-gnu

# Build
export CC=aarch64-linux-gnu-gcc
export CXX=aarch64-linux-gnu-g++
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export CFLAGS_aarch64_unknown_linux_gnu=-D__ARM_ARCH=8
cargo build --release --target=aarch64-unknown-linux-gnu

For ARMv7

# Install cross-compilation tools
sudo apt-get install -y crossbuild-essential-armhf

# Add Rust target
rustup target add armv7-unknown-linux-gnueabihf

# Build
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
cargo build --release --target=armv7-unknown-linux-gnueabihf

For i686 (32-bit)

# Install cross-compilation tools
sudo apt-get install -y crossbuild-essential-i386

# Add Rust target
rustup target add i686-unknown-linux-gnu

# Build
export CC=i686-linux-gnu-gcc
export CXX=i686-linux-gnu-g++
export CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=i686-linux-gnu-gcc
cargo build --release --target=i686-unknown-linux-gnu

Optimizing Binary Size

Using UPX Compression

# Install UPX
# Linux (Debian/Ubuntu)
sudo apt-get install upx-ucl

# macOS
brew install upx

# Windows
choco install upx

# Compress the binary
upx --best --lzma target/release/ygege

Static Linking (Windows)

For standalone Windows executables without runtime dependencies:

$env:RUSTFLAGS = "-C target-feature=+crt-static"
cargo build --release

Docker Build

Local Build

# Build for current platform only (fastest)
docker build -f docker/Dockerfile -t ygege:local .

# Multi-platform build (requires Docker Buildx)
docker buildx build \
--platform linux/amd64,linux/arm64 \
-f docker/Dockerfile \
-t ygege:latest \
--load \
.

With Build Arguments

docker build \
-f docker/Dockerfile \
--build-arg BUILD_COMMIT=$(git rev-parse HEAD) \
--build-arg BUILD_DATE=$(date -u +%s) \
--build-arg BUILD_BRANCH=$(git branch --show-current) \
-t ygege:latest \
.

Running the Binary

After building, you can run Ygégé:

# Show version
./target/release/ygege --version

# Run with default settings (see README.md for configuration)
./target/release/ygege

Troubleshooting

Common Issues

Missing dependencies during build

Make sure all platform-specific prerequisites are installed. The error messages usually indicate which library is missing.

Cross-compilation failures on boring-sys2

The BoringSSL dependency can be tricky to cross-compile. If you encounter issues:

  • Ensure all cross-compilation toolchains are properly installed
  • Verify environment variables are set correctly
  • Consider using Docker for cross-platform builds instead

Windows: link.exe not found

Install Visual Studio Build Tools with the C++ workload.

CI/CD Builds

Official builds are automatically created by GitHub Actions for every release:

  • Linux: x86_64, i686, aarch64, armv7
  • Windows: x86_64, i686
  • macOS: x86_64 (Intel), aarch64 (Apple Silicon)
  • Docker: linux/amd64, linux/arm64

Check the Releases page for pre-built binaries.