#!/usr/bin/env bash

# Parse command line arguments.
set -euo pipefail
eval "$(claptrap --spec - -- "$@" <<SPEC
name: build.sh
args:
  windows:
    short: w
    long: windows
    action: set-true
    help: Build for Windows
  strict:
    short: s
    long: strict
    action: set-true
    help: Warnings as errors
SPEC
)"

# Set up local environment.
target=''
test "$claptrap_windows" = 'true' && target='--target=x86_64-pc-windows-gnu'
test "$claptrap_strict" = 'true' && export RUSTFLAGS='-D warnings'

# Build Rust debug and release target.
cargo build $target || exit
cargo build $target --release || exit
