Added a build bash script to build easier with the same commands
This commit is contained in:
1 parent
c778bb1b48
commit
27b85f3e0d
1 file changed
+66
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: ./build.sh <linux|windows|all> <debug|release>
|
||||
|
||||
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
|
||||
Reference in new issue
Block a user