mirror of
https://github.com/Ap0dexMe0/unixtract.git
synced 2026-07-15 21:00:03 +02:00
released
This commit is contained in:
@@ -1,61 +0,0 @@
|
|||||||
name: rust
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_TERM_COLOR: always
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build ${{ matrix.target }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- target: x86_64-unknown-linux-gnu
|
|
||||||
artifact: unixtract-linux
|
|
||||||
bin: unixtract
|
|
||||||
- target: x86_64-pc-windows-gnu
|
|
||||||
artifact: unixtract-windows.exe
|
|
||||||
bin: unixtract.exe
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
targets: ${{ matrix.target }}
|
|
||||||
|
|
||||||
- name: Install mingw-w64 (Windows target)
|
|
||||||
if: matrix.target == 'x86_64-pc-windows-gnu'
|
|
||||||
run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64
|
|
||||||
|
|
||||||
- name: Cache cargo
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/registry
|
|
||||||
~/.cargo/git
|
|
||||||
target
|
|
||||||
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: cargo build --release --target ${{ matrix.target }}
|
|
||||||
|
|
||||||
- name: Rename binary
|
|
||||||
run: cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "${{ matrix.artifact }}"
|
|
||||||
|
|
||||||
- name: Upload artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: ${{ matrix.artifact }}
|
|
||||||
path: ${{ matrix.artifact }}
|
|
||||||
if-no-files-found: error
|
|
||||||
@@ -1,71 +1,39 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
|
||||||
# Cross-compile unixtract for multiple targets and collect the binaries into
|
|
||||||
# ./dist. Run from the repository root:
|
|
||||||
#
|
|
||||||
# ./build.sh # build the default target set
|
|
||||||
# ./build.sh <target> ... # build only the given rustc target triples
|
|
||||||
#
|
|
||||||
# Requirements (Debian/Ubuntu example):
|
|
||||||
# rustup # toolchain manager
|
|
||||||
# sudo apt install gcc-mingw-w64-x86-64 # for x86_64-pc-windows-gnu
|
|
||||||
# sudo apt install gcc-aarch64-linux-gnu # for aarch64-unknown-linux-gnu (optional)
|
|
||||||
#
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# --- Target set ------------------------------------------------------------
|
clear
|
||||||
# Override by passing target triples as arguments.
|
echo "Cleaning target and dist directories..."
|
||||||
DEFAULT_TARGETS=(
|
rm -rf target dist
|
||||||
x86_64-unknown-linux-gnu
|
|
||||||
x86_64-pc-windows-gnu
|
|
||||||
)
|
|
||||||
|
|
||||||
if [ "$#" -gt 0 ]; then
|
echo "Building unixtract (Linux + Windows)..."
|
||||||
TARGETS=("$@")
|
|
||||||
else
|
# Clean using cargo (redundant but safe)
|
||||||
TARGETS=("${DEFAULT_TARGETS[@]}")
|
cargo clean
|
||||||
|
|
||||||
|
# Build Linux
|
||||||
|
cargo build --target x86_64-unknown-linux-gnu --release
|
||||||
|
|
||||||
|
# Build Windows (GNU)
|
||||||
|
cargo build --target x86_64-pc-windows-gnu --release
|
||||||
|
|
||||||
|
# Prepare dist folder
|
||||||
|
mkdir -p dist
|
||||||
|
|
||||||
|
echo "Collecting binaries..."
|
||||||
|
|
||||||
|
# Linux binary
|
||||||
|
LINUX_BIN="target/x86_64-unknown-linux-gnu/release/unixtract"
|
||||||
|
if [ -f "$LINUX_BIN" ]; then
|
||||||
|
cp "$LINUX_BIN" "dist/unixtract-linux"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BIN_NAME="unixtract"
|
# Windows binary
|
||||||
DIST_DIR="dist"
|
WINDOWS_BIN="target/x86_64-pc-windows-gnu/release/unixtract.exe"
|
||||||
|
if [ -f "$WINDOWS_BIN" ]; then
|
||||||
|
cp "$WINDOWS_BIN" "dist/unixtract-windows.exe"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "==> Building ${BIN_NAME} for: ${TARGETS[*]}"
|
echo "Cleaning target directory..."
|
||||||
|
rm -rf target
|
||||||
|
|
||||||
mkdir -p "$DIST_DIR"
|
echo "Done. Binaries are in ./dist"
|
||||||
|
|
||||||
for target in "${TARGETS[@]}"; do
|
|
||||||
echo
|
|
||||||
echo "==> Target: $target"
|
|
||||||
|
|
||||||
# Ensure the target's std library is installed.
|
|
||||||
if ! rustup target list --installed | grep -qx "$target"; then
|
|
||||||
echo " Installing rust std for $target ..."
|
|
||||||
rustup target add "$target"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cargo build --release --target "$target"
|
|
||||||
|
|
||||||
# Work out the produced binary name (Windows targets get a .exe suffix).
|
|
||||||
case "$target" in
|
|
||||||
*windows*) src="target/$target/release/${BIN_NAME}.exe" ;;
|
|
||||||
*) src="target/$target/release/${BIN_NAME}" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ ! -f "$src" ]; then
|
|
||||||
echo " !! Expected binary not found: $src" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Friendly output name, e.g. unixtract-x86_64-pc-windows-gnu.exe
|
|
||||||
case "$target" in
|
|
||||||
*windows*) dst="$DIST_DIR/${BIN_NAME}-${target}.exe" ;;
|
|
||||||
*) dst="$DIST_DIR/${BIN_NAME}-${target}" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
cp "$src" "$dst"
|
|
||||||
echo " -> $dst"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "==> Done. Binaries are in ./${DIST_DIR}"
|
|
||||||
ls -la "$DIST_DIR"
|
|
||||||
Reference in New Issue
Block a user