review

review patchsets using your default editor
Log | Files | Refs

justfile (2905B)


      1 # Standard recipes: build (debug), release, clean, test, install.
      2 # review is the Odin binary; review-go and review-vet are the Go sidecars
      3 # (the Go parser, and go vet's multichecker) and odin-review-extract the
      4 # Odin one. install ships all four beside each other on PATH. The Odin
      5 # packages need the jm collection at ~/Source/Personal/jm.
      6 
      7 odin := env("ODIN", "odin")
      8 flags := "-vet -strict-style -collection:jm=" + home_directory() / "Source" / "Personal" / "jm"
      9 packages := "txt frontend git tree change finding report check analyser job provider cache reviewer hook bench"
     10 
     11 # `just` alone lists the recipes.
     12 default:
     13     @just --list --unsorted
     14 
     15 # Debug build: symbols kept, for delve and stack traces.
     16 build:
     17     mkdir -p build
     18     {{odin}} build review {{flags}} -debug -sanitize:address -out:build/review
     19     {{odin}} build sidecar/odin {{flags}} -debug -out:build/odin-review-extract
     20     go build -o build/review-go ./sidecar/gofront
     21     go build -C sidecar/govet -o ../../build/review-vet .
     22 
     23 # Optimised build: stripped, reproducible paths.
     24 release:
     25     mkdir -p build
     26     {{odin}} build review {{flags}} -o:speed -out:build/review
     27     {{odin}} build sidecar/odin {{flags}} -o:speed -out:build/odin-review-extract
     28     go build -trimpath -ldflags='-s -w' -o build/review-go ./sidecar/gofront
     29     go build -C sidecar/govet -trimpath -ldflags='-s -w' -o ../../build/review-vet .
     30 
     31 # Type-check, then run every package's tests and the Go sidecar's.
     32 test:
     33     #!/usr/bin/env bash
     34     set -euo pipefail
     35     mkdir -p build/test
     36     for p in {{packages}}; do
     37         {{odin}} test $p {{flags}} -sanitize:address -out:build/test/$p
     38     done
     39     go vet ./... && go test ./...
     40 
     41 # Remove build output and the Go build cache for this module.
     42 clean:
     43     rm -rf build
     44     go clean
     45 
     46 # Copy the release binaries to a directory on PATH. An installed review is
     47 # replaced in place; otherwise ~/.local/bin, ~/bin, GOBIN, GOPATH/bin,
     48 # /usr/local/bin, else the first writable PATH entry.
     49 install: release
     50     #!/usr/bin/env bash
     51     set -euo pipefail
     52     dest=""
     53     if existing=$(command -v review 2>/dev/null) && [[ -w ${existing%/*} ]]; then
     54         dest=${existing%/*}
     55     fi
     56     gopath=$(go env GOPATH 2>/dev/null || true); gobin=$(go env GOBIN 2>/dev/null || true)
     57     for d in "$HOME/.local/bin" "$HOME/bin" "$gobin" "${gopath:+$gopath/bin}" /usr/local/bin; do
     58         [[ -z $dest && -n $d && -d $d && -w $d && ":$PATH:" == *":$d:"* ]] && dest=$d
     59     done
     60     if [[ -z $dest ]]; then
     61         IFS=: read -ra dirs <<<"$PATH"
     62         for d in "${dirs[@]}"; do [[ -d $d && -w $d ]] && { dest=$d; break; }; done
     63     fi
     64     [[ -n $dest ]] || { echo "install: no writable directory on PATH" >&2; exit 1; }
     65     for bin in review review-go review-vet odin-review-extract; do
     66         install -m 755 build/$bin "$dest/$bin"
     67     done
     68     echo "installed review, review-go, review-vet and odin-review-extract into $dest"