From f91d1562662fc25627fb8f19011b50c997e87310 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Sun, 8 Jun 2025 12:05:07 -0400 Subject: [PATCH] refactor: Add make targets for cross-compilation setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add setup-cross-compile target to create cargo config - Add verify-cross-compile target to check setup - Update CI to use make verify-cross-compile - Simplifies CI workflow and centralizes cross-compile logic 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/ci.yml | 16 +--------------- Makefile | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bf8050..58e4e7c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,21 +45,7 @@ jobs: path: target key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} - name: Verify cross-compilation setup - run: | - echo "Installed targets:" - rustup target list --installed - echo "Cargo version:" - cargo --version - echo "Rustc version:" - rustc --version - echo "Available linkers:" - which x86_64-unknown-linux-musl-gcc || echo "x86_64-unknown-linux-musl-gcc not found" - which x86_64-linux-musl-gcc || echo "x86_64-linux-musl-gcc not found" - which musl-gcc || echo "musl-gcc not found" - which aarch64-linux-gnu-gcc || echo "aarch64-linux-gnu-gcc not found" - which rust-lld || echo "rust-lld not found" - echo "Cargo config:" - cat .cargo/config.toml || echo "No cargo config found" + run: make verify-cross-compile - name: Build run: make build-verbose - name: Run unit tests diff --git a/Makefile b/Makefile index 2c48d98..f41ab0e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: test test-unit test-e2e build run clean fmt lint check-fmt check test-verbose +.PHONY: test test-unit test-e2e build run clean fmt lint check-fmt check test-verbose setup-cross-compile verify-cross-compile # Test flags - run single-threaded to avoid env var races TEST_FLAGS := -- --test-threads=1 @@ -11,6 +11,44 @@ build: build-verbose: cargo build --verbose +# Setup cargo config for cross-compilation +setup-cross-compile: + @mkdir -p .cargo + @cat > .cargo/config.toml <<'EOF' + [target.x86_64-unknown-linux-musl] + linker = "x86_64-linux-musl-gcc" + + [target.aarch64-unknown-linux-musl] + linker = "aarch64-linux-gnu-gcc" + EOF + @echo "Created .cargo/config.toml for cross-compilation" + +# Verify cross-compilation setup +verify-cross-compile: + @echo "=== Rust Installation ===" + @echo "Installed targets:" + @rustup target list --installed + @echo "" + @echo "Cargo version:" + @cargo --version + @echo "" + @echo "Rustc version:" + @rustc --version + @echo "" + @echo "=== Available Linkers ===" + @which x86_64-unknown-linux-musl-gcc 2>/dev/null && echo "✓ x86_64-unknown-linux-musl-gcc found" || echo "✗ x86_64-unknown-linux-musl-gcc not found" + @which x86_64-linux-musl-gcc 2>/dev/null && echo "✓ x86_64-linux-musl-gcc found" || echo "✗ x86_64-linux-musl-gcc not found" + @which musl-gcc 2>/dev/null && echo "✓ musl-gcc found" || echo "✗ musl-gcc not found" + @which aarch64-linux-gnu-gcc 2>/dev/null && echo "✓ aarch64-linux-gnu-gcc found" || echo "✗ aarch64-linux-gnu-gcc not found" + @which rust-lld 2>/dev/null && echo "✓ rust-lld found" || echo "✗ rust-lld not found" + @echo "" + @echo "=== Cargo Config ===" + @if [ -f .cargo/config.toml ]; then \ + cat .cargo/config.toml; \ + else \ + echo "No cargo config found at .cargo/config.toml"; \ + fi + # Run the project run: cargo run