Updated build.sh to copy windows build to a specified destination

This commit is contained in:
Squid committed 2026-10-30 18:46:10 +01:00
1 parent 27b85f3e0d
commit 328557ed2d
1 file changed
+49 -5
+49 -5
View File
@@ -1,6 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
# Content copied into the Windows destination after a successful build.
SRC_DIR="/home/squid/Documents/Moorly/target/x86_64-pc-windows-gnu/"
DEST_DIR="/nextcloud/Stefan/Moorly/Build/"
usage() {
cat <<'EOF'
Usage: ./build.sh <linux|windows|all> <debug|release>
@@ -16,6 +20,10 @@ Examples:
./build.sh windows release
./build.sh all release
On a successful Windows build, the contents of SRC_DIR are copied into
a new timestamped (yyyymmdd_hhmmss) folder inside DEST_DIR. Both are
configured at the top of this script.
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
@@ -58,9 +66,45 @@ build() {
cargo "${args[@]}"
}
if [ "$1" = "all" ]; then
copy_to_destination() {
if [ ! -d "$SRC_DIR" ]; then
echo "Cannot copy: source folder '$SRC_DIR' does not exist."
return 1
fi
if [ ! -d "$DEST_DIR" ]; then
echo "Cannot copy: destination folder '$DEST_DIR' does not exist."
return 1
fi
local build_dir="$DEST_DIR/$(date +%Y%m%d_%H%M%S)"
mkdir -p "$build_dir"
echo "Copying '$SRC_DIR' contents to '$build_dir'..."
cp -a "$SRC_DIR"/. "$build_dir"/
echo "Copy completed."
}
build_windows() {
local profile="$1"
if ! build windows "$profile"; then
echo "Cannot copy: Windows build failed."
exit 1
fi
copy_to_destination
}
case "$1" in
linux)
build linux "$2"
build windows "$2"
else
build "$1" "$2"
fi
;;
windows)
build_windows "$2"
;;
all)
build linux "$2"
build_windows "$2"
;;
esac