From 27b85f3e0d78315b07dc1718affdb357c8c93b86 Mon Sep 17 00:00:00 2001 From: squid Date: Thu, 29 Oct 2026 22:45:28 +0100 Subject: [PATCH] Added a build bash script to build easier with the same commands --- build.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..6d6901e --- /dev/null +++ b/build.sh @@ -0,0 +1,66 @@ +#!/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