| 1 | #!/usr/bin/env bash |
| 2 | # Concatenate game sources into build/game.js, same pattern as raytracer / frameworkv3. |
| 3 | set -euo pipefail |
| 4 | ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
| 5 | BUILD_FILE="$ROOT/build/game.js" |
| 6 | SRC_DIR="$ROOT/src" |
| 7 | |
| 8 | mkdir -p "$ROOT/build" |
| 9 | |
| 10 | printf "Build started, output file: %s\n" "$BUILD_FILE" |
| 11 | rm -f "$BUILD_FILE" |
| 12 | |
| 13 | FILES=( |
| 14 | "$SRC_DIR/rng.js" |
| 15 | "$SRC_DIR/planet.js" |
| 16 | "$SRC_DIR/easing.js" |
| 17 | "$SRC_DIR/gameCore.js" |
| 18 | "$SRC_DIR/main.js" |
| 19 | ) |
| 20 | |
| 21 | { |
| 22 | printf '%s\n' "/*" |
| 23 | printf '%s\n' " * AUTO-GENERATED FILE — DO NOT EDIT BY HAND." |
| 24 | printf '%s\n' " * Built by src/build.sh from the sources in src/." |
| 25 | printf '%s\n' " */" |
| 26 | } >> "$BUILD_FILE" |
| 27 | |
| 28 | for file in "${FILES[@]}" |
| 29 | do |
| 30 | if [[ ! -f "$file" ]] |
| 31 | then |
| 32 | printf "Missing source file: %s\n" "$file" >&2 |
| 33 | exit 1 |
| 34 | fi |
| 35 | printf "\n/*\n * Start File:\n * %s\n */ \n" "$file" >> "$BUILD_FILE" |
| 36 | printf "Building %s\n" "$file" |
| 37 | cat "$file" >> "$BUILD_FILE" |
| 38 | printf "\n/*\n * End File:\n * %s\n */ \n" "$file" >> "$BUILD_FILE" |
| 39 | done |
| 40 | |
| 41 | printf "DONE\n" |
projects-timfalken-com meteors