feat/arm-cross-compilation #259
@@ -3,3 +3,6 @@ rustflags = ["-C", "link-arg=/STACK:8000000"]
|
||||
|
||||
[target.x86_64-pc-windows-gnu]
|
||||
rustflags = ["-C", "link-arg=-Wl,--stack,8000000"]
|
||||
|
||||
[target.aarch64-unknown-linux-gnu]
|
||||
linker = "aarch64-linux-gnu-gcc"
|
||||
|
||||
78
.gitea/workflows/arm-agents.yaml
Normal file
78
.gitea/workflows/arm-agents.yaml
Normal file
@@ -0,0 +1,78 @@
|
||||
name: Build ARM agent binaries
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
- 'snapshot-*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build_arm_agents:
|
||||
container:
|
||||
image: hub.nationtech.io/harmony/harmony_composer:latest
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install ARM cross-compilation toolchain
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq gcc-aarch64-linux-gnu
|
||||
rustup target add aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Build agent crates for aarch64
|
||||
run: |
|
||||
cargo build --release --target aarch64-unknown-linux-gnu \
|
||||
-p harmony_agent \
|
||||
-p harmony_inventory_agent
|
||||
|
||||
- name: Install jq
|
||||
run: apt-get install -y -qq jq
|
||||
|
||||
- name: Get or create release
|
||||
run: |
|
||||
TAG_NAME="${GITHUB_REF_NAME}"
|
||||
|
||||
# Try to get existing release
|
||||
RELEASE_ID=$(curl -s -X GET \
|
||||
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||
"https://git.nationtech.io/api/v1/repos/nationtech/harmony/releases/tags/${TAG_NAME}" \
|
||||
| jq -r '.id // empty')
|
||||
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
# Create new release
|
||||
RESPONSE=$(curl -s -X POST \
|
||||
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"tag_name\": \"${TAG_NAME}\",
|
||||
\"name\": \"${TAG_NAME}\",
|
||||
\"body\": \"Release ${TAG_NAME}\",
|
||||
\"draft\": false,
|
||||
\"prerelease\": true
|
||||
}" \
|
||||
"https://git.nationtech.io/api/v1/repos/nationtech/harmony/releases")
|
||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
||||
fi
|
||||
|
||||
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV
|
||||
|
||||
- name: Upload harmony_agent ARM binary
|
||||
run: |
|
||||
curl -X POST \
|
||||
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@target/aarch64-unknown-linux-gnu/release/harmony_agent" \
|
||||
"https://git.nationtech.io/api/v1/repos/nationtech/harmony/releases/${{ env.RELEASE_ID }}/assets?name=harmony_agent-aarch64-linux"
|
||||
|
||||
- name: Upload harmony_inventory_agent ARM binary
|
||||
run: |
|
||||
curl -X POST \
|
||||
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@target/aarch64-unknown-linux-gnu/release/harmony_inventory_agent" \
|
||||
"https://git.nationtech.io/api/v1/repos/nationtech/harmony/releases/${{ env.RELEASE_ID }}/assets?name=harmony_inventory_agent-aarch64-linux"
|
||||
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3640,7 +3640,6 @@ dependencies = [
|
||||
"cidr",
|
||||
"env_logger",
|
||||
"getrandom 0.3.4",
|
||||
"harmony",
|
||||
"harmony_macros",
|
||||
"harmony_types",
|
||||
"log",
|
||||
|
||||
43
build/cross-arm.sh
Executable file
43
build/cross-arm.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# Cross-compile agent crates for aarch64 (Raspberry Pi)
|
||||
#
|
||||
# Prerequisites (Debian/Ubuntu):
|
||||
# sudo apt install gcc-aarch64-linux-gnu
|
||||
# rustup target add aarch64-unknown-linux-gnu
|
||||
#
|
||||
# Prerequisites (Arch Linux):
|
||||
# sudo pacman -S aarch64-linux-gnu-gcc
|
||||
# rustup target add aarch64-unknown-linux-gnu
|
||||
|
||||
TARGET="aarch64-unknown-linux-gnu"
|
||||
|
||||
echo "=== Cross-compiling for $TARGET ==="
|
||||
|
||||
# Check prerequisites
|
||||
if ! rustup target list --installed | grep -q "$TARGET"; then
|
||||
echo "ERROR: Rust target $TARGET not installed. Run: rustup target add $TARGET"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v aarch64-linux-gnu-gcc > /dev/null 2>&1; then
|
||||
echo "ERROR: aarch64-linux-gnu-gcc not found. Install the cross-compilation toolchain."
|
||||
echo " Debian/Ubuntu: sudo apt install gcc-aarch64-linux-gnu"
|
||||
echo " Arch Linux: sudo pacman -S aarch64-linux-gnu-gcc"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "--- Building harmony_agent ---"
|
||||
cargo build --release --target "$TARGET" -p harmony_agent
|
||||
|
||||
echo "--- Building harmony_inventory_agent ---"
|
||||
cargo build --release --target "$TARGET" -p harmony_inventory_agent
|
||||
|
||||
echo ""
|
||||
echo "=== Build complete ==="
|
||||
echo "Binaries:"
|
||||
echo " target/$TARGET/release/harmony_agent"
|
||||
echo " target/$TARGET/release/harmony_inventory_agent"
|
||||
@@ -6,7 +6,6 @@ readme.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
harmony = { path = "../harmony" }
|
||||
# harmony_cli = { path = "../harmony_cli" }
|
||||
harmony_types = { path = "../harmony_types" }
|
||||
harmony_macros = { path = "../harmony_macros" }
|
||||
|
||||
Reference in New Issue
Block a user