BlueGit

projects-timfalken-com meteors

Files

meteors / src / build.sh

build.sh

build.sh 980 B Download Raw
1#!/usr/bin/env bash
2# Concatenate game sources into build/game.js, same pattern as raytracer / frameworkv3.
3set -euo pipefail
4ROOT="$(cd "$(dirname "$0")/.." && pwd)"
5BUILD_FILE="$ROOT/build/game.js"
6SRC_DIR="$ROOT/src"
7
8mkdir -p "$ROOT/build"
9
10printf "Build started, output file: %s\n" "$BUILD_FILE"
11rm -f "$BUILD_FILE"
12
13FILES=(
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
28for file in "${FILES[@]}"
29do
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"
39done
40
41printf "DONE\n"