init, basic glogg clone
This commit is contained in:
210
BUILD.md
Normal file
210
BUILD.md
Normal file
@@ -0,0 +1,210 @@
|
||||
# Building RLogg
|
||||
|
||||
This document describes how to build RLogg for different platforms.
|
||||
|
||||
## Quick Start
|
||||
|
||||
**On Linux, you can build for all platforms including Windows:**
|
||||
```bash
|
||||
./cross-compile.sh all
|
||||
```
|
||||
|
||||
This uses Docker-based cross-compilation, so no Windows tools needed!
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Rust toolchain (install from https://rustup.rs/)
|
||||
- Platform-specific dependencies (see below)
|
||||
- For cross-compilation: Docker (for the `cross` tool)
|
||||
|
||||
## Platform-Specific Dependencies
|
||||
|
||||
### Linux
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev \
|
||||
libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
|
||||
```
|
||||
|
||||
### macOS
|
||||
No additional dependencies required. Xcode Command Line Tools should be installed.
|
||||
|
||||
### Windows
|
||||
No additional dependencies required. Visual Studio Build Tools or Visual Studio with C++ development tools should be installed.
|
||||
|
||||
## Quick Build
|
||||
|
||||
### Development Build
|
||||
```bash
|
||||
cargo build
|
||||
```
|
||||
|
||||
### Release Build (Optimized)
|
||||
```bash
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
The binary will be in `target/release/rlogg` (or `rlogg.exe` on Windows).
|
||||
|
||||
## Multi-Platform Builds
|
||||
|
||||
### Using Build Scripts
|
||||
|
||||
#### Linux/macOS
|
||||
```bash
|
||||
./build-release.sh
|
||||
```
|
||||
|
||||
#### Windows
|
||||
```powershell
|
||||
.\build-release.ps1
|
||||
```
|
||||
|
||||
The built binaries will be in the `dist/` directory.
|
||||
|
||||
### Manual Cross-Compilation
|
||||
|
||||
#### Install Target
|
||||
```bash
|
||||
# For Linux
|
||||
rustup target add x86_64-unknown-linux-gnu
|
||||
|
||||
# For Windows
|
||||
rustup target add x86_64-pc-windows-msvc
|
||||
|
||||
# For macOS x86_64
|
||||
rustup target add x86_64-apple-darwin
|
||||
|
||||
# For macOS ARM (M1/M2)
|
||||
rustup target add aarch64-apple-darwin
|
||||
```
|
||||
|
||||
#### Build for Specific Target
|
||||
```bash
|
||||
cargo build --release --target <target-triple>
|
||||
```
|
||||
|
||||
Examples:
|
||||
```bash
|
||||
# Linux
|
||||
cargo build --release --target x86_64-unknown-linux-gnu
|
||||
|
||||
# Windows
|
||||
cargo build --release --target x86_64-pc-windows-msvc
|
||||
|
||||
# macOS Intel
|
||||
cargo build --release --target x86_64-apple-darwin
|
||||
|
||||
# macOS Apple Silicon
|
||||
cargo build --release --target aarch64-apple-darwin
|
||||
```
|
||||
|
||||
## GitHub Actions (Automated Builds)
|
||||
|
||||
The project includes GitHub Actions workflow that automatically builds for all platforms:
|
||||
- Linux x86_64
|
||||
- Windows x86_64
|
||||
- macOS x86_64 (Intel)
|
||||
- macOS aarch64 (Apple Silicon)
|
||||
|
||||
### Triggering Builds
|
||||
|
||||
- **Push to master/main**: Builds all platforms and uploads artifacts
|
||||
- **Pull Request**: Runs build checks
|
||||
- **Release**: Builds and attaches binaries to the GitHub release
|
||||
|
||||
### Creating a Release
|
||||
|
||||
1. Tag your commit:
|
||||
```bash
|
||||
git tag -a v0.1.0 -m "Release v0.1.0"
|
||||
git push origin v0.1.0
|
||||
```
|
||||
|
||||
2. Create a release on GitHub from the tag
|
||||
|
||||
3. GitHub Actions will automatically build and attach binaries
|
||||
|
||||
## Optimizing Binary Size
|
||||
|
||||
To reduce the binary size, you can use these settings in `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[profile.release]
|
||||
opt-level = "z" # Optimize for size
|
||||
lto = true # Enable Link Time Optimization
|
||||
codegen-units = 1 # Better optimization
|
||||
strip = true # Strip symbols
|
||||
```
|
||||
|
||||
Or build with:
|
||||
```bash
|
||||
cargo build --release
|
||||
strip target/release/rlogg # On Linux/macOS
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Linux: Missing libraries
|
||||
Make sure all required development libraries are installed:
|
||||
```bash
|
||||
sudo apt-get install -y libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev \
|
||||
libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
|
||||
```
|
||||
|
||||
### macOS: Code signing issues
|
||||
If you encounter code signing errors, you can sign the binary:
|
||||
```bash
|
||||
codesign --force --deep --sign - target/release/rlogg
|
||||
```
|
||||
|
||||
### Windows: MSVC not found
|
||||
Install Visual Studio Build Tools with C++ development tools, or install full Visual Studio.
|
||||
|
||||
### Cross-compilation from Linux to Windows
|
||||
|
||||
#### Method 1: Using the cross-compile script (Recommended)
|
||||
```bash
|
||||
# Interactive mode
|
||||
./cross-compile.sh
|
||||
|
||||
# Or specify target directly
|
||||
./cross-compile.sh windows # Windows (MinGW)
|
||||
./cross-compile.sh all # All platforms
|
||||
```
|
||||
|
||||
**Note**: Only MinGW/GNU target is supported for cross-compilation from Linux. MSVC requires Windows.
|
||||
|
||||
#### Method 2: Manual with 'cross'
|
||||
Install `cross` and build:
|
||||
```bash
|
||||
cargo install cross --git https://github.com/cross-rs/cross
|
||||
cross build --release --target x86_64-pc-windows-msvc
|
||||
```
|
||||
|
||||
The `cross` tool uses Docker to provide a complete cross-compilation environment, so you don't need to install Windows-specific tools.
|
||||
|
||||
## Running Tests
|
||||
|
||||
```bash
|
||||
cargo test
|
||||
```
|
||||
|
||||
## Running in Development Mode
|
||||
|
||||
```bash
|
||||
cargo run
|
||||
```
|
||||
|
||||
## Checking Code
|
||||
|
||||
```bash
|
||||
# Check for errors without building
|
||||
cargo check
|
||||
|
||||
# Run linter
|
||||
cargo clippy
|
||||
|
||||
# Format code
|
||||
cargo fmt
|
||||
```
|
||||
Reference in New Issue
Block a user