|
2 | 2 |
|
3 | 3 | set -euo pipefail
|
4 | 4 |
|
5 |
| -CROSS_VERSION="v0.2.5" |
6 |
| - |
7 |
| -if [ $# != 1 ]; then |
8 |
| - >&2 echo "Error: $0 <TARGET>" |
| 5 | +if [ "$#" -ne 1 ]; then |
| 6 | + echo >&2 "Error: $0 <TARGET>" |
9 | 7 | exit 1
|
10 | 8 | fi
|
11 | 9 | TARGET="$1"
|
12 | 10 |
|
13 |
| -kernel_name=$(uname -s) |
14 |
| -case "$kernel_name" in |
15 |
| -Darwin*) |
16 |
| - # on mac (for apple-darwin targets), rely on host compiler's targets |
17 |
| - rustup target add "$TARGET" |
18 |
| - compiler_command="cargo" |
| 11 | +CARGO_CONFIG=~/.cargo/config.toml |
| 12 | + |
| 13 | +case "$TARGET" in |
| 14 | +x86_64-unknown-linux-gnu | x86_64-apple-darwin | aarch64-apple-darwin) |
| 15 | + echo "Target requires no extra actions: $TARGET" |
19 | 16 | ;;
|
20 |
| -Linux*) |
21 |
| - # on linux, rely on cross compiler |
22 |
| - download_url="https://github.com/cross-rs/cross/releases/download/${CROSS_VERSION}/cross-x86_64-unknown-linux-gnu.tar.gz" |
23 |
| - curl -SsL "$download_url" | |
24 |
| - tar -xvz -C /tmp |
25 |
| - compiler_command="/tmp/cross" |
| 17 | + |
| 18 | +x86_64-unknown-linux-musl) |
| 19 | + sudo apt-get update |
| 20 | + sudo apt-get install musl-tools |
| 21 | + musl-gcc --version && echo "Musl successfully installed" |
26 | 22 | ;;
|
| 23 | + |
| 24 | +aarch64-unknown-linux-gnu) |
| 25 | + sudo apt-get update |
| 26 | + sudo apt-get install gcc-aarch64-linux-gnu |
| 27 | + |
| 28 | + aarch64-linux-gnu-gcc --version |
| 29 | + echo "Cross compiler successfully installed" |
| 30 | + |
| 31 | + echo '[target.aarch64-unknown-linux-gnu]' >>"$CARGO_CONFIG" |
| 32 | + echo 'linker = "aarch64-linux-gnu-gcc"' >>"$CARGO_CONFIG" |
| 33 | + ;; |
| 34 | + |
27 | 35 | *)
|
28 |
| - >&2 echo "Unsupported kernel: $kernel_name" |
29 |
| - exit 1 |
| 36 | + echo >&2 "Error: Unsupported compilation target: $TARGET" |
| 37 | + exit 2 |
30 | 38 | ;;
|
31 | 39 | esac
|
32 | 40 |
|
33 |
| -"$compiler_command" build --release --target="$TARGET" |
| 41 | +rustup target add "$TARGET" |
| 42 | +cargo build --release --target="$TARGET" --bin starknet-devnet |
0 commit comments