37 lines
934 B
Bash
Executable File
37 lines
934 B
Bash
Executable File
#!/bin/bash
|
|
# Build media transport targets
|
|
# Usage: ./build.sh [client|server|all] [--release]
|
|
# client build cht-client (default)
|
|
# server build cht-server
|
|
# all build both
|
|
set -euo pipefail
|
|
|
|
MEDIA_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
CARGO="${CARGO:-$HOME/.cargo/bin/cargo}"
|
|
|
|
TARGET="${1:-client}"
|
|
shift || true
|
|
|
|
CARGO_FLAGS=()
|
|
for arg in "$@"; do
|
|
CARGO_FLAGS+=("$arg")
|
|
done
|
|
|
|
LOG_DIR="$MEDIA_DIR/logs"
|
|
mkdir -p "$LOG_DIR"
|
|
|
|
build() {
|
|
local pkg="$1"
|
|
local log="$LOG_DIR/build-$pkg.log"
|
|
echo "==> building $pkg ${CARGO_FLAGS[*]+"${CARGO_FLAGS[@]}"}"
|
|
"$CARGO" build -p "cht-$pkg" "${CARGO_FLAGS[@]}" --manifest-path "$MEDIA_DIR/Cargo.toml" 2>&1 | tee "$log"
|
|
return "${PIPESTATUS[0]}"
|
|
}
|
|
|
|
case "$TARGET" in
|
|
client) build client ;;
|
|
server) build server ;;
|
|
all) build client || true; build server ;;
|
|
*) echo "Usage: $0 [client|server|all] [--release]" >&2; exit 1 ;;
|
|
esac
|