From: Thomas Karpiniec Date: Mon, 3 Mar 2025 00:28:39 +0000 (+1100) Subject: Add build scripts for cross-platform testing X-Git-Url: https://code.octet-stream.net/m17rt/commitdiff_plain/b894437365797e9cdbccf4b6e6d908180e92ab81 Add build scripts for cross-platform testing --- diff --git a/buildscripts/build.sh b/buildscripts/build.sh new file mode 100755 index 0000000..469dff2 --- /dev/null +++ b/buildscripts/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -euxo pipefail +cd "$(git rev-parse --show-toplevel)" +source buildscripts/init.sh "$1" + +cargo build --target "${RUST_TARGET}" diff --git a/buildscripts/dist-generic.sh b/buildscripts/dist-generic.sh new file mode 100755 index 0000000..d4df239 --- /dev/null +++ b/buildscripts/dist-generic.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -euxo pipefail +cd "$(git rev-parse --show-toplevel)" + +TAG=$1 + +BASENAME="m17rt-${TAG}" +FILENAME="${BASENAME}.tar.xz" + +git archive "${TAG}" -o "${FILENAME}" --prefix="${BASENAME}/" + +echo "GENERIC_ARTIFACT|${FILENAME}|Source Code" +echo "URL|Git Tag|https://code.octet-stream.net/m17rt/shortlog/refs/tags/${TAG}|${TAG}" diff --git a/buildscripts/dist.sh b/buildscripts/dist.sh new file mode 100755 index 0000000..3c8f6b2 --- /dev/null +++ b/buildscripts/dist.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -euxo pipefail +cd "$(git rev-parse --show-toplevel)" + +PLATFORM=$1 +TAG=$2 +source buildscripts/init.sh "${PLATFORM}" + +# TODO diff --git a/buildscripts/init.sh b/buildscripts/init.sh new file mode 100644 index 0000000..ed73ec8 --- /dev/null +++ b/buildscripts/init.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -euxo pipefail +cd "$(git rev-parse --show-toplevel)" + +PLATFORM=$1 + +case $PLATFORM in +mac-x86_64) + RUST_TARGET=x86_64-apple-darwin + ;; +mac-arm64) + RUST_TARGET=aarch64-apple-darwin + ;; +linux-x86_64) + RUST_TARGET=x86_64-unknown-linux-gnu + ;; +linux-armhf) + RUST_TARGET=armv7-unknown-linux-gnueabihf + ;; +linux-arm64) + RUST_TARGET=aarch64-unknown-linux-gnu + ;; +windows-x86_64) + RUST_TARGET=x86_64-pc-windows-msvc + ;; +*) + echo "Unrecognised platform" + exit 1 + ;; +esac + +export RUST_TARGET diff --git a/buildscripts/lint.sh b/buildscripts/lint.sh new file mode 100755 index 0000000..bf9fc8f --- /dev/null +++ b/buildscripts/lint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -euxo pipefail +cd "$(git rev-parse --show-toplevel)" +source buildscripts/init.sh "$1" + +cargo clippy --all-targets --target "${RUST_TARGET}" -- -D warnings +cargo fmt --all --check diff --git a/buildscripts/test.sh b/buildscripts/test.sh new file mode 100755 index 0000000..a02b370 --- /dev/null +++ b/buildscripts/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -euxo pipefail +cd "$(git rev-parse --show-toplevel)" +source buildscripts/init.sh "$1" + +cargo test --target "${RUST_TARGET}"