wee
Multi-Platform CI / test-platforms (ubuntu-22.04) (push) Successful in 22s
Multi-Platform CI / test-platforms (windows-latest) (push) Successful in 18s
Multi-Platform CI / Package for Linux x86_64 (push) Successful in 58s
Multi-Platform CI / Package for Windows x86_64 (push) Successful in 54s
Multi-Platform CI / test-platforms (ubuntu-22.04) (push) Successful in 22s
Multi-Platform CI / test-platforms (windows-latest) (push) Successful in 18s
Multi-Platform CI / Package for Linux x86_64 (push) Successful in 58s
Multi-Platform CI / Package for Windows x86_64 (push) Successful in 54s
This commit is contained in:
@@ -7,7 +7,7 @@ on:
|
|||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
target:
|
target:
|
||||||
description: "The Rust compilation target (e.g., x86_64-pc-windows-gnu). Empty for native."
|
description: "The Rust compilation target. Empty for native test builds."
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: ''
|
default: ''
|
||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
components: clippy, rustfmt
|
components: clippy, rustfmt
|
||||||
|
|
||||||
# Steps for linting, testing, etc. These are skipped in 'package-only' mode.
|
# Normal tests and lints (these will run on the runner's native ARM architecture)
|
||||||
- name: Build
|
- name: Build
|
||||||
if: ${{ !inputs.package-only }}
|
if: ${{ !inputs.package-only }}
|
||||||
run: cargo build --all-features
|
run: cargo build --all-features
|
||||||
@@ -39,7 +39,7 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
if: ${{ !inputs.package-only }}
|
if: ${{ !inputs.package-only }}
|
||||||
run: cargo test --all-features
|
run: cargo test --all-features
|
||||||
|
|
||||||
- name: Clippy
|
- name: Clippy
|
||||||
if: ${{ !inputs.package-only }}
|
if: ${{ !inputs.package-only }}
|
||||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||||
@@ -54,81 +54,75 @@ jobs:
|
|||||||
cargo install cargo-audit
|
cargo install cargo-audit
|
||||||
cargo audit
|
cargo audit
|
||||||
|
|
||||||
|
|
||||||
# --- Build & Package Logic ---
|
# --- Build & Package Logic ---
|
||||||
|
|
||||||
- name: Set up Windows cross-compilation environment
|
- name: Set up Linux x86_64 cross-compilation
|
||||||
|
if: inputs.target == 'x86_64-unknown-linux-gnu'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y g++-x86-64-linux-gnu
|
||||||
|
rustup target add x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
|
- name: Set up Windows x86_64 cross-compilation
|
||||||
if: inputs.target == 'x86_64-pc-windows-gnu'
|
if: inputs.target == 'x86_64-pc-windows-gnu'
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y gcc-mingw-w64-x86-64
|
sudo apt-get install -y gcc-mingw-w64-x86-64
|
||||||
rustup target add x86_64-pc-windows-gnu
|
rustup target add x86_64-pc-windows-gnu
|
||||||
|
|
||||||
- name: Build FFI library (Native)
|
- name: Build FFI library (Cross-Compile)
|
||||||
if: inputs.upload-artifacts && inputs.target == ''
|
if: inputs.upload-artifacts
|
||||||
run: cargo build --release --features ffi
|
|
||||||
|
|
||||||
- name: Build FFI library (Cross-compile for Windows)
|
|
||||||
if: inputs.upload-artifacts && inputs.target == 'x86_64-pc-windows-gnu'
|
|
||||||
run: cargo build --release --features ffi --target=${{ inputs.target }}
|
run: cargo build --release --features ffi --target=${{ inputs.target }}
|
||||||
env:
|
env:
|
||||||
|
# Set the correct linker for each target
|
||||||
|
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: x86_64-linux-gnu-g++
|
||||||
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: x86_64-w64-mingw32-gcc
|
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: x86_64-w64-mingw32-gcc
|
||||||
|
|
||||||
- name: Extract version and create package (Linux)
|
- name: Extract version and create package
|
||||||
if: inputs.upload-artifacts && inputs.target == ''
|
if: inputs.upload-artifacts
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(sed -n 's/^version\s*=\s*"\([^"]\+\)"/\1/p' Cargo.toml | head -n1)
|
VERSION=$(sed -n 's/^version\s*=\s*"\([^"]\+\)"/\1/p' Cargo.toml | head -n1)
|
||||||
# Map runner.arch to Rust target arch
|
TARGET_ARCH="x86_64"
|
||||||
case "${{ runner.arch }}" in
|
TARGET_TRIPLE="${{ inputs.target }}"
|
||||||
ARM64) ARCH_TRIPLE="aarch64" ;;
|
|
||||||
X64) ARCH_TRIPLE="x86_64" ;;
|
|
||||||
*) ARCH_TRIPLE="unknown" ;;
|
|
||||||
esac
|
|
||||||
PKG_BASENAME="medicallib_rust-v${VERSION}-${ARCH_TRIPLE}-unknown-linux-gnu"
|
|
||||||
PKG_DIR="dist/${PKG_BASENAME}"
|
|
||||||
|
|
||||||
|
# Determine package name and library extension based on target
|
||||||
|
if [[ "$TARGET_TRIPLE" == "x86_64-unknown-linux-gnu" ]]; then
|
||||||
|
PKG_BASENAME="medicallib_rust-v${VERSION}-${TARGET_ARCH}-unknown-linux-gnu"
|
||||||
|
LIB_NAME="libmedicallib_rust.so"
|
||||||
|
ARCHIVE_TYPE="tar.gz"
|
||||||
|
elif [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then
|
||||||
|
PKG_BASENAME="medicallib_rust-v${VERSION}-${TARGET_ARCH}-pc-windows-gnu"
|
||||||
|
LIB_NAME="medicallib_rust.dll"
|
||||||
|
ARCHIVE_TYPE="zip"
|
||||||
|
else
|
||||||
|
echo "::error::Unsupported target for packaging: $TARGET_TRIPLE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PKG_DIR="dist/${PKG_BASENAME}"
|
||||||
echo "Creating package ${PKG_BASENAME}..."
|
echo "Creating package ${PKG_BASENAME}..."
|
||||||
mkdir -p "${PKG_DIR}/include" "${PKG_DIR}/lib"
|
mkdir -p "${PKG_DIR}/include" "${PKG_DIR}/lib"
|
||||||
|
|
||||||
|
# Copy header and the compiled library from the correct target-specific directory
|
||||||
cp ffi/medicallib.h "${PKG_DIR}/include/"
|
cp ffi/medicallib.h "${PKG_DIR}/include/"
|
||||||
cp "target/release/libmedicallib_rust.so" "${PKG_DIR}/lib/"
|
cp "target/${TARGET_TRIPLE}/release/${LIB_NAME}" "${PKG_DIR}/lib/"
|
||||||
|
|
||||||
tar -C dist -czf "dist/${PKG_BASENAME}.tar.gz" "${PKG_BASENAME}"
|
# Create the appropriate archive
|
||||||
(cd dist && zip -r9 "${PKG_BASENAME}.zip" "${PKG_BASENAME}")
|
if [[ "$ARCHIVE_TYPE" == "tar.gz" ]]; then
|
||||||
|
tar -C dist -czf "dist/${PKG_BASENAME}.tar.gz" "${PKG_BASENAME}"
|
||||||
|
elif [[ "$ARCHIVE_TYPE" == "zip" ]]; then
|
||||||
|
(cd dist && zip -r9 "${PKG_BASENAME}.zip" "${PKG_BASENAME}")
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Extract version and create package (Cross-compiled Windows)
|
- name: Upload Artifact
|
||||||
if: inputs.upload-artifacts && inputs.target == 'x86_64-pc-windows-gnu'
|
if: inputs.upload-artifacts
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
VERSION=$(sed -n 's/^version\s*=\s*"\([^"]\+\)"/\1/p' Cargo.toml | head -n1)
|
|
||||||
ARCH_TRIPLE="x86_64"
|
|
||||||
PKG_BASENAME="medicallib_rust-v${VERSION}-${ARCH_TRIPLE}-pc-windows-gnu"
|
|
||||||
PKG_DIR="dist/${PKG_BASENAME}"
|
|
||||||
|
|
||||||
echo "Creating package ${PKG_BASENAME}..."
|
|
||||||
mkdir -p "${PKG_DIR}/include" "${PKG_DIR}/lib"
|
|
||||||
cp ffi/medicallib.h "${PKG_DIR}/include/"
|
|
||||||
|
|
||||||
# The output path is different for cross-compilation
|
|
||||||
cp "target/x86_64-pc-windows-gnu/release/medicallib_rust.dll" "${PKG_DIR}/lib/"
|
|
||||||
|
|
||||||
(cd dist && zip -r9 "${PKG_BASENAME}.zip" "${PKG_BASENAME}")
|
|
||||||
|
|
||||||
# --- Artifact Upload Logic ---
|
|
||||||
|
|
||||||
- name: Upload Linux Artifact
|
|
||||||
if: inputs.upload-artifacts && inputs.target == ''
|
|
||||||
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: medicallib-rust-Linux-${{ runner.arch }}-${{ github.run_number }}
|
# Create a unique name based on the target OS
|
||||||
|
name: medicallib-rust-${{ contains(inputs.target, 'windows') && 'Windows' || 'Linux' }}-x86_64-${{ github.run_number }}
|
||||||
path: |
|
path: |
|
||||||
dist/*.tar.gz
|
dist/*.tar.gz
|
||||||
dist/*.zip
|
dist/*.zip
|
||||||
if-no-files-found: error
|
|
||||||
|
|
||||||
- name: Upload Windows Artifact
|
|
||||||
if: inputs.upload-artifacts && inputs.target == 'x86_64-pc-windows-gnu'
|
|
||||||
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: medicallib-rust-Windows-x86_64-${{ github.run_number }}
|
|
||||||
path: dist/*.zip
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
@@ -33,11 +33,11 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
# Configuration for the native Linux build
|
# Configuration for the native Linux build
|
||||||
- name: Linux
|
- name: Linux x86_64
|
||||||
target: '' # An empty target means native build
|
target: 'x86_64-unknown-linux-gnu' # An empty target means native build
|
||||||
|
|
||||||
# Configuration for the Windows cross-compile build
|
# Configuration for the Windows cross-compile build
|
||||||
- name: Windows (Cross-Compiled)
|
- name: Windows x86_64
|
||||||
target: 'x86_64-pc-windows-gnu'
|
target: 'x86_64-pc-windows-gnu'
|
||||||
|
|
||||||
name: Package for ${{ matrix.name }}
|
name: Package for ${{ matrix.name }}
|
||||||
|
|||||||
Reference in New Issue
Block a user