mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-14 02:43:16 +00:00
Add Common Build Tooling ## Information for Developers On Windows, the build scripts will automatically install Node. Other platforms should use their package manager or download it from https://nodejs.org/en/download/ Pick one: - VSCode: `Ctrl+Shift+B` - VSCode: `F5` (build & run with debugger) or `Ctrl+F5` (build & run without debugger) - Windows: double-click root `Build.bat` (pause to see output) or `tools/build/build.bat` (no pause) - Git Bash and non-Windows: `tools/build/build` ## Information for Server Admins - TGS scripts will automatically install the version of Node specified in `dependencies.sh` - Either use this build script, or compile tgui by running any script in `tgui/bin` folder. ## Details Both dm and tgui are now built with a single script. It's pretty easy to launch: just press `Ctrl+Shift+B` in VSCode, and tada! 🎉 **It's smart.** It will skip certain steps if source files were untouched for that step. So, if you're only touching dm code, it will only rebuild dm code, and will skip tgui. **Syntax is fairly readable and maintainable.** ```js const { Task, runTasks, exec } = require('./cbt'); const taskTgui = new Task('tgui') .depends('tgui/yarn.lock') .depends('tgui/packages/**/*.js') .provides('tgui/public/*.bundle.*') .provides('tgui/public/*.chunk.*') .build(async () => { await exec('tgui/bin/tgui'); }); runTasks([taskTgui]); ``` **This is a long term solution to the js bundle hell.** Now that we have a single script to build everything, bundles have been excluded from the repo, and they will no longer cause conflicts in PRs. This results in quicker PR turnaround time and less time wasted on rebuilding tgui for PRs. **CI pipelines have been updated.** They're not coded in the most optimal way, just making them green for now. ## Possible future work - Support compiling with DM defines by passing them as an argument, like `-D LOWMEMORYMODE`. - Instead of explicitly listing the task sequence in `runTasks()`, support specifying tasks in `.depends()`, which in turn will allow building a graph of dependencies and running things in parallel. Co-authored-by: Tad Hardesty <tad@platymuus.com> - Add root Build.bat - Add trio of tools/bootstrap/ scripts for Node - Add tools/build/README.md - Ensure build script and VSC configuration works properly on Linux - Update TGS4 PreCompile scripts Co-authored-by: Jordan Brown <Cyberboss@users.noreply.github.com> - Keep PreCompile scripts compatible with TGS3 as well - Update LinuxOneShot PreCompile scripts - Update TGS4 configuration
92 lines
3.4 KiB
Bash
92 lines
3.4 KiB
Bash
#!/bin/bash
|
|
|
|
# REPO MAINTAINERS: KEEP CHANGES TO THIS IN SYNC WITH /tools/tgs4_scripts/PreCompile.sh
|
|
|
|
set -e
|
|
set -x
|
|
|
|
#load dep exports
|
|
#need to switch to game dir for Dockerfile weirdness
|
|
original_dir=$PWD
|
|
cd "$1"
|
|
. dependencies.sh
|
|
cd "$original_dir"
|
|
|
|
#find out what we have (+e is important for this)
|
|
set +e
|
|
has_git="$(command -v git)"
|
|
has_cargo="$(command -v ~/.cargo/bin/cargo)"
|
|
has_sudo="$(command -v sudo)"
|
|
has_grep="$(command -v grep)"
|
|
DATABASE_EXISTS="$(mysqlshow --host mariadb --port 3306 --user=root --password=$MYSQL_ROOT_PASSWORD ss13_db| grep -v Wildcard | grep -o ss13_db)"
|
|
set -e
|
|
|
|
# install cargo if needful
|
|
if ! [ -x "$has_cargo" ]; then
|
|
echo "Installing rust..."
|
|
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-host i686-unknown-linux-gnu
|
|
. ~/.profile
|
|
fi
|
|
|
|
# apt packages, libssl needed by rust-g but not included in TGS barebones install
|
|
if ! { [ -x "$has_git" ] && [ -x "$has_grep" ] && [ -f "/usr/lib/i386-linux-gnu/libssl.so" ] && [ -f "/usr/bin/mysql" ] && [ -d "/usr/include/mysql" ]; }; then
|
|
echo "Installing apt dependencies..."
|
|
if ! [ -x "$has_sudo" ]; then
|
|
dpkg --add-architecture i386
|
|
apt-get update
|
|
apt-get install -y git libssl-dev:i386 grep mysql-client lib32z1 pkg-config libssl-dev
|
|
rm -rf /var/lib/apt/lists/*
|
|
else
|
|
sudo dpkg --add-architecture i386
|
|
sudo apt-get update
|
|
sudo apt-get install -y git libssl-dev:i386 grep mysql-client lib32z1 pkg-config libssl-dev
|
|
sudo rm -rf /var/lib/apt/lists/*
|
|
fi
|
|
fi
|
|
|
|
#update rust-g
|
|
if [ ! -d "rust-g" ]; then
|
|
echo "Cloning rust-g..."
|
|
git clone https://github.com/tgstation/rust-g
|
|
else
|
|
echo "Fetching rust-g..."
|
|
cd rust-g
|
|
git fetch
|
|
cd ..
|
|
fi
|
|
|
|
echo "Deploying rust-g..."
|
|
cd rust-g
|
|
git checkout "$RUST_G_VERSION"
|
|
env PKG_CONFIG_ALLOW_CROSS=1 ~/.cargo/bin/cargo build --release --target=i686-unknown-linux-gnu
|
|
mv target/i686-unknown-linux-gnu/release/librust_g.so "$1/librust_g.so"
|
|
cd ..
|
|
|
|
# compile tgui
|
|
echo "Compiling tgui..."
|
|
cd "$1"
|
|
chmod +x tools/bootstrap/node # Workaround for https://github.com/tgstation/tgstation-server/issues/1167
|
|
env TG_BOOTSTRAP_CACHE="$original_dir" TG_BOOTSTRAP_NODE_LINUX=1 TG_BUILD_TGS_MODE=1 tools/bootstrap/node tools/build/build.js
|
|
cd "$original_dir"
|
|
|
|
if [ ! -d "../GameStaticFiles/config" ]; then
|
|
echo "Creating initial config..."
|
|
cp -r "$1/config" "../GameStaticFiles/config"
|
|
echo -e "SQL_ENABLED\nFEEDBACK_TABLEPREFIX SS13_\nADDRESS mariadb\nPORT 3306\nFEEDBACK_DATABASE ss13_db\nFEEDBACK_LOGIN root\nFEEDBACK_PASSWORD $MYSQL_ROOT_PASSWORD\nASYNC_QUERY_TIMEOUT 10\nBLOCKING_QUERY_TIMEOUT 5\nBSQL_THREAD_LIMIT 50" > "../GameStaticFiles/config/dbconfig.txt"
|
|
echo "$TGS_ADMIN_CKEY = Host" > "../GameStaticFiles/config/admins.txt"
|
|
fi
|
|
|
|
if [ "$DATABASE_EXISTS" != "ss13_db" ]; then
|
|
echo "Creating initial SS13 database..."
|
|
mysql -u root --password=$MYSQL_ROOT_PASSWORD -h mariadb -P 3306 -e 'CREATE DATABASE IF NOT EXISTS ss13_db;'
|
|
cat "$1/$TGS_PREFIXED_SCHEMA_FILE"
|
|
mysql -u root --password=$MYSQL_ROOT_PASSWORD -h mariadb -P 3306 ss13_db < "$1/$TGS_PREFIXED_SCHEMA_FILE"
|
|
mysql -u root --password=$MYSQL_ROOT_PASSWORD -h mariadb -P 3306 ss13_db -e "INSERT INTO \`SS13_schema_revision\` (\`major\`, \`minor\`) VALUES ($TGS_SCHEMA_MAJOR_VERSION, $TGS_SCHEMA_MINOR_VERSION)"
|
|
fi
|
|
|
|
# compile tgui
|
|
echo "Compiling tgui..."
|
|
cd "$1"
|
|
chmod +x tools/bootstrap/node # Workaround for https://github.com/tgstation/tgstation-server/issues/1167
|
|
chmod +x tgui/bin/tgui
|
|
env TG_BOOTSTRAP_CACHE="$original_dir" TG_BOOTSTRAP_NODE_LINUX=1 TG_BUILD_TGS_MODE=1 tools/bootstrap/node tools/build/build.js |