Skip to content

Commit

Permalink
ci: add build for Linux ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuttymoon committed Sep 7, 2023
1 parent 45e1fc3 commit 354d154
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[target.aarch64-unknown-linux-gnu]
ar = "aarch64-linux-gnu-ar"
linker = "aarch64-linux-gnu-gcc"

[target.x86_64-apple-darwin]
linker = "x86_64-apple-darwin21.4-clang"
ar = "x86_64-apple-darwin21.4-ar"
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/ash_sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ chrono = { version = "0.4.24", features = ["clock"] }
[dev-dependencies]
serial_test = "2.0.0"
tempfile = "3.3.0"

[target.aarch64-unknown-linux-gnu.dependencies]
openssl = { version = "0.10.54", features = ["vendored"] }
30 changes: 23 additions & 7 deletions scripts/build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,43 @@
# Build Ash CLI for Linux
# Any argument will be passed to cargo build

# The script assumes it is run on a Debian-based Linux distro (e.g. Ubuntu)
# The script assumes it is run on a Debian-based Linux distro (e.g. Ubuntu) on an x86_64 (amd64) machine
# and that the following packages are installed: gcc-aarch64-linux-gnu

# Build Ash CLI for Linux
echo "Building Ash CLI for Linux..."
# Add aaarch64-unknown-linux-gnu target to rustup
rustup target add aarch64-unknown-linux-gnu

# Build Ash CLI for Linux x86_64
echo "Building Ash CLI for Linux x86_64..."
cargo build "$@"

# Build Ash CLI for Linux aarch64
echo "Building Ash CLI for Linux aarch64..."
cargo build --target aarch64-unknown-linux-gnu "$@"

# Get current version
PACKAGE_VERSION=$(grep '^version =' Cargo.toml | grep -oP '\d+\.\d+\.\d+-?(alpha|beta)?(.\d+)?')

# If any argument passed is '--release', binaries are in 'target/release'
# Otherwise, binaries are in 'target/debug'
if [[ "$*" == *"--release"* ]]; then
LINUX_TARGET_DIR="target/release"
LINUX_AMD_TARGET_DIR="target/release"
LINUX_ARM_TARGET_DIR="target/aarch64-unknown-linux-gnu/release"
else
LINUX_TARGET_DIR="target/debug"
LINUX_AMD_TARGET_DIR="target/debug"
LINUX_ARM_TARGET_DIR="target/aarch64-unknown-linux-gnu/debug"
fi

# Create an archive with the Ash CLI binary
## Linux
cd "$LINUX_TARGET_DIR" || exit 1
## Linux x86_64
cd "$LINUX_AMD_TARGET_DIR" || exit 1
rm -f "ash-linux-amd64-v$PACKAGE_VERSION.tar.gz"
tar -czf "ash-linux-amd64-v$PACKAGE_VERSION.tar.gz" ash
sha512sum "ash-linux-amd64-v$PACKAGE_VERSION.tar.gz" >"ash-linux-amd64-v$PACKAGE_VERSION.tar.gz.sha512"
cd "$OLDPWD" || exit 1

## Linux aarch64
cd "$LINUX_ARM_TARGET_DIR" || exit 1
rm -f "ash-linux-arm64-v$PACKAGE_VERSION.tar.gz"
tar -czf "ash-linux-arm64-v$PACKAGE_VERSION.tar.gz" ash
sha512sum "ash-linux-arm64-v$PACKAGE_VERSION.tar.gz" >"ash-linux-arm64-v$PACKAGE_VERSION.tar.gz.sha512"
1 change: 0 additions & 1 deletion scripts/build_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@ cd "$MAC_ARM_TARGET_DIR" || exit 1
rm -f "ash-macos-arm64-v$PACKAGE_VERSION.tar.gz"
tar -czf "ash-macos-arm64-v$PACKAGE_VERSION.tar.gz" ash
sha512sum "ash-macos-arm64-v$PACKAGE_VERSION.tar.gz" >"ash-macos-arm64-v$PACKAGE_VERSION.tar.gz.sha512"
cd "$OLDPWD" || exit 1

0 comments on commit 354d154

Please sign in to comment.