BlueGit

projects-timfalken-com allianties

Files

allianties / src / build.sh

build.sh

build.sh 1.6 KiB Download Raw
1#!/usr/bin/env bash
2# Concatenate sources into build/game.js and copy the PHP API into build/.
3# data/config.php and any sqlite are NEVER copied.
4set -euo pipefail
5ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6BUILD_FILE="$ROOT/build/game.js"
7SRC_DIR="$ROOT/src"
8
9mkdir -p "$ROOT/build"
10
11printf "Build started, output file: %s\n" "$BUILD_FILE"
12rm -f "$BUILD_FILE"
13
14FILES=(
15 "$SRC_DIR/i18n.js"
16 "$SRC_DIR/rules.js"
17 "$SRC_DIR/api.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 printf '%s' "var I18N_CATALOG = "
27 cat "$ROOT/server/lib/i18n.json"
28 printf ';\n'
29} >> "$BUILD_FILE"
30
31for file in "${FILES[@]}"
32do
33 if [[ ! -f "$file" ]]
34 then
35 printf "Missing source file: %s\n" "$file" >&2
36 exit 1
37 fi
38 printf "\n/*\n * Start File:\n * %s\n */ \n" "$file" >> "$BUILD_FILE"
39 printf "Building %s\n" "$file"
40 cat "$file" >> "$BUILD_FILE"
41 printf "\n/*\n * End File:\n * %s\n */ \n" "$file" >> "$BUILD_FILE"
42done
43
44SERVER="$ROOT/server"
45cp -f "$SERVER/api.php" "$SERVER/auth.php" "$SERVER/callback.php" \
46 "$SERVER/logout.php" "$SERVER/router.php" "$SERVER/.htaccess" \
47 "$ROOT/build/"
48mkdir -p "$ROOT/build/lib"
49cp -f "$SERVER/lib/bootstrap.php" "$SERVER/lib/Store.php" \
50 "$SERVER/lib/Engine.php" "$SERVER/lib/i18n.json" "$SERVER/lib/I18n.php" \
51 "$ROOT/build/lib/"
52mkdir -p "$ROOT/build/data"
53cp -f "$SERVER/data/.htaccess" "$ROOT/build/data/.htaccess"
54rm -f "$ROOT/build/data/config.php" "$ROOT/build/data/config.lock"
55rm -f "$ROOT/build/data/"*.sqlite "$ROOT/build/data/"*.sqlite-journal
56rm -rf "$ROOT/build/data/sessions"
57
58printf "DONE\n"