summaryrefslogtreecommitdiffstats
path: root/ci/build_scripts/build_for_arm.sh
blob: deb2857c5e4796b573c67a0a7fa1f34f6cc0c08c (plain)
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
#!/bin/bash -x

set -euo pipefail

ARCH=$1

# Install required cargo crates
cargo install cargo-deb --version 1.38.1
cargo install cross

# armv7 uses `arm-linux-gnueabihf-strip`; aarch64 uses `aarch64-linux-gnu-strip`
# It appears `aarch64-linux-gnu-strip` seems to work explicitly on other arm bins but not other way around.
sudo apt update
sudo apt-get --assume-yes install binutils-arm-linux-gnueabihf binutils-aarch64-linux-gnu

# Load the release package list as $RELEASE_PACKAGES and $TEST_PACKAGES
# shellcheck disable=SC1091
source ./ci/package_list.sh

# Cross build release for target
cross build --release --target="$ARCH"

# Strip and create debian packages for release artifacts
for PACKAGE in "${RELEASE_PACKAGES[@]}"
do
    arm-linux-gnueabihf-strip target/"$ARCH"/release/"$PACKAGE" || aarch64-linux-gnu-strip target/"$ARCH"/release/"$PACKAGE"
    cargo deb -p "$PACKAGE" --no-strip --no-build --target="$ARCH"
done

# Strip and build for test artifacts
for PACKAGE in "${TEST_PACKAGES[@]}"
do
    cross build --release -p "$PACKAGE" --target="$ARCH"
    arm-linux-gnueabihf-strip target/"$ARCH"/release/"$PACKAGE" || aarch64-linux-gnu-strip target/"$ARCH"/release/"$PACKAGE"
done