#!/bin/bash
# Build the project for development.
# All command-line arguments are passed to the executed `cargo` command.
# Optional environment variables:
#   $RUN_NEW_TERMINAL
#     If this variable is not `0` or empty,
#     then the cargo command is executed in a new terminal.
#     DEFAULT: ""
#   $RUN_CARGO_CMD
#     The cargo sub-command to run.
#     DEFAULT: "build"

# shellcheck source=./util.sh
_dir="$( dirname "$0" )"
source "${_dir}/share.sh"
unset _dir

function build {
  check "cargo"
  cmd="cargo +$RUST_VERSION build --features amethyst/nightly $*"
  if should_run_in_terminal; then
    run_terminal "$cmd"
  else
    $cmd
  fi
}

build "$@"
