]> code.octet-stream.net Git - m17rt/commitdiff
Add build scripts for cross-platform testing master
authorThomas Karpiniec <tom.karpiniec@fastmail.com.au>
Mon, 3 Mar 2025 00:28:39 +0000 (11:28 +1100)
committerThomas Karpiniec <tom.karpiniec@fastmail.com.au>
Mon, 3 Mar 2025 00:34:36 +0000 (11:34 +1100)
buildscripts/build.sh [new file with mode: 0755]
buildscripts/dist-generic.sh [new file with mode: 0755]
buildscripts/dist.sh [new file with mode: 0755]
buildscripts/init.sh [new file with mode: 0644]
buildscripts/lint.sh [new file with mode: 0755]
buildscripts/test.sh [new file with mode: 0755]

diff --git a/buildscripts/build.sh b/buildscripts/build.sh
new file mode 100755 (executable)
index 0000000..469dff2
--- /dev/null
@@ -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 (executable)
index 0000000..d4df239
--- /dev/null
@@ -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 (executable)
index 0000000..3c8f6b2
--- /dev/null
@@ -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 (file)
index 0000000..ed73ec8
--- /dev/null
@@ -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 (executable)
index 0000000..bf9fc8f
--- /dev/null
@@ -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 (executable)
index 0000000..a02b370
--- /dev/null
@@ -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}"