# map trenchbroom game folder to here:
# see https://trenchbroom.github.io/manual/latest/#game_configuration_files
tb_setup_mac:
    mkdir -p "$HOME/Library/Application Support/TrenchBroom/games/hedz" | true
    ln -s $(pwd)/trenchbroom/hedz/hedz.fgd "$HOME/Library/Application Support/TrenchBroom/games/hedz/hedz.fgd" | true
    ln -s $(pwd)/trenchbroom/hedz/GameConfig.cfg "$HOME/Library/Application Support/TrenchBroom/games/hedz/GameConfig.cfg" | true

client_args := "--bin hedz_reloaded --no-default-features --features shared/client"
server_args := "--bin server --no-default-features --features shared/server"

run *args:
    cargo b {{server_args}}
    RUST_BACKTRACE=1 cargo r {{client_args}} -- {{args}}

client *args:
    RUST_BACKTRACE=1 cargo r {{client_args}} -- {{args}}

server:
    RUST_BACKTRACE=1 cargo r {{server_args}}

dbg *args:
    cargo b {{server_args}},dbg
    RUST_BACKTRACE=1 cargo r {{client_args}},dbg -- {{args}}

dbg-client *args:
    RUST_BACKTRACE=1 cargo r {{client_args}},dbg -- {{args}}

dbg-server:
    RUST_BACKTRACE=1 cargo r {{server_args}},dbg

sort:
    cargo sort --check --workspace

check:
    cargo sort --check --workspace
    cargo fmt --check
    cargo b {{client_args}}
    cargo b {{server_args}}
    cargo clippy {{client_args}}
    cargo clippy {{server_args}}
    cargo test {{client_args}}
    cargo test {{server_args}}
