From b64a6b65ddcbf1ed3bbd28c65bcf118d70fb9723 Mon Sep 17 00:00:00 2001 From: euzu Date: Sun, 14 Dec 2025 12:05:51 +0100 Subject: [PATCH] updated build scripts --- bin/build_aarch64.sh | 5 -- bin/build_armv7.sh | 5 -- bin/build_darwin.sh | 4 - bin/build_docker.sh | 38 +++++++++ bin/build_lin.sh | 8 -- bin/build_lin_static.sh | 5 -- bin/build_local.sh | 167 ++++++++++++++++++++++++++++++++++++++++ bin/build_win.sh | 6 -- 8 files changed, 205 insertions(+), 33 deletions(-) delete mode 100755 bin/build_aarch64.sh delete mode 100755 bin/build_armv7.sh delete mode 100755 bin/build_darwin.sh delete mode 100755 bin/build_lin.sh delete mode 100755 bin/build_lin_static.sh create mode 100644 bin/build_local.sh delete mode 100755 bin/build_win.sh diff --git a/bin/build_aarch64.sh b/bin/build_aarch64.sh deleted file mode 100755 index 7fc58de88..000000000 --- a/bin/build_aarch64.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -echo "building binary for aarch64" -env RUSTFLAGS="--remap-path-prefix $HOME=~" cross build -p tuliprox --release --target aarch64-unknown-linux-musl -cd ./frontend || exit 1 -env RUSTFLAGS="--remap-path-prefix $HOME=~" trunk build --release diff --git a/bin/build_armv7.sh b/bin/build_armv7.sh deleted file mode 100755 index 76d6a18d4..000000000 --- a/bin/build_armv7.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -echo "building binary for armv7" -env RUSTFLAGS="--remap-path-prefix $HOME=~" cross build -p tuliprox --release --target armv7-unknown-linux-musleabihf -cd ./frontend || exit 1 -env RUSTFLAGS="--remap-path-prefix $HOME=~" trunk build --release \ No newline at end of file diff --git a/bin/build_darwin.sh b/bin/build_darwin.sh deleted file mode 100755 index 0fc62e75b..000000000 --- a/bin/build_darwin.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -env RUSTFLAGS="--remap-path-prefix $HOME=~" cross build -p tuliprox --release --target x86_64-apple-darwin -cd ./frontend || exit 1 -env RUSTFLAGS="--remap-path-prefix $HOME=~" trunk build --release \ No newline at end of file diff --git a/bin/build_docker.sh b/bin/build_docker.sh index e35eb0915..fa8151c46 100755 --- a/bin/build_docker.sh +++ b/bin/build_docker.sh @@ -8,7 +8,45 @@ if [ ! -f "${HOME}/.ghcr.io" ]; then fi source "${HOME}/.ghcr.io" +# ----------------------------- +# Rust / Cargo Setup +# ----------------------------- +export RUSTUP_NO_UPDATE_CHECK=1 +export CARGO_NET_GIT_FETCH_WITH_CLI=true +export RUSTFLAGS="--remap-path-prefix $HOME=~" + +REQUIRED_TARGETS=( + "x86_64-unknown-linux-musl" + "aarch64-unknown-linux-musl" +) + +echo "🦀 Checking Rust toolchain..." + +if ! rustup toolchain list | grep -q "^stable"; then + echo "🔧 Installing stable toolchain..." + rustup toolchain install stable --profile minimal +fi + +rustup default stable + +echo "🎯 Ensuring required targets are installed..." +for TARGET in "${REQUIRED_TARGETS[@]}"; do + if ! rustup target list --installed | grep -q "^${TARGET}$"; then + echo "➕ Installing target $TARGET" + rustup target add "$TARGET" + fi +done + +WASM_TARGET="wasm32-unknown-unknown" + +if ! rustup target list --installed | grep -q "^${WASM_TARGET}$"; then + echo "➕ Installing wasm target for frontend: ${WASM_TARGET}" + rustup target add "${WASM_TARGET}" +fi + +# ----------------------------------------- # Function to print usage instructions +# ----------------------------------------- print_usage() { echo "Usage: $(basename "$0") " echo diff --git a/bin/build_lin.sh b/bin/build_lin.sh deleted file mode 100755 index c32b029c7..000000000 --- a/bin/build_lin.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -export RUSTFLAGS="--remap-path-prefix $HOME=~" -if [ "$(uname)" != "Linux" ]; then - cross build -p tuliprox --release --target --target x86_64-unknown-linux-gnu -else - cargo build -p tuliprox --release -fi -cd "./frontend" && trunk build --release \ No newline at end of file diff --git a/bin/build_lin_static.sh b/bin/build_lin_static.sh deleted file mode 100755 index fca88dcca..000000000 --- a/bin/build_lin_static.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -DEFAULT_TARGET="x86_64-unknown-linux-musl" -TARGET="${1:-$DEFAULT_TARGET}" -env RUSTFLAGS="--remap-path-prefix $HOME=~" cross build -p tuliprox --release --target "$TARGET" -cd "./frontend" && env RUSTFLAGS="--remap-path-prefix $HOME=~" trunk build --release \ No newline at end of file diff --git a/bin/build_local.sh b/bin/build_local.sh new file mode 100644 index 000000000..4f12c1dfd --- /dev/null +++ b/bin/build_local.sh @@ -0,0 +1,167 @@ +#!/usr/bin/env bash +set -e + +############################### +# +# Standard +# ./build.sh linux-musl +# +# # ARM without Frontend +# ./build.sh armv7 --no-frontend +# +# # Only Frontend +# ./build.sh linux-musl --frontend-only +# +# # Only Backend + clean +# ./build.sh windows --backend-only --clean +# +# # Help +# ./build.sh --help +# +##################################################### + +######################################## +# Globals +######################################## +SCRIPT_NAME="$(basename "$0")" +export RUSTFLAGS="--remap-path-prefix $HOME=~" + +BUILD_BACKEND=true +BUILD_FRONTEND=true +DO_CLEAN=false +TARGET="" + +######################################## +# Usage +######################################## +usage() { + cat < [options] + +Targets: + linux-musl x86_64-unknown-linux-musl (cross) + linux-gnu x86_64-unknown-linux-gnu (cargo on Linux, cross otherwise) + armv7 armv7-unknown-linux-musleabihf (cross) + aarch64 aarch64-unknown-linux-musl (cross) + macos x86_64-apple-darwin (cross) + windows x86_64-pc-windows-gnu (cargo) + +Options: + --no-frontend Skip frontend build + --frontend-only Build only frontend + --backend-only Build only backend + --clean cargo clean before build + -h, --help Show this help + +Examples: + $SCRIPT_NAME linux-musl + $SCRIPT_NAME armv7 --no-frontend + $SCRIPT_NAME aarch64 --no-frontend + $SCRIPT_NAME windows --backend-only + $SCRIPT_NAME linux-gnu --clean +EOF +} + +######################################## +# Argument parsing +######################################## +if [ $# -eq 0 ]; then + echo "❌ No target specified" + usage + exit 1 +fi + +for arg in "$@"; do + case "$arg" in + linux-musl|linux-gnu|armv7|aarch64|macos|windows) + TARGET="$arg" + ;; + --no-frontend) + BUILD_FRONTEND=false + ;; + --frontend-only) + BUILD_BACKEND=false + BUILD_FRONTEND=true + ;; + --backend-only) + BUILD_BACKEND=true + BUILD_FRONTEND=false + ;; + --clean) + DO_CLEAN=true + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "❌ Unknown option: $arg" + usage + exit 1 + ;; + esac +done + +if [ -z "$TARGET" ]; then + echo "❌ No valid target specified" + usage + exit 1 +fi + +######################################## +# Clean +######################################## +if [ "$DO_CLEAN" = true ]; then + echo "==> Cleaning workspace" + cargo clean +fi + +######################################## +# Backend build +######################################## +if [ "$BUILD_BACKEND" = true ]; then + echo "==> Building backend ($TARGET)" + + case "$TARGET" in + linux-musl) + cross build -p tuliprox --release --target x86_64-unknown-linux-musl + ;; + linux-gnu) + if [ "$(uname)" = "Linux" ]; then + cargo build -p tuliprox --release + else + cross build -p tuliprox --release --target x86_64-unknown-linux-gnu + fi + ;; + armv7) + cross build -p tuliprox --release --target armv7-unknown-linux-musleabihf + ;; + aarch64) + cross build -p tuliprox --release --target aarch64-unknown-linux-musl + ;; + macos) + cross build -p tuliprox --release --target x86_64-apple-darwin + ;; + windows) + cargo build -p tuliprox --release --target x86_64-pc-windows-gnu + ;; + esac +fi + +######################################## +# Frontend build +######################################## +if [ "$BUILD_FRONTEND" = true ]; then + echo "==> Building frontend (trunk)" + cd frontend || { + echo "❌ frontend directory not found" + exit 1 + } + trunk build --release +fi + +######################################## +# Done +######################################## +echo "✅ Build finished successfully" diff --git a/bin/build_win.sh b/bin/build_win.sh deleted file mode 100755 index bff62549e..000000000 --- a/bin/build_win.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -env RUSTFLAGS="--remap-path-prefix $HOME=~" cargo build -p tuliprox --release --target x86_64-pc-windows-gnu -# cross build, is only working with cargo clean -# env RUSTFLAGS="--remap-path-prefix $HOME=~" cross build -p tuliprox --release --target x86_64-pc-windows-gnu - -cd "./frontend" && env RUSTFLAGS="--remap-path-prefix $HOME=~" trunk build --release