From 3159397a817aedc9bc84b7a88c148d680cf3e42f Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Wed, 27 Nov 2024 16:17:57 +0100 Subject: [PATCH 1/5] misc(setup.sh): `rebuild.sh` -> `just build` --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index a20542e0f..23f9de20e 100755 --- a/setup.sh +++ b/setup.sh @@ -19,7 +19,7 @@ while [ $# -gt 0 ]; do done # 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" From 1dc71b068bc4860004d3e122bd2700c072522dfd Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Wed, 27 Nov 2024 16:23:52 +0100 Subject: [PATCH 2/5] feat(setup.sh): cleanup cargo & dune by default, add a `--no-cleanup` flag --- setup.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/setup.sh b/setup.sh index 23f9de20e..18101ff36 100755 --- a/setup.sh +++ b/setup.sh @@ -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=("$@") @@ -14,10 +15,23 @@ while [ $# -gt 0 ]; do opam_jobs=$2 shift ;; + --no-cleanup) + CLEANUP_WORKSPACE=off + ;; 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 `just build`. warn_if_dirty() { @@ -86,6 +100,10 @@ install_ocaml_engine() { ) } +if [ "$CLEANUP_WORKSPACE" = "on" ]; then + cleanup_workspace +fi + warn_if_dirty for binary in opam node rustup jq; do From c297dc516a80457403b070ec42771dade92b9213 Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Wed, 27 Nov 2024 16:27:24 +0100 Subject: [PATCH 3/5] feat(setup.sh): add `--help` message --- setup.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/setup.sh b/setup.sh index 18101ff36..2e592d1a6 100755 --- a/setup.sh +++ b/setup.sh @@ -18,6 +18,16 @@ while [ $# -gt 0 ]; do --no-cleanup) CLEANUP_WORKSPACE=off ;; + --help) + echo "hax setup script" + echo "" + echo "Usage: $0 [OPTIONS]" + echo "" + echo "Options:" + echo ' -j 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 From 62366a44c995976c12f440f1276170d64a1a68af Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Wed, 27 Nov 2024 16:54:13 +0100 Subject: [PATCH 4/5] fix(setup.sh): clean: use opam, not dune --- setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 2e592d1a6..b68f24119 100755 --- a/setup.sh +++ b/setup.sh @@ -25,7 +25,7 @@ while [ $# -gt 0 ]; do echo "" echo "Options:" echo ' -j The number of opam jobs to run in parallel' - echo ' --no-cleanup Disables the default behavior that runs `cargo clean` and `dune clean`' + echo ' --no-cleanup Disables the default behavior that runs `cargo clean` and `opam clean`' exit ;; esac @@ -38,7 +38,7 @@ cleanup_workspace() { cargo clean ( cd engine - dune clean + opam clean ) } From 37fee7aa188c72687d49e6261516818866d01ea5 Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Wed, 27 Nov 2024 16:54:39 +0100 Subject: [PATCH 5/5] fix(setup.sh): first check for binaries, then do cleanup --- setup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index b68f24119..607661a42 100755 --- a/setup.sh +++ b/setup.sh @@ -110,10 +110,6 @@ install_ocaml_engine() { ) } -if [ "$CLEANUP_WORKSPACE" = "on" ]; then - cleanup_workspace -fi - warn_if_dirty for binary in opam node rustup jq; do @@ -121,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