Updated build.sh to copy windows build to a specified destination
This commit is contained in:
1 parent
27b85f3e0d
commit
328557ed2d
1 file changed
+49
-5
@@ -1,6 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
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() {
|
usage() {
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
Usage: ./build.sh <linux|windows|all> <debug|release>
|
Usage: ./build.sh <linux|windows|all> <debug|release>
|
||||||
@@ -16,6 +20,10 @@ Examples:
|
|||||||
./build.sh windows release
|
./build.sh windows release
|
||||||
./build.sh all 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:
|
Windows builds cross-compile to x86_64-pc-windows-gnu and require:
|
||||||
rustup target add x86_64-pc-windows-gnu
|
rustup target add x86_64-pc-windows-gnu
|
||||||
sudo apt install mingw-w64
|
sudo apt install mingw-w64
|
||||||
@@ -58,9 +66,45 @@ build() {
|
|||||||
cargo "${args[@]}"
|
cargo "${args[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" = "all" ]; then
|
copy_to_destination() {
|
||||||
build linux "$2"
|
if [ ! -d "$SRC_DIR" ]; then
|
||||||
build windows "$2"
|
echo "Cannot copy: source folder '$SRC_DIR' does not exist."
|
||||||
else
|
return 1
|
||||||
build "$1" "$2"
|
|
||||||
fi
|
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"
|
||||||
|
;;
|
||||||
|
windows)
|
||||||
|
build_windows "$2"
|
||||||
|
;;
|
||||||
|
all)
|
||||||
|
build linux "$2"
|
||||||
|
build_windows "$2"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Reference in new issue
Block a user