# Cross.toml - Cross-compilation configuration
# See: https://github.com/cross-rs/cross

[build]
# Use docker by default
default-target = "x86_64-unknown-linux-gnu"

[build.env]
passthrough = [
    "RUST_BACKTRACE",
    "RUST_LOG",
    "CARGO_TERM_COLOR",
]

# x86_64 MUSL static builds
[target.x86_64-unknown-linux-musl]
# Use the rust-musl-cross image which has proper musl toolchain
image = "ghcr.io/rust-cross/rust-musl-cross:x86_64-musl"
# Pre-build hook to install any additional dependencies
pre-build = []

[target.x86_64-unknown-linux-musl.env]
passthrough = [
    "OPENSSL_STATIC=1",
    "PKG_CONFIG_ALLOW_CROSS=1",
]

# ARM64 Linux builds
[target.aarch64-unknown-linux-gnu]
# Use cross's default image with proper ARM toolchain
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main"
pre-build = [
    "dpkg --add-architecture arm64 && apt-get update && apt-get install -y libdbus-1-dev:arm64 pkg-config",
]

[target.aarch64-unknown-linux-gnu.env]
passthrough = [
    "PKG_CONFIG_ALLOW_CROSS=1",
    # Give the emulated test binary a writable cache dir. Without this the
    # container has no writable TMPDIR/HOME, so default_cache_dir() falls back
    # to a read-only path and BootstrapCache::open() fails with EACCES,
    # panicking every endpoint-constructing test (see bootstrap_cache::config).
    "TMPDIR=/tmp",
]

# ARM64 MUSL static builds
[target.aarch64-unknown-linux-musl]
image = "ghcr.io/rust-cross/rust-musl-cross:aarch64-musl"
pre-build = []

[target.aarch64-unknown-linux-musl.env]
passthrough = [
    "OPENSSL_STATIC=1",
    "PKG_CONFIG_ALLOW_CROSS=1",
]

# ARMv7 Linux builds (Raspberry Pi, etc.)
[target.armv7-unknown-linux-gnueabihf]
image = "ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:main"
pre-build = []

[target.armv7-unknown-linux-gnueabihf.env]
passthrough = [
    "PKG_CONFIG_ALLOW_CROSS=1",
]

# ARMv7 MUSL static builds
[target.armv7-unknown-linux-musleabihf]
image = "ghcr.io/rust-cross/rust-musl-cross:armv7-musleabihf"
pre-build = []

[target.armv7-unknown-linux-musleabihf.env]
passthrough = [
    "OPENSSL_STATIC=1",
    "PKG_CONFIG_ALLOW_CROSS=1",
]
