-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·48 lines (41 loc) · 1.29 KB
/
build.sh
File metadata and controls
executable file
·48 lines (41 loc) · 1.29 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
#!/bin/bash
set -e
PROJECT_DIR="$(pwd)"
IMAGE="rust:1.93-slim"
# Detect OS
OS="$(uname -s)"
case "${OS}" in
Linux*) OS_NAME="linux";;
Darwin*) OS_NAME="macos";;
*) echo "Unsupported OS: ${OS}"; exit 1;;
esac
# Detect architecture
ARCH="$(uname -m)"
case "${ARCH}" in
x86_64*) RUST_ARCH="x86_64";;
amd64*) RUST_ARCH="x86_64";;
arm64*) RUST_ARCH="aarch64";;
aarch64*) RUST_ARCH="aarch64";;
*) echo "Unsupported architecture: ${ARCH}"; exit 1;;
esac
# Set target triple
if [ "${OS_NAME}" = "linux" ]; then
TARGET="${RUST_ARCH}-unknown-linux-gnu"
elif [ "${OS_NAME}" = "macos" ]; then
TARGET="${RUST_ARCH}-apple-darwin"
fi
echo "Building for ${OS_NAME} on ${ARCH} (${TARGET})"
# Run build in Docker
docker run --rm \
-v "${PROJECT_DIR}":/workspace \
-w /workspace \
${IMAGE} \
bash -c "rustup target add ${TARGET} && \
cargo update && \
rustup component add clippy && \
cargo clippy --all-targets --all-features -- -D warnings && \
cargo build --release --target ${TARGET} --features fast-crypto"
# cargo clean && \
echo "Optimized binary at: target/${TARGET}/release/git-remote-codecommit"
# Set executable permissions
chmod +x "target/${TARGET}/release/git-remote-codecommit"