-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcollect_binaries.sh
More file actions
59 lines (49 loc) · 1.93 KB
/
Copy pathcollect_binaries.sh
File metadata and controls
59 lines (49 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
set -e
# --- Configuration ---
# 1. Output directory name
OUTPUT_DIR="dist"
# 2. Project Name / Executable Name
# The script attempts to read the package name from Cargo.toml. If unsuccessful,
# it uses the current directory name.
if [ -f Cargo.toml ]; then
EXECUTABLE_NAME=$(grep -E '^\s*name\s*=' Cargo.toml | head -1 | cut -d '=' -f 2 | tr -d ' '\"\' | tr -d '\r')
fi
if [ -z "$EXECUTABLE_NAME" ]; then
EXECUTABLE_NAME=$(basename "$PWD")
echo "⚠️ Warning: Could not extract project name from Cargo.toml. Using directory name: $EXECUTABLE_NAME"
fi
# 3. Target List (Must match the list used in the compilation script)
ALL_TARGETS=(
x86_64-apple-darwin aarch64-apple-darwin
x86_64-pc-windows-msvc aarch64-pc-windows-msvc i686-pc-windows-msvc
x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu
x86_64-unknown-linux-musl armv7-unknown-linux-gnueabihf i686-unknown-linux-gnu
x86_64-unknown-freebsd x86_64-unknown-netbsd
aarch64-linux-android x86_64-linux-android
wasm32-unknown-unknown
)
# --- Initialization ---
echo "--- 📦 Collecting Release Artifacts into $OUTPUT_DIR/ directory ---"
mkdir -p "$OUTPUT_DIR"
echo "Project Name: $EXECUTABLE_NAME"
# --- Loop through targets ---
for TARGET in "${ALL_TARGETS[@]}"; do
SOURCE_DIR="target/$TARGET/release"
# Determine file extension
EXT=""
if [[ "$TARGET" == *windows* ]]; then
EXT=".exe"
elif [[ "$TARGET" == *wasm* ]]; then
EXT=".wasm"
fi
SOURCE_FILE="$SOURCE_DIR/$EXECUTABLE_NAME$EXT"
DEST_FILE="$OUTPUT_DIR/$EXECUTABLE_NAME-$TARGET$EXT"
if [ -f "$SOURCE_FILE" ]; then
cp "$SOURCE_FILE" "$DEST_FILE"
echo "✅ Copied successfully: $TARGET -> $DEST_FILE"
else
echo "⚠️ Warning: File not found at $SOURCE_FILE (Not compiled or failed compilation)."
fi
done
echo -e "\n=== 🎉 All release artifacts collected ($OUTPUT_DIR) ==="