# justfile
# `just build[-all]` -> dev, or `just --set profile release build[-all]` -> release

profile := "debug"

[private]
default: list

# List all recipes.
list:
    just --list

# Build with `just build` -> dev, or `just --set profile release build` -> release
build:
    clear
    cargo build {{ if profile == "release" { "--release" } else { "" } }}

# Build with `just build-all` -> dev, or `just --set profile release build-all` -> release
build-all: cross-linux cross-windows cross-macos-x64 cross-macos-aarch64

# Clear cache, delete temps, and I think it also deletes the built files.
clean:
    cargo clean

# Reformat the code as defined in the style guide.
fmt:
    cargo fmt

# Add all unignored files to git and make a commit with MESSAGE as the commit message.
commit *MESSAGE="Unlabeled commit.": ci
    git add .
    git commit -m "{{ MESSAGE }}"

# Push commits to remote repository.
push:
    git push -u origin main

# Pull commits from remote repository.
pull:
    git pull

# Run `cargo check`, `cargo fmt --check`, `cargo clippy -- -D warnings` and same with `-W clippy::pedantic`, `cargo test`, and `cargo build`.
ci:
    clear
    cargo check
    cargo check --no-default-features
    cargo check --features=simple
    cargo check --features=dashmap
    cargo check --features=serde
    cargo check --all-features
    cargo fmt --check
    cargo clippy -- -D warnings
    cargo clippy -- -D warnings -W clippy::pedantic
    cargo clippy --no-default-features -- -D warnings
    cargo clippy --no-default-features -- -D warnings -W clippy::pedantic
    cargo clippy --features=simple -- -D warnings
    cargo clippy --features=simple -- -D warnings -W clippy::pedantic
    cargo clippy --features=dashmap -- -D warnings
    cargo clippy --features=dashmap -- -D warnings -W clippy::pedantic
    cargo clippy --features=serde -- -D warnings
    cargo clippy --features=serde -- -D warnings -W clippy::pedantic
    cargo clippy --all-features -- -D warnings
    cargo clippy --all-features -- -D warnings -W clippy::pedantic
    cargo test
    cargo test --no-default-features
    cargo test --features=simple
    cargo test --features=dashmap
    cargo test --features=serde
    cargo test --all-features
    cargo build
    cargo build --no-default-features
    cargo build --features=simple
    cargo build --features=dashmap
    cargo build --features=serde
    cargo build --all-features

publish-dry-run: ci
    cargo publish -p dogsoap --dry-run

publish-for-real: publish-dry-run
    cargo publish -p dogsoap

# Added target with `rustup target add x86_64-unknown-linux-gnu`
[private]
cross-linux:
    cargo build --target x86_64-unknown-linux-gnu {{ if profile == "release" { "--release" } else { "" } }}

# Added target with `rustup target add x86_64-pc-windows-gnu`
[private]
cross-windows:
    cargo build --target x86_64-pc-windows-gnu {{ if profile == "release" { "--release" } else { "" } }}

# Added target with `rustup target add x86_64-apple-darwin`
[private]
cross-macos-x64:
    cargo build --target x86_64-apple-darwin {{ if profile == "release" { "--release" } else { "" } }}

# Added target with `rustup target add aarch64-apple-darwin`
[private]
cross-macos-aarch64:
    cargo build --target aarch64-apple-darwin {{ if profile == "release" { "--release" } else { "" } }}
