updated build scripts

This commit is contained in:
euzu
2025-12-14 12:05:51 +01:00
parent 7c5f0b62b3
commit b64a6b65dd
8 changed files with 205 additions and 33 deletions
-5
View File
@@ -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
-5
View File
@@ -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
-4
View File
@@ -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
+38
View File
@@ -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") <branch>"
echo
-8
View File
@@ -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
-5
View File
@@ -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
+167
View File
@@ -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 <<EOF
Usage:
$SCRIPT_NAME <target> [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"
-6
View File
@@ -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