BlueGit

projects-timfalken-com meteors

Files

meteors / src / build.sh

build.sh

build.sh 958 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/gameCore.js"
17 "$SRC_DIR/main.js"
18)
19
20{
21 printf '%s\n' "/*"
22 printf '%s\n' " * AUTO-GENERATED FILE — DO NOT EDIT BY HAND."
23 printf '%s\n' " * Built by src/build.sh from the sources in src/."
24 printf '%s\n' " */"
25} >> "$BUILD_FILE"
26
27for file in "${FILES[@]}"
28do
29 if [[ ! -f "$file" ]]
30 then
31 printf "Missing source file: %s\n" "$file" >&2
32 exit 1
33 fi
34 printf "\n/*\n * Start File:\n * %s\n */ \n" "$file" >> "$BUILD_FILE"
35 printf "Building %s\n" "$file"
36 cat "$file" >> "$BUILD_FILE"
37 printf "\n/*\n * End File:\n * %s\n */ \n" "$file" >> "$BUILD_FILE"
38done
39
40printf "DONE\n"