-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_rust.sh
More file actions
executable file
·51 lines (39 loc) · 1.35 KB
/
setup_rust.sh
File metadata and controls
executable file
·51 lines (39 loc) · 1.35 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
#!/bin/bash
# setup_rust.sh - Install Rust and configure for cross-compilation
# Used by both Dockerfile (local) and GitHub Actions (CI)
set -e
CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
# Install Rust if not present (minimal profile to save space)
if ! command -v rustup &> /dev/null; then
curl -fsSL https://sh.rustup.rs -o /tmp/rustup.sh
sh /tmp/rustup.sh -y --default-toolchain stable --profile minimal
rm /tmp/rustup.sh
fi
# Ensure cargo is in PATH
export PATH="$CARGO_HOME/bin:$PATH"
# Add targets
rustup target add \
x86_64-unknown-linux-gnu \
aarch64-unknown-linux-gnu \
x86_64-pc-windows-gnu \
x86_64-apple-darwin \
aarch64-apple-darwin
# Install rustfmt
rustup component add rustfmt
# Configure Cargo linkers
mkdir -p "$CARGO_HOME"
cat > "$CARGO_HOME/config.toml" << 'EOF'
[target.x86_64-apple-darwin]
linker = "zcc"
rustflags = ["-C", "link-arg=-target", "-C", "link-arg=x86_64-macos", "-C", "link-arg=-L/opt/macos-sysroot/x86_64/lib"]
[target.aarch64-apple-darwin]
linker = "zcc"
rustflags = ["-C", "link-arg=-target", "-C", "link-arg=aarch64-macos", "-C", "link-arg=-L/opt/macos-sysroot/aarch64/lib"]
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.x86_64-unknown-linux-gnu]
linker = "x86_64-linux-gnu-gcc"
EOF
echo "Rust setup complete!"