BlueGit

projects-timfalken-com allianties

Files

allianties / src / build.sh

build.sh

build.sh 1.7 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/avatar.js"
19 "$SRC_DIR/main.js"
20)
21
22{
23 printf '%s\n' "/*"
24 printf '%s\n' " * AUTO-GENERATED FILE — DO NOT EDIT BY HAND."
25 printf '%s\n' " * Built by src/build.sh from the sources in src/."
26 printf '%s\n' " */"
27 printf '%s' "var I18N_CATALOG = "
28 cat "$ROOT/server/lib/i18n.json"
29 printf ';\n'
30} >> "$BUILD_FILE"
31
32for file in "${FILES[@]}"
33do
34 if [[ ! -f "$file" ]]
35 then
36 printf "Missing source file: %s\n" "$file" >&2
37 exit 1
38 fi
39 printf "\n/*\n * Start File:\n * %s\n */ \n" "$file" >> "$BUILD_FILE"
40 printf "Building %s\n" "$file"
41 cat "$file" >> "$BUILD_FILE"
42 printf "\n/*\n * End File:\n * %s\n */ \n" "$file" >> "$BUILD_FILE"
43done
44
45SERVER="$ROOT/server"
46cp -f "$SERVER/api.php" "$SERVER/auth.php" "$SERVER/callback.php" \
47 "$SERVER/logout.php" "$SERVER/router.php" "$SERVER/.htaccess" \
48 "$ROOT/build/"
49mkdir -p "$ROOT/build/lib"
50cp -f "$SERVER/lib/bootstrap.php" "$SERVER/lib/Store.php" \
51 "$SERVER/lib/Engine.php" "$SERVER/lib/i18n.json" "$SERVER/lib/I18n.php" \
52 "$ROOT/build/lib/"
53mkdir -p "$ROOT/build/data"
54cp -f "$SERVER/data/.htaccess" "$ROOT/build/data/.htaccess"
55rm -f "$ROOT/build/data/config.php" "$ROOT/build/data/config.lock"
56rm -f "$ROOT/build/data/"*.sqlite "$ROOT/build/data/"*.sqlite-journal
57rm -rf "$ROOT/build/data/sessions"
58
59printf "DONE\n"