[tools]
cargo = "latest"
rust = "latest"
zig = "latest"

[tasks.rustup]
run = "rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu x86_64-unknown-linux-musl aarch64-unknown-linux-musl x86_64-apple-darwin aarch64-apple-darwin x86_64-pc-windows-gnu"

[tasks.npmgenerate]
run = "cargo npm generate --clean"

[tasks.npmzigbuild]
depends = ["npmgenerate", "rustup"]
run = '''
#!/usr/bin/env bash
set -euo pipefail

if [[ "$(uname -s)" == "Linux" ]]; then
  cargo zigbuild --release --locked \
    --target x86_64-unknown-linux-gnu \
    --target aarch64-unknown-linux-gnu \
    --target x86_64-unknown-linux-musl \
    --target aarch64-unknown-linux-musl \
    --target x86_64-pc-windows-gnu
else
  cargo zigbuild --release --locked \
    --target x86_64-unknown-linux-gnu \
    --target aarch64-unknown-linux-gnu \
    --target x86_64-unknown-linux-musl \
    --target aarch64-unknown-linux-musl \
    --target x86_64-apple-darwin \
    --target aarch64-apple-darwin \
    --target x86_64-pc-windows-gnu
fi
'''

