diff --git a/.github/workflows/build_riscv_rva23.yml b/.github/workflows/build_riscv_rva23.yml new file mode 100644 index 0000000..beca89c --- /dev/null +++ b/.github/workflows/build_riscv_rva23.yml @@ -0,0 +1,36 @@ +name: Build RISC V RVA23 via x86 cross-compile + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v5 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Build image + run: podman build -t odorobo-builder:rva23 . + - name: Build binaries + run: podman run --rm -v ${{ github.workspace }}:/code -w /code odorobo-builder:rva23 cargo build --release --verbose + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: odorobo_riscv_rva23 + path: | + target/riscv64a23-unknown-linux-gnu/release/odorobo-agent + target/riscv64a23-unknown-linux-gnu/release/odoroboctl diff --git a/.github/workflows/rust.yml b/.github/workflows/build_x86.yml similarity index 51% rename from .github/workflows/rust.yml rename to .github/workflows/build_x86.yml index 9fd45e0..76aae89 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/build_x86.yml @@ -1,4 +1,4 @@ -name: Rust +name: Build x86 on: push: @@ -17,6 +17,13 @@ jobs: steps: - uses: actions/checkout@v4 - name: Build - run: cargo build --verbose + run: cargo build --verbose --release + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: odorobo_x86 + path: | + target/release/odorobo-agent + target/release/odoroboctl - name: Run tests run: cargo test --verbose diff --git a/.gitignore b/.gitignore index 27e517e..cf82bef 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ dev # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +.idea/ # AI Slop # Anyone who uses LLMs for slop gets to keep their own slop context. diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..8f6fe62 --- /dev/null +++ b/Containerfile @@ -0,0 +1,15 @@ +FROM alpine:3.23.3 +RUN apk add \ + bash \ + gcc \ + musl-dev \ + rustup \ + zig +RUN rustup-init \ + --profile minimal \ + --target riscv64a23-unknown-linux-gnu \ + -y +ENV CARGO_BUILD_TARGET="riscv64a23-unknown-linux-gnu" +ENV PATH="/root/.cargo/bin:$PATH" +ENV CC_riscv64a23_unknown_linux_gnu="/code/scripts/zig-cc-rva23.sh" +ENV CARGO_TARGET_RISCV64A23_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C linker=scripts/zig-cc-rva23.sh" diff --git a/scripts/zig-cc-rva23.sh b/scripts/zig-cc-rva23.sh new file mode 100755 index 0000000..fd0d8e6 --- /dev/null +++ b/scripts/zig-cc-rva23.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +# A script for cargo to use as the C compiler and linker when building RVA23 +# binaries. This links them using zig cc. + +args=() +for arg in "$@"; do + case "$arg" in + --target=riscv64-unknown-linux-gnu) + ;; + *) + args+=("$arg") + ;; + esac +done +exec zig cc -target riscv64-linux-gnu "${args[@]}"