#!/usr/bin/env bash set -euo pipefail usage() { cat <<'EOF' Usage: ./build.sh Arguments: linux|windows|all Target platform ("all" builds linux, then windows) debug|release Build profile Examples: ./build.sh linux debug ./build.sh linux release ./build.sh windows debug ./build.sh windows release ./build.sh all release Windows builds cross-compile to x86_64-pc-windows-gnu and require: rustup target add x86_64-pc-windows-gnu sudo apt install mingw-w64 EOF } if [ "$#" -ne 2 ]; then usage exit 1 fi case "$1" in linux) ;; windows) ;; all) ;; *) usage exit 1 ;; esac case "$2" in debug) ;; release) ;; *) usage exit 1 ;; esac build() { local os="$1" local profile="$2" local args=(build) [ "$profile" = "release" ] && args+=(--release) [ "$os" = "windows" ] && args+=(--target x86_64-pc-windows-gnu) echo "Building $os ($profile): cargo ${args[*]}" cargo "${args[@]}" } if [ "$1" = "all" ]; then build linux "$2" build windows "$2" else build "$1" "$2" fi