| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
| 4 | BUILD_FILE="$ROOT/build/game.js" |
| 5 | SRC_DIR="$ROOT/src" |
| 6 | |
| 7 | printf "Build started, output file: %s\n" "$BUILD_FILE" |
| 8 | rm -f "$BUILD_FILE" |
| 9 | |
| 10 | # Deterministic order (texture helpers before world/player/scene). |
| 11 | FILES=( |
| 12 | "$SRC_DIR/textureColumn.js" |
| 13 | "$SRC_DIR/levels.js" |
| 14 | "$SRC_DIR/tiles.js" |
| 15 | "$SRC_DIR/world.js" |
| 16 | "$SRC_DIR/player.js" |
| 17 | "$SRC_DIR/raycastScene.js" |
| 18 | "$SRC_DIR/main.js" |
| 19 | ) |
| 20 | |
| 21 | for file in "${FILES[@]}" |
| 22 | do |
| 23 | if [[ ! -f "$file" ]] |
| 24 | then |
| 25 | printf "Missing source file: %s\n" "$file" >&2 |
| 26 | exit 1 |
| 27 | fi |
| 28 | printf "\n/*\n * Start File:\n * %s\n */ \n" "$file" >> "$BUILD_FILE" |
| 29 | printf "Building %s\n" "$file" |
| 30 | cat "$file" >> "$BUILD_FILE" |
| 31 | printf "\n/*\n * End File:\n * %s\n */ \n" "$file" >> "$BUILD_FILE" |
| 32 | done |
| 33 | printf "DONE\n" |