mirror of
https://github.com/imjasonh/krust
synced 2026-07-08 06:45:32 +00:00
refactor: Add make targets for cross-compilation setup
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
e15bd1df8c
commit
f91d156266
2 changed files with 40 additions and 16 deletions
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
40
Makefile
40
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue