35 lines
1.6 KiB
Bash
Executable File
35 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
target="${1:?Usage: build-linux.sh linux-aarch64|linux-armhf|linux-x86_64}"
|
|
case "$target" in linux-aarch64|linux-armhf|linux-x86_64) ;; *) echo "Unsupported target label" >&2; exit 2;; esac
|
|
sdk="${SDKDIR:-$root/sdk/ExtensionSDK}"
|
|
compiler="${CC:-gcc}"
|
|
for tool in "$compiler" make m4 dos2unix python3 file; do command -v "$tool" >/dev/null; done
|
|
sdk="$(realpath "$sdk")"
|
|
make -C "$root/component" SDKDIR="$sdk" CC="$compiler" clean
|
|
make -C "$root/component" SDKDIR="$sdk" CC="$compiler" all
|
|
binary="$root/component/out/libCmpAtomModbus.so"
|
|
identity="$(file -b "$binary")"
|
|
case "$target" in
|
|
linux-aarch64) [[ "$identity" == *aarch64* ]] ;;
|
|
linux-armhf) [[ "$identity" == *"ELF 32-bit"* && "$identity" == *ARM* ]] ;;
|
|
linux-x86_64) [[ "$identity" == *x86-64* ]] ;;
|
|
esac || { echo "Binary architecture does not match $target: $identity" >&2; exit 3; }
|
|
destination="$root/dist/0.2.0/$target"
|
|
mkdir -p "$destination"
|
|
cp "$binary" "$destination/"
|
|
{
|
|
date -u '+Build UTC: %Y-%m-%dT%H:%M:%SZ'
|
|
uname -a
|
|
"$compiler" --version
|
|
file "$binary"
|
|
if command -v getconf >/dev/null; then getconf GNU_LIBC_VERSION || true; fi
|
|
if command -v git >/dev/null; then git -C "$root" rev-parse HEAD 2>/dev/null || true; fi
|
|
printf 'SDK file hashes:\n'
|
|
find "$sdk" -type f -exec sha256sum {} +
|
|
printf 'Record tested runtime, target OS/libc and cross sysroot here before release.\n'
|
|
} > "$destination/build-info.txt"
|
|
sha256sum "$destination/libCmpAtomModbus.so" > "$destination/SHA256SUMS.txt"
|
|
printf 'Built: %s\n' "$destination/libCmpAtomModbus.so"
|