Skip to content

Commit

Permalink
Merge pull request #1146 from hacspec/setup-sh-clean
Browse files Browse the repository at this point in the history
Improve `setup.sh`
  • Loading branch information
W95Psp authored Nov 27, 2024
2 parents 7bb4c28 + c297dc5 commit acc109b
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -eu
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

opam_jobs=4
CLEANUP_WORKSPACE=on

# Parse command line arguments.
all_args=("$@")
Expand All @@ -14,12 +15,35 @@ while [ $# -gt 0 ]; do
opam_jobs=$2
shift
;;
--no-cleanup)
CLEANUP_WORKSPACE=off
;;
--help)
echo "hax setup script"
echo ""
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo ' -j <JOBS> The number of opam jobs to run in parallel'
echo ' --no-cleanup Disables the default behavior that runs `cargo clean` and `dune clean`'
exit
;;
esac
shift
done

# Cleanup the cargo and dune workspace, to make sure we are in a clean
# state
cleanup_workspace() {
cargo clean
(
cd engine
dune clean
)
}

# Warns if we're building in a dirty checkout of hax: while hacking on
# hax, we should really be using the `./.utils/rebuild.sh`
# hax, we should really be using `just build`.
warn_if_dirty() {
(
cd "$SCRIPTPATH"
Expand Down Expand Up @@ -86,6 +110,10 @@ install_ocaml_engine() {
)
}

if [ "$CLEANUP_WORKSPACE" = "on" ]; then
cleanup_workspace
fi

warn_if_dirty

for binary in opam node rustup jq; do
Expand Down

0 comments on commit acc109b

Please sign in to comment.