vk-graph 0.14.2

A high-performance Vulkan driver with automatic resource management and execution.
Documentation
#!/bin/sh

set -eu

ALLOW_DIRTY=0
MDBOOK_VERSION=0.5.3
RELEASE_MODE=0
RUN_SEMVER=0
RUN_VULKAN=1

for arg in "$@"; do
    case "$arg" in
        --allow-dirty)
            ALLOW_DIRTY=1
            ;;
        --release)
            RELEASE_MODE=1
            ;;
        --semver)
            RUN_SEMVER=1
            ;;
        --skip-vulkan)
            RUN_VULKAN=0
            ;;
        *)
            printf 'unknown argument: %s\n' "$arg" >&2
            exit 2
            ;;
    esac
done

if [ "$RELEASE_MODE" -eq 1 ]; then
    PROFILE="--release"
else
    PROFILE=""
fi

fail() {
    printf '%s\n' "$1" >&2
    exit "${2-1}"
}

run() {
    printf '==> %s\n' "$1"
    shift
    "$@"
}

install_mdbook() {
    version=$(mdbook --version 2>/dev/null | awk '{print $2}' || true)

    if [ "$version" != "$MDBOOK_VERSION" ]; then
        run "install mdbook ${MDBOOK_VERSION}" cargo install --locked mdbook --version "$MDBOOK_VERSION"
    fi
}

if [ "$ALLOW_DIRTY" -ne 1 ]; then
    git diff --no-ext-diff --quiet || fail "uncommitted changes (pass --allow-dirty to skip this check)"
fi

# Rust code checks
run "format check" cargo fmt --all --check
run "workspace target check" env RUSTFLAGS="-D warnings" cargo check $PROFILE --all-targets --workspace --no-default-features --features loaded
run "workspace target check (parking_lot)" env RUSTFLAGS="-D warnings" cargo check $PROFILE --all-targets --workspace --features parking_lot
run "workspace clippy" cargo clippy $PROFILE --all-targets --workspace --no-default-features --features loaded -- -D warnings
run "workspace clippy (parking_lot)" cargo clippy $PROFILE --all-targets --workspace --features parking_lot -- -D warnings
run "workspace clippy (no checked)" cargo clippy $PROFILE --all-targets --workspace --no-default-features --features "loaded,parking_lot" -- -D warnings
run "workspace tests" env RUSTFLAGS="-D warnings" cargo test $PROFILE --all-targets --workspace --no-default-features --features loaded

if [ "$RUN_VULKAN" -eq 1 ]; then
    run "vulkan tests" env RUSTFLAGS="-D warnings" cargo test $PROFILE --workspace vulkan -- --ignored --test-threads=1
fi

run "workspace doctests" env RUSTFLAGS="-D warnings" cargo test $PROFILE --workspace --doc
run "workspace docs" env RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps
run "guide hot doctests" env RUSTFLAGS="-D warnings" cargo test -p guide --features hot

# Build guide book
install_mdbook
run "guide build" mdbook build guide/

if [ "$RUN_SEMVER" -eq 1 ]; then
    # Check for semver breaking changes: if this fails you must update the crate version or fix the code
    run "semver check (vk-graph)" cargo semver-checks check-release -p vk-graph --default-features
    run "semver check (vk-graph-egui)" cargo semver-checks check-release -p vk-graph-egui
    run "semver check (vk-graph-fx)" cargo semver-checks check-release -p vk-graph-fx
    run "semver check (vk-graph-hot)" cargo semver-checks check-release -p vk-graph-hot
    run "semver check (vk-graph-imgui)" cargo semver-checks check-release -p vk-graph-imgui
    run "semver check (vk-graph-window)" cargo semver-checks check-release -p vk-graph-window
fi

printf 'OK\n'