From 5a214c16f8dc20c15fd6ca2e7beb1b6c049b308d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Wed, 17 Jan 2024 04:31:41 +0300 Subject: [PATCH] add build automation scripts --- dist/BUILD_TEMPLATE.sh | 52 ++++++++++++++++++++++++++++++++++++++++++ dist/build-version.sh | 28 +++++++++++++++++++++++ dist/prep-folders.sh | 24 +++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100755 dist/BUILD_TEMPLATE.sh create mode 100755 dist/build-version.sh create mode 100755 dist/prep-folders.sh diff --git a/dist/BUILD_TEMPLATE.sh b/dist/BUILD_TEMPLATE.sh new file mode 100755 index 0000000..19677ec --- /dev/null +++ b/dist/BUILD_TEMPLATE.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# (c) 2023-present Eroax +# (c) 2023-present Yagich +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +# Template script to build StreamGraph for Linux and Windows targets. +# While it can be invoked manually, it's part of a series of automation scripts. +# This script is tailor-made for one system and may not necessarily work on others. +# If you want a safer way to build StreamGraph, use Godot's Export menu. + +# This script is copied to a version folder as part of the build process. +# It will not try detecting that the folder it's in is valid, so do not run it if it's named "BUILD_TEMPLATE.sh". +# It expects a "godot" executable to be present in PATH. + +# If the first argument is "clean", the script will remove the built executables in the linux/ and windows/ folders and zip files it creates. + +target=`pwd` +version=`basename $target` +filename="StreamGraph-v$version" + +# Build StreamGraph for linux and windows and zip them up. +function build { + if ! command -v godot &> /dev/null; then + echo "ERROR: godot not found in PATH. Aborting." + exit 1 + fi + + cd ../../ + godot --headless --quiet --export-debug "linux" "$target/linux/$filename.x86_64" + godot --headless --quiet --export-debug "windows" "$target/windows/$filename.exe" + + cd "$target" + zip -rq "$filename-linux.zip" linux + zip -rq "$filename-windows.zip" windows + exit 0 +} + +# Clean the linux and windows folders and zip files. +function clean { + rm -f windows/* + rm -f linux/* + rm -f "$filename-linux.zip" + rm -f "$filename-windows.zip" + exit 0 +} + +if [[ $1 = "clean" ]]; then + clean +else + build +fi diff --git a/dist/build-version.sh b/dist/build-version.sh new file mode 100755 index 0000000..3a6d816 --- /dev/null +++ b/dist/build-version.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# (c) 2023-present Eroax +# (c) 2023-present Yagich +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +# Main script to build a given version of StreamGraph for Linux and Windows. +# See the files prep-folders.sh and BUILD_TEMPLATE.sh for more information on what happens during the build process. + +if [[ $# -ne 1 ]]; then + echo "ERROR: Version string required." + exit 2 +fi + +./prep-folders.sh $1 + +cd "$1" + +./build.sh clean +./build.sh + +if [[ $? = 0 ]]; then + echo "Build completed." + exit 0 +else + echo "Build failed." + exit $? +fi diff --git a/dist/prep-folders.sh b/dist/prep-folders.sh new file mode 100755 index 0000000..42ac2ff --- /dev/null +++ b/dist/prep-folders.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# (c) 2023-present Eroax +# (c) 2023-present Yagich +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +# Helper script to prepare folders for a StreamGraph release. +# Takes one argument, the version string, and creates a relevant folder structure, copying the build template into the version folder. + +if [[ $# -ne 1 ]]; then + echo "ERROR: Version string required." + exit 2 +fi + +if [[ -d $1 ]]; then + echo "WARN: The directory for version $1 already exists." + cp BUILD_TEMPLATE.sh "$1/build.sh" + exit 1 +fi + +mkdir -p "$1"/linux +mkdir -p "$1"/windows + +cp BUILD_TEMPLATE.sh "$1/build.sh"