Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve setup.sh #1146

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 `opam 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
opam 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 @@ -93,5 +117,9 @@ for binary in opam node rustup jq; do
done
ensure_node_is_recent_enough

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

install_rust_binaries
install_ocaml_engine