Skip to content

Commit 9758a2a

Browse files
authored
Update few scripts (#2572)
* add [`--semaphore`](https://discord.com/channels/1260717118576525372/1260717118576525376/1410352637701914718) to Cabal invocations * remove Stack option from tutorial autoplay script * add `playtest.sh` script which builds swarm with `-O0` but dependencies with `-O1` * remove sublibraries script as we now have `cabal target`
1 parent 5cc7b1d commit 9758a2a

File tree

5 files changed

+30
-26
lines changed

5 files changed

+30
-26
lines changed

scripts/autoplay-tutorials.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
#!/usr/bin/env bash
2+
set -euo pipefail
23

3-
cd $(git rev-parse --show-toplevel)
4-
5-
if command -v stack &> /dev/null; then
6-
SWARM="stack exec swarm --"
7-
else
8-
SWARM="cabal run -j -O0 swarm --"
9-
fi
4+
cd "$(git rev-parse --show-toplevel)"
105

116
for tutorial in $(cat scenarios/Tutorials/00-ORDER.txt | xargs); do
127
echo -n "$tutorial"
13-
$SWARM -i "scenarios/Tutorials/$tutorial" --autoplay --cheat;
8+
scripts/play.sh -i "scenarios/Tutorials/$tutorial" --autoplay --cheat;
149
echo -en "\tCONTINUE [Y/n]: "
15-
read answer;
10+
read -r answer;
1611
case "${answer:0:1}" in
1712
n|N )
1813
exit 1

scripts/build-game.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/bin/bash -ex
1+
#!/usr/bin/env bash
2+
set -euo pipefail
23

3-
cd $(git rev-parse --show-toplevel)
4+
cd "$(git rev-parse --show-toplevel)"
45

56
# NOTE: There are several executables within the swarm.cabal project.
67
# If you only want to play the swarm game, you should specify an explicit
7-
# target 'swarm:exe:swarm' to the 'stack' command, to avoid building
8+
# target 'swarm:exe:swarm' to the 'cabal' command, to avoid building
89
# extra dependencies.
9-
10-
cabal build -j -O0 swarm:exe:swarm
10+
cabal build -j --semaphore swarm:exe:swarm

scripts/gen/list-sublibraries.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/play.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/bin/bash -ex
1+
#!/usr/bin/env bash
2+
set -euo pipefail
23

3-
cd $(git rev-parse --show-toplevel)
4+
cd "$(git rev-parse --show-toplevel)"
45

5-
# This compiles without optimizations and then runs the resulting executable.
6-
# It's been observed in certain versions of GHC that compiling with optimizations
7-
# results in the swarm UI freezing for a potentially long time upon starting a scenario.
8-
# See https://github.com/swarm-game/swarm/issues/1000#issuecomment-1378632269
9-
scripts/build-game.sh && cabal run -j -O0 swarm:exe:swarm -- "$@"
6+
# This compiles with optimizations and then runs the resulting executable.
7+
# Building with optimizations takes longer, but is noticeable when running
8+
# scenarios with swarms of robots.
9+
cabal run -j --semaphore swarm:exe:swarm -- "$@"

scripts/playtest.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -xeuo pipefail
3+
4+
cd "$(git rev-parse --show-toplevel)"
5+
6+
# This compiles the dependencies with optimizations (as they are not built frequently)
7+
# and then builds the swarm executable without optimizations.
8+
# Expect the game to run slow with many robots, but most scenarios are fine.
9+
# This is the development workflow when making changes to the game.
10+
11+
cabal build -j --semaphore swarm:exe:swarm --dependencies-only
12+
cabal run swarm:exe:swarm -O0 -- "$@"
13+
14+
# PS: Don't forget to also run tests and at least build benchmarks or the CI will catch you ;)

0 commit comments

Comments
 (0)