#!/usr/bin/env bash set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" JOBS="${JOBS:-1}" HOST="${HOST:-x86_64-w64-mingw32}" PREFIX="$ROOT/depends/$HOST" NATIVE_BIN="$PREFIX/native/bin" PROTOBUF_VERSION="${PROTOBUF_VERSION:-2.6.1}" PROTOBUF_SOURCE="$ROOT/depends/sources/protobuf-$PROTOBUF_VERSION.tar.bz2" PROTOBUF_BUILD="${PROTOBUF_BUILD:-/tmp/agrarian-protobuf-$PROTOBUF_VERSION-native}" require_cmd() { if ! command -v "$1" >/dev/null 2>&1; then echo "Missing required command: $1" >&2 exit 1 fi } require_path() { if [[ ! -e "$1" ]]; then echo "Missing required path: $1" >&2 exit 1 fi } copy_first_match() { local name="$1" local match match="$(find "$ROOT/depends/work/build/$HOST" -path "*/qtbase/bin/$name" -type f | sort | tail -n 1 || true)" if [[ -z "$match" ]]; then echo "Could not find Qt host tool after depends build: $name" >&2 exit 1 fi cp "$match" "$NATIVE_BIN/$name" } ensure_posix_mingw() { require_cmd "$HOST-g++" if ! "$HOST-g++" --version | head -n 1 | grep -qi posix; then cat >&2 <