Skip to content

Commit

Permalink
Fail ./dt helper script when invoked outside the project root
Browse files Browse the repository at this point in the history
  • Loading branch information
booniepepper committed Jul 13, 2023
1 parent 014ef71 commit 9177fcb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
14 changes: 14 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Developing

Hi friends, these are just some quick notes for anyone interested in developing
`dt` or building it from source.

The main development entrypoint right now is `./bin/build` which can compile, test,
and do cross-compilation as well.

## Requirements

Zig 0.11.*

Rust toolchain that's recent-ish

15 changes: 14 additions & 1 deletion dt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

set -eu

DT_ROOT="$(dirname "$0")"
DT="$DT_ROOT/zig-out/bin/dt"

# Running this outside the project root is likely an error:
if [[ $DT_ROOT != . ]]; then
>&2 echo "ERROR: $0 is intended to be run when developing dt."
>&2 echo "If you're just trying to run a dt built from source:"
>&2 echo "- Navigate to $DT_ROOT"
>&2 echo "- Run './build release' to compile a release executable (Requires Zig 0.11.*)"
>&2 echo "- Use the result at: $DT"
exit 1
fi

zig build \
&& >&2 echo 'INFO: dt compiled (zig build exited successfully)' \
&& exec rlwrap zig-out/bin/"$(basename "$0")" "$@"
&& exec rlwrap "$DT" "$@"

0 comments on commit 9177fcb

Please sign in to comment.