# quiet all recipies by default
set quiet

CRATES_DIR := `jq -r '."CRATES_DIR"' 00_config.json`
OUTPUT_BASE_DIR := `jq -r '."OUTPUT_BASE_DIR"' 00_config.json`
RUSTC_PLUGIN_TOOLCHAIN := `jq -r '."RUSTC_PLUGIN_TOOLCHAIN"' 00_config.json`

default:
  just --list

install:
  #!/usr/bin/env bash
  RUSTUP_TOOLCHAIN={{RUSTC_PLUGIN_TOOLCHAIN}} cargo install --debug --force --locked --path . \
    --bin cargo-equity-extractor --bin equity-extractor-driver

  CARGO_HOME=${CARGO_HOME:-"$HOME/.cargo"}
  patchelf --add-rpath \
    ${RUSTUP_HOME:-"$HOME/.rustup"}/toolchains/{{RUSTC_PLUGIN_TOOLCHAIN}}-x86_64-unknown-linux-gnu/lib \
    ${CARGO_HOME:-"$HOME/.cargo"}/bin/equity-extractor-driver

build: install

test-all: install
  #!/usr/bin/env bash
  # use sccache
  export CARGO_INCREMENTAL=0 
  export RUSTC_WRAPPER=$(which sccache) 
  cargo t --lib -- --test-threads=1 -Z unstable-options --report-time
  send_slack_notification.sh done

# debug single test
test-dbg name: install
  #!/usr/bin/env bash
  # use sccache
  export CARGO_INCREMENTAL=0 
  export RUSTC_WRAPPER=$(which sccache) 
  RUST_LOG=${RUST_LOG:-trace} cargo t --lib {{name}} -- --test-threads=1 --nocapture -Z unstable-options --report-time
  send_slack_notification.sh done
