From 970257913070d8fe796067f6f457b80b65628e81 Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 24 Jun 2026 14:02:51 +1200 Subject: [PATCH 01/19] Add mk.sh script --- ShellScripts/common/post_build.sh | 29 ++-- mk.sh | 213 ++++++++++++++++++++++++++++++ src/meson.build | 4 +- 3 files changed, 232 insertions(+), 14 deletions(-) create mode 100755 mk.sh diff --git a/ShellScripts/common/post_build.sh b/ShellScripts/common/post_build.sh index eed95d57d..fa9bd1c9c 100755 --- a/ShellScripts/common/post_build.sh +++ b/ShellScripts/common/post_build.sh @@ -12,9 +12,8 @@ run_script() { local appname=$(basename "$ORIGPROGPATH") local appdir=$(dirname "$ORIGPROGPATH") local progpath="$PROGDIR/$appname" - mkdir -p "$PROGDIR/Resources" - - generate_manifest "$PROGDIR/Resources/manifest.plist" + local resourcesdir="$PROGDIR/Resources" + mkdir -p "$resourcesdir" if [[ ! -f "$ORIGPROGPATH" ]]; then echo "❌ 'Oolite binary at '$ORIGPROGPATH' does not exist!" >&2 @@ -24,14 +23,20 @@ run_script() { echo "❌ Failed to copy '$ORIGPROGPATH' to '$progpath'!" >&2 return 1 fi - cp -fu "$ORIGPROGPATH" "$progpath" - cp -fu src/Cocoa/Info-Oolite.plist "$PROGDIR/Resources/Info-gnustep.plist" + generate_manifest "$resourcesdir/manifest.plist" + cp -fu src/Cocoa/Info-Oolite.plist "$resourcesdir/Info-gnustep.plist" + if [[ "$DEPLOYMENT_RELEASE_CONFIGURATION" == "no" ]]; then + local addonsdir="$PROGDIR/AddOns" + mkdir -p "$addonsdir" + rm -rf "$addonsdir/Basic-debug.oxp" + cp -rf DebugOXP/Debug.oxp "$addonsdir/Basic-debug.oxp" + fi # Voice Data if [[ "$ESPEAK" == "yes" ]]; then if [[ "$HOST_OS" == "windows" ]]; then # Windows espeak-ng-data - cp -rfu "$MINGW_PREFIX/share/espeak-ng-data" "$PROGDIR/Resources" + cp -rfu "$MINGW_PREFIX/share/espeak-ng-data" "$resourcesdir" else # Linux search paths for espeak-ng-data local SEARCH_PATHS=( @@ -44,7 +49,7 @@ run_script() { local path for path in "${SEARCH_PATHS[@]}"; do if [[ -d "$path" ]]; then - cp -rfu "$path" "$PROGDIR/Resources" + cp -rfu "$path" "$resourcesdir" found_data=true break fi @@ -59,10 +64,10 @@ run_script() { fi # Replace specific voices with Oolite-specific versions - rm -f "$PROGDIR/Resources/espeak-ng-data/voices/!v/f2" - rm -f "$PROGDIR/Resources/espeak-ng-data/voices/default" - cp -rfu Resources/. "$PROGDIR/Resources" - rm -f "$PROGDIR/Resources/AIReference.html" "$PROGDIR/Resources/*.icns" + rm -f "$resourcesdir/espeak-ng-data/voices/!v/f2" + rm -f "$resourcesdir/espeak-ng-data/voices/default" + cp -rfu Resources/. "$resourcesdir" + rm -f "$resourcesdir/AIReference.html" "$resourcesdir/*.icns" # Strip binary if requested if [[ "$STRIP_BIN" == "yes" ]]; then @@ -97,7 +102,7 @@ run_script() { if [ ! -f "$gnustep_conf" ] && [ "$GNUSTEP_FOLDER" = "/usr" ] && [ -f "/etc/GNUstep/GNUstep.conf" ]; then gnustep_conf="/etc/GNUstep/GNUstep.conf" fi - install -D "$gnustep_conf" "$PROGDIR/Resources/GNUstep.conf.orig" || { echo "$err_msg GNUstep config" >&2; return 1; } + install -D "$gnustep_conf" "$resourcesdir/GNUstep.conf.orig" || { echo "$err_msg GNUstep config" >&2; return 1; } # If we're using GNUstep libraries that aren't in a system folder copy them ldd "$progpath" | \ diff --git a/mk.sh b/mk.sh new file mode 100755 index 000000000..1bf550fc4 --- /dev/null +++ b/mk.sh @@ -0,0 +1,213 @@ +#!/bin/bash + +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) +pushd "$SCRIPT_DIR" > /dev/null + +# Strict expansions, but NO 'set -e' +set -u -o pipefail + +# --- Error Handling Trap --- +cleanup_and_exit() { + local exit_code=$? + + # If the exit code is 0 (success) but this function was triggered, + # force it to 1 to indicate an error. + if [[ $exit_code -eq 0 ]]; then + exit_code=1 + fi + + echo "❌ Oolite build failed on line $1 with exit code $exit_code!" >&2 + + # Always pop the directory stack before exiting + popd > /dev/null 2>&1 || true + + # Exit only if not sourced + if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + exit "$exit_code" + fi +} + +# Trap any command errors (ERR) passing ${LINENO} to know exactly where it failed. +trap 'cleanup_and_exit ${LINENO}' ERR + +# --- Environment Variables & Defaults --- +NATIVE_FILE="${NATIVE_FILE:-clang.ini}" +BUILDER="${BUILDER:-unknown}" +GITHUB_REPOSITORY="${GITHUB_REPOSITORY:-}" + +# --- Feature Flags & Options --- +CLEAN_BUILD=false +SETUP_FLAGS=() # Array to cleanly store additional meson setup arguments + +# --- Helper Functions --- +# Replicates $(call meson_build,flags,suffix) +meson_build() { + local build_dir="build/meson_$2" + # If --clean was specified, delete the specific build directory first + if [[ "$CLEAN_BUILD" == true ]]; then + echo "--> Cleaning target build directory: ${build_dir}" + rm -rf "$build_dir" + fi + echo "--> Running Meson build for: $2" + # Setup with --reconfigure, fallback to fresh setup. SETUP_FLAGS safely expands the array only if it's not empty + meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dgithub_repository="${GITHUB_REPOSITORY}" --native-file "${NATIVE_FILE}" --reconfigure 2>/dev/null || \ + meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dgithub_repository="${GITHUB_REPOSITORY}" --native-file "${NATIVE_FILE}" + meson compile -C "$build_dir" +} + +meson_install() { + echo "--> Running Meson install for: $1" + meson install -C "build/meson_$1" +} + +# --- Script Help Menu --- +show_help() { + echo "Usage: $0 [options] " + echo "" + echo "Options:" + echo -e " \033[36m--clean\033[0m Delete target build directory before compiling" + echo -e " \033[36m--setup-flags=\"...\"\033[0m Pass additional arguments directly to 'meson setup'" + echo "" + echo "Targets:" + echo -e " \033[36mrelease\033[0m Build a test release executable" + echo -e " \033[36mrelease-deployment\033[0m Build a release deployment executable" + echo -e " \033[36mrelease-snapshot\033[0m Build a snapshot release executable" + echo -e " \033[36mdebug\033[0m Build a debug executable" + echo -e " \033[36minstall\033[0m Install the test release build" + echo -e " \033[36minstall-deployment\033[0m Install the release deployment build" + echo -e " \033[36minstall-snapshot\033[0m Install the snapshot release build" + echo -e " \033[36mtest\033[0m Run test suite (depends on release-snapshot)" + echo -e " \033[36mclean\033[0m Remove all generated build artifacts" + echo -e " \033[36mpkg-flatpak\033[0m Package a Flatpak application" + echo -e " \033[36mpkg-appimage\033[0m Package a test release AppImage" + echo -e " \033[36mpkg-appimage-deployment\033[0m Package a deployment AppImage" + echo -e " \033[36mpkg-appimage-snapshot\033[0m Package a snapshot AppImage" + echo -e " \033[36mpkg-win\033[0m Package a Windows NSIS test release installer" + echo -e " \033[36mpkg-win-deployment\033[0m Package a Windows NSIS deployment installer" + echo -e " \033[36mpkg-win-snapshot\033[0m Package a Windows NSIS snapshot installer" +} + +# --- Target Execution Logic --- +execute_target() { + case "$1" in + release) + meson_build "-Ddebug=false -Dstrip_bin=true -Db_lto=true" "release" + ;; + release-deployment) + meson_build "-Ddeployment_release_configuration=true -Ddebug=false -Dstrip_bin=true -Db_lto=true" "deployment" + ;; + release-snapshot) + meson_build "-Dsnapshot_build=true -Ddebug=false -Dstrip_bin=false" "snapshot" + ;; + debug) + meson_build "-Ddebug=true -Dstrip_bin=false" "debug" + ;; + install) + meson_install "release" + ;; + install-deployment) + meson_install "deployment" + ;; + install-snapshot) + meson_install "snapshot" + ;; + test) + execute_target "release-snapshot" + tests/run_test.sh + ;; + clean) + echo "--> Cleaning all build artifacts..." + rm -rf build/meson_* + ;; + pkg-flatpak) + ./installers/flatpak/create_flatpak.sh + ;; + pkg-appimage) + execute_target "release" + installers/appimage/create_appimage.sh meson_release/oolite.app "test" + ;; + pkg-appimage-deployment) + execute_target "release-deployment" + installers/appimage/create_appimage.sh meson_deployment/oolite.app + ;; + pkg-appimage-snapshot) + execute_target "release-snapshot" + installers/appimage/create_appimage.sh meson_snapshot/oolite.app "dev" + ;; + pkg-win) + execute_target "release" + installers/win32/create_nsis.sh meson_release/oolite.app "test" + ;; + pkg-win-deployment) + execute_target "release-deployment" + installers/win32/create_nsis.sh meson_deployment/oolite.app + ;; + pkg-win-snapshot) + execute_target "release-snapshot" + installers/win32/create_nsis.sh meson_snapshot/oolite.app "dev" + ;; + help|--help|-h) + show_help + ;; + *) + echo "Error: Unknown target '$1'" >&2 + show_help + exit 1 + ;; + esac +} + +# --- Flexible Argument Parser --- +TARGET="" + +while [[ $# -gt 0 ]]; do + case "$1" in + --clean) + CLEAN_BUILD=true + shift + ;; + --setup-flags=*) + # Handle inline assignment format (e.g., --setup-flags="-Dfoo=bar") + read -r -a flags_array <<< "${1#*=}" + SETUP_FLAGS+=("${flags_array[@]}") + shift + ;; + help|--help|-h) + show_help + exit 0 + ;; + -*) + echo "Error: Unknown option '$1'" >&2 + show_help + exit 1 + ;; + *) + if [[ -n "$TARGET" ]]; then + echo "Error: Multiple targets specified ('$TARGET' and '$1'). Only one target allowed." >&2 + exit 1 + fi + TARGET="$1" + shift + ;; + esac +done + +# Fallback to help menu if no target was provided +if [[ -z "$TARGET" ]]; then + show_help + exit 1 +fi + +execute_target "$TARGET" +# Successful Exit - remove the ERR trap so it doesn't accidentally fire during normal bailing. +trap - ERR +popd > /dev/null + +# Only print build success if it wasn't a help menu or a cleanup action +if [[ "$TARGET" != "help" && "$TARGET" != "--help" && "$TARGET" != "-h" && "$TARGET" != "clean" ]]; then + echo "✅ Oolite target '$TARGET' completed successfully" +fi + +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + exit 0 +fi \ No newline at end of file diff --git a/src/meson.build b/src/meson.build index 314faa0ed..55f9e304d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -37,7 +37,7 @@ oolite_bin = executable( prog_dir = meson.global_build_root() / appname + '.app' stamp_file = '.oolite_bundle.stamp' -install_env_args = [ +post_build_env_args = [ 'ORIGPROGPATH=' + meson.current_build_dir() / appname, 'PROGDIR=' + prog_dir, 'HOST_OS=' + host_os, @@ -58,7 +58,7 @@ oolite_app_bundle = custom_target('post_build', depend_files: [post_build_script.full_path()], command: [ 'env', - install_env_args, + post_build_env_args, post_build_script.full_path(), ], build_by_default: true, From 63b9cbf92fd9f0406aed2996bc9f6eaafb427602 Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 24 Jun 2026 15:05:12 +1200 Subject: [PATCH 02/19] Call as functions from mk.sh Remove Makefile --- .github/workflows/build-all.yaml | 6 +- .github/workflows/test_builds.yaml | 22 ++--- Makefile | 97 ------------------- ShellScripts/Linux/install_package_fn.sh | 2 +- ShellScripts/Windows/install_deps.sh | 1 - ShellScripts/common/build_oolite.sh | 35 ------- ...eate_appimage.sh => create_appimage_fn.sh} | 14 +-- ...create_flatpak.sh => create_flatpak_fn.sh} | 14 +-- installers/flatpak/flatpak_build.sh | 2 +- .../{create_nsis.sh => create_nsis_fn.sh} | 15 +-- mk.sh | 18 ++-- tests/{run_test.sh => run_test_fn.sh} | 11 +-- 12 files changed, 29 insertions(+), 208 deletions(-) delete mode 100755 Makefile delete mode 100755 ShellScripts/common/build_oolite.sh rename installers/appimage/{create_appimage.sh => create_appimage_fn.sh} (95%) rename installers/flatpak/{create_flatpak.sh => create_flatpak_fn.sh} (96%) rename installers/win32/{create_nsis.sh => create_nsis_fn.sh} (95%) rename tests/{run_test.sh => run_test_fn.sh} (92%) diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index aee2e9f3d..ffdf8e0fd 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -52,7 +52,7 @@ jobs: ldconfig - name: Build Oolite run: | - ShellScripts/common/build_oolite.sh ${{matrix.flavour}} + ./mk.sh ${{matrix.flavour}} - name: Archive installer uses: actions/upload-artifact@v6 with: @@ -78,7 +78,7 @@ jobs: fetch-depth: 0 - name: Build flatpak run: | - installers/flatpak/create_flatpak.sh + ./mk.sh pkg-flatpak - name: Archive installer uses: actions/upload-artifact@v6 with: @@ -122,7 +122,7 @@ jobs: env: msystem: UCRT64 run: | - ShellScripts/common/build_oolite.sh ${{matrix.flavour}} + ./mk.sh ${{matrix.flavour}} - name: Archive installer uses: actions/upload-artifact@v6 with: diff --git a/.github/workflows/test_builds.yaml b/.github/workflows/test_builds.yaml index ebf28ae4c..fcc032fd1 100644 --- a/.github/workflows/test_builds.yaml +++ b/.github/workflows/test_builds.yaml @@ -44,14 +44,14 @@ jobs: - name: Build and test Oolite if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name run: | - ShellScripts/common/build_oolite.sh test + ./mk.sh test - name: Build Oolite (no test) if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name run: | - ShellScripts/common/build_oolite.sh + ./mk.sh release-snapshot - name: Build AppImage run: | - ShellScripts/common/build_oolite.sh pkg-appimage-snapshot + ./mk.sh pkg-appimage-snapshot fedora: runs-on: ubuntu-latest @@ -88,14 +88,14 @@ jobs: - name: Build and test Oolite if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name run: | - ShellScripts/common/build_oolite.sh test + ./mk.sh test - name: Build Oolite (no test) if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name run: | - ShellScripts/common/build_oolite.sh + ./mk.sh release-snapshot - name: Build AppImage run: | - ShellScripts/common/build_oolite.sh pkg-appimage-snapshot + ./mk.sh pkg-appimage-snapshot arch: runs-on: ubuntu-latest @@ -132,14 +132,14 @@ jobs: - name: Build and test Oolite if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name run: | - ShellScripts/common/build_oolite.sh test + ./mk.sh test - name: Build Oolite (no test) if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name run: | - ShellScripts/common/build_oolite.sh + ./mk.sh release-snapshot - name: Build AppImage run: | - ShellScripts/common/build_oolite.sh pkg-appimage-snapshot + ./mk.sh pkg-appimage-snapshot windows: runs-on: windows-latest @@ -174,7 +174,7 @@ jobs: env: msystem: UCRT64 run: | - ShellScripts/common/build_oolite.sh test + ./mk.sh test - name: Build Oolite (no test) if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name @@ -182,4 +182,4 @@ jobs: env: msystem: UCRT64 run: | - ShellScripts/common/build_oolite.sh + ./mk.sh release-snapshot diff --git a/Makefile b/Makefile deleted file mode 100755 index 6a25ab871..000000000 --- a/Makefile +++ /dev/null @@ -1,97 +0,0 @@ -# Use bash as the explicit shell and enable strict error handling for safety -SHELL := /bin/bash -.SHELLFLAGS := -eu -o pipefail -c - -NATIVE_FILE ?= clang.ini -BUILDER ?= unknown - -# Modern, self-documenting help target. -# It parses the '##' comments next to targets automatically. -.PHONY: help -help: ## Show this help message - @echo "Usage: make [target]" - @echo "" - @echo "Targets:" - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' - -# Macro for Meson workflow -define meson_build - meson setup build/meson_$(2) $(1) -Dgithub_repository=${GITHUB_REPOSITORY} --native-file $(NATIVE_FILE) --reconfigure 2>/dev/null || meson setup build/meson_$(2) $(1) -Dgithub_repository=${GITHUB_REPOSITORY} --native-file $(NATIVE_FILE) - meson compile -C build/meson_$(2) -endef - -# Helper macro for syncing OXP files cleanly -define sync_debug_oxp - mkdir -p build/meson_$(1)/oolite.app/AddOns - rm -rf build/meson_$(1)/oolite.app/AddOns/Basic-debug.oxp - cp -rf DebugOXP/Debug.oxp build/meson_$(1)/oolite.app/AddOns/Basic-debug.oxp -endef - -## -## Development Targets -## - -.PHONY: release -release: ## Build a test release executable - $(call meson_build,-Ddebug=false -Dstrip_bin=true -Db_lto=true,release) - $(call sync_debug_oxp,release) - -.PHONY: release-deployment -release-deployment: ## Build a release deployment executable - $(call meson_build,-Ddeployment_release_configuration=true -Ddebug=false -Dstrip_bin=true -Db_lto=true,deployment) - -.PHONY: release-snapshot -release-snapshot: ## Build a snapshot release executable - $(call meson_build,-Dsnapshot_build=true -Ddebug=false -Dstrip_bin=false,snapshot) - $(call sync_debug_oxp,snapshot) - -.PHONY: debug -debug: ## Build a debug executable - $(call meson_build,-Ddebug=true -Dstrip_bin=false,debug) - $(call sync_debug_oxp,debug) - -.PHONY: test -test: release-snapshot ## Run test suite - tests/run_test.sh - -.PHONY: clean -clean: ## Remove all generated build artifacts - rm -rf build/meson_* - -.PHONY: all -all: release release-deployment release-snapshot debug ## Build all standard development targets - -.PHONY: remake -remake: clean all - -## -## Packaging Targets -## - -.PHONY: pkg-flatpak -pkg-flatpak: ## Package a Flatpak application - ./installers/flatpak/create_flatpak.sh - -.PHONY: pkg-appimage -pkg-appimage: release ## Package a test release AppImage - installers/appimage/create_appimage.sh meson_release/oolite.app "test" - -.PHONY: pkg-appimage-deployment -pkg-appimage-deployment: release-deployment ## Package a deployment AppImage - installers/appimage/create_appimage.sh meson_deployment/oolite.app - -.PHONY: pkg-appimage-snapshot -pkg-appimage-snapshot: release-snapshot ## Package a snapshot AppImage - installers/appimage/create_appimage.sh meson_snapshot/oolite.app "dev" - -.PHONY: pkg-win -pkg-win: release ## Package a Windows NSIS test release installer - installers/win32/create_nsis.sh meson_release/oolite.app "test" - -.PHONY: pkg-win-deployment -pkg-win-deployment: release-deployment ## Package a Windows NSIS deployment installer - installers/win32/create_nsis.sh meson_deployment/oolite.app - -.PHONY: pkg-win-snapshot -pkg-win-snapshot: release-snapshot ## Package a Windows NSIS snapshot installer - installers/win32/create_nsis.sh meson_snapshot/oolite.app "dev" diff --git a/ShellScripts/Linux/install_package_fn.sh b/ShellScripts/Linux/install_package_fn.sh index affdaa29e..476ad8a43 100644 --- a/ShellScripts/Linux/install_package_fn.sh +++ b/ShellScripts/Linux/install_package_fn.sh @@ -15,7 +15,7 @@ install_package() { "base-devel") case "$CURRENT_DISTRO" in debian) pkg_name="build-essential" ;; - redhat) pkg_name="gcc gcc-c++ make" ;; + redhat) pkg_name="gcc gcc-c++" ;; arch) pkg_name="base-devel" ;; esac ;; diff --git a/ShellScripts/Windows/install_deps.sh b/ShellScripts/Windows/install_deps.sh index ce6669d84..e0424de02 100755 --- a/ShellScripts/Windows/install_deps.sh +++ b/ShellScripts/Windows/install_deps.sh @@ -47,7 +47,6 @@ run_script() { pacboy -S jq --noconfirm pacman -S unzip --noconfirm pacboy -S python-pip --noconfirm - pacman -S make --noconfirm pacboy -S meson --noconfirm pacboy -S ninja --noconfirm pacboy -S nsis --noconfirm diff --git a/ShellScripts/common/build_oolite.sh b/ShellScripts/common/build_oolite.sh deleted file mode 100755 index b68fc19bc..000000000 --- a/ShellScripts/common/build_oolite.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# No parameters: build target = release -# One parameter: build target - -run_script() { - local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) - pushd "$script_dir" - - cd ../.. - - local target - if [[ -z "$1" ]]; then - target=release - else - target=$1 - fi - - make clean - if ! make $target; then - echo "❌ Oolite build failed!" >&2 - return 1 - fi - echo "✅ Oolite build completed successfully" - - popd -} - -run_script "$@" -status=$? - - -# Exit only if not sourced -if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then - exit $status -fi \ No newline at end of file diff --git a/installers/appimage/create_appimage.sh b/installers/appimage/create_appimage_fn.sh similarity index 95% rename from installers/appimage/create_appimage.sh rename to installers/appimage/create_appimage_fn.sh index e81c99d75..6e09dbf8c 100755 --- a/installers/appimage/create_appimage.sh +++ b/installers/appimage/create_appimage_fn.sh @@ -4,9 +4,7 @@ # First parameter can be set to build type, typically one of "test", "dev" or omitted for release builds. # -echo I am $0 $@ - -run_script() { +create_appimage() { # First parameter is a suffix for the build type eg. test, dev local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" @@ -101,13 +99,3 @@ run_script() { popd } - -run_script "$@" -status=$? - - -# Exit only if not sourced -if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then - exit $status -fi - diff --git a/installers/flatpak/create_flatpak.sh b/installers/flatpak/create_flatpak_fn.sh similarity index 96% rename from installers/flatpak/create_flatpak.sh rename to installers/flatpak/create_flatpak_fn.sh index 0ded5d34b..ad2905f26 100755 --- a/installers/flatpak/create_flatpak.sh +++ b/installers/flatpak/create_flatpak_fn.sh @@ -1,8 +1,6 @@ #!/bin/bash -x -echo "I am $0 $@" - -run_script() { +create_flatpak() { # First parameter is a suffix for the build type eg. test, dev local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" @@ -127,13 +125,3 @@ EOF popd } - -run_script "$@" -status=$? - - -# Exit only if not sourced -if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then - exit $status -fi - diff --git a/installers/flatpak/flatpak_build.sh b/installers/flatpak/flatpak_build.sh index 503f5d8c1..5ff69cc84 100755 --- a/installers/flatpak/flatpak_build.sh +++ b/installers/flatpak/flatpak_build.sh @@ -11,7 +11,7 @@ source ShellScripts/Linux/install_freedesktop_fn.sh export ADDITIONAL_CFLAGS="-DBUILD_DATE='\"$CPP_DATE\"'" export ADDITIONAL_OBJCFLAGS="-DBUILD_DATE='\"$CPP_DATE\"'" -make release-deployment +./mk.sh release-deployment ABS_OOLITEDIR=$(realpath -m "build/meson_deployment/oolite.app") install_freedesktop $ABS_OOLITEDIR /app lib/debug/bin metainfo diff --git a/installers/win32/create_nsis.sh b/installers/win32/create_nsis_fn.sh similarity index 95% rename from installers/win32/create_nsis.sh rename to installers/win32/create_nsis_fn.sh index d4a74e8be..08190a328 100644 --- a/installers/win32/create_nsis.sh +++ b/installers/win32/create_nsis_fn.sh @@ -7,10 +7,7 @@ # VER_NSIS - the numberical version number (x.x.x.x) that the NSIS installer is built with # -echo I am $0 $@ - - -run_script() { +create_nsis() { # First parameter is a suffix for the build type eg. test, dev local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" @@ -78,13 +75,3 @@ run_script() { fi popd } - -run_script "$@" -status=$? - - -# Exit only if not sourced -if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then - exit $status -fi - diff --git a/mk.sh b/mk.sh index 1bf550fc4..7c9aca50b 100755 --- a/mk.sh +++ b/mk.sh @@ -4,7 +4,7 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$SCRIPT_DIR" > /dev/null # Strict expansions, but NO 'set -e' -set -u -o pipefail +set -o pipefail # --- Error Handling Trap --- cleanup_and_exit() { @@ -113,38 +113,38 @@ execute_target() { ;; test) execute_target "release-snapshot" - tests/run_test.sh + source tests/run_test_fn.sh && run_test ;; clean) echo "--> Cleaning all build artifacts..." rm -rf build/meson_* ;; pkg-flatpak) - ./installers/flatpak/create_flatpak.sh + source installers/flatpak/create_flatpak_fn.sh && create_flatpak ;; pkg-appimage) execute_target "release" - installers/appimage/create_appimage.sh meson_release/oolite.app "test" + source installers/appimage/create_appimage_fn.sh && create_appimage meson_release/oolite.app "test" ;; pkg-appimage-deployment) execute_target "release-deployment" - installers/appimage/create_appimage.sh meson_deployment/oolite.app + source installers/appimage/create_appimage_fn.sh && create_appimage meson_deployment/oolite.app ;; pkg-appimage-snapshot) execute_target "release-snapshot" - installers/appimage/create_appimage.sh meson_snapshot/oolite.app "dev" + source installers/appimage/create_appimage_fn.sh && create_appimage meson_snapshot/oolite.app "dev" ;; pkg-win) execute_target "release" - installers/win32/create_nsis.sh meson_release/oolite.app "test" + source installers/win32/create_nsis_fn.sh && create_nsis meson_release/oolite.app "test" ;; pkg-win-deployment) execute_target "release-deployment" - installers/win32/create_nsis.sh meson_deployment/oolite.app + source installers/win32/create_nsis_fn.sh && create_nsis meson_deployment/oolite.app ;; pkg-win-snapshot) execute_target "release-snapshot" - installers/win32/create_nsis.sh meson_snapshot/oolite.app "dev" + source installers/win32/create_nsis_fn.sh && create_nsis meson_snapshot/oolite.app "dev" ;; help|--help|-h) show_help diff --git a/tests/run_test.sh b/tests/run_test_fn.sh similarity index 92% rename from tests/run_test.sh rename to tests/run_test_fn.sh index f345ab359..1da802206 100755 --- a/tests/run_test.sh +++ b/tests/run_test_fn.sh @@ -9,7 +9,7 @@ output_log() { fi } -run_script() { +run_test() { if python3 --version >/dev/null 2>&1; then local PYTHON_CMD="python3" elif python --version >/dev/null 2>&1; then @@ -50,12 +50,3 @@ run_script() { echo "✅ Oolite test completed successfully" popd } - -run_script "$@" -status=$? - -# Exit only if not sourced -if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then - exit $status -fi - From da65cea549d9676339dbf208c89ef8c3136296e0 Mon Sep 17 00:00:00 2001 From: mcarans Date: Sat, 27 Jun 2026 10:14:47 +1200 Subject: [PATCH 03/19] mk.sh orchestrates everything Align builds to end filenames --- .github/workflows/build-all.yaml | 32 +-- .github/workflows/test_builds.yaml | 22 +- README.md | 52 ++-- ShellScripts/Linux/install_freedesktop_fn.sh | 47 ++-- ShellScripts/common/generate_manifest_fn.sh | 29 +-- ShellScripts/common/get_build_date_fn.sh | 26 ++ ShellScripts/common/get_version.sh | 58 ----- ShellScripts/common/get_version_fn.sh | 53 ++++ ShellScripts/common/install.sh | 24 +- ShellScripts/common/post_build.sh | 60 +++-- installers/appimage/create_appimage_fn.sh | 20 +- installers/flatpak/create_flatpak_fn.sh | 21 +- installers/flatpak/flatpak_build.sh | 24 -- installers/flatpak/flatpak_postbuild_fn.sh | 24 ++ installers/flatpak/space.oolite.Oolite.yaml | 5 +- installers/win32/OOlite.nsi | 20 +- installers/win32/create_nsis_fn.sh | 53 ++-- meson.build | 28 +- meson.options | 24 +- mk.sh | 259 ++++++++++++------- src/Core/OOLogHeader.m | 2 +- src/Core/Universe.m | 2 +- src/SDL/MyOpenGLView.m | 6 +- src/meson.build | 46 ++-- 24 files changed, 519 insertions(+), 418 deletions(-) create mode 100755 ShellScripts/common/get_build_date_fn.sh delete mode 100755 ShellScripts/common/get_version.sh create mode 100755 ShellScripts/common/get_version_fn.sh delete mode 100755 installers/flatpak/flatpak_build.sh create mode 100755 installers/flatpak/flatpak_postbuild_fn.sh diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index ffdf8e0fd..8ddd479e4 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -19,7 +19,7 @@ jobs: --security-opt apparmor:unconfined strategy: matrix: - flavour: [pkg-appimage-snapshot, pkg-appimage-deployment, pkg-appimage] + flavour: [pkg-appimage-deployment, pkg-appimage-test, pkg-appimage-dev] steps: ## This is for debugging only and helps developing the workflow. # - name: Environment Variables @@ -52,7 +52,7 @@ jobs: ldconfig - name: Build Oolite run: | - ./mk.sh ${{matrix.flavour}} + ./mk.sh ${{matrix.flavour}} --github-repository="$GITHUB_REPOSITORY" - name: Archive installer uses: actions/upload-artifact@v6 with: @@ -78,7 +78,7 @@ jobs: fetch-depth: 0 - name: Build flatpak run: | - ./mk.sh pkg-flatpak + ./mk.sh pkg-flatpak --github-repository="$GITHUB_REPOSITORY" - name: Archive installer uses: actions/upload-artifact@v6 with: @@ -91,7 +91,7 @@ jobs: runs-on: windows-latest strategy: matrix: - flavour: [pkg-win-snapshot, pkg-win-deployment, pkg-win] + flavour: [pkg-win-deployment, pkg-win-test, pkg-win-dev] steps: ## This is for debugging only and helps developing the workflow. # - name: Environment Variables @@ -122,7 +122,7 @@ jobs: env: msystem: UCRT64 run: | - ./mk.sh ${{matrix.flavour}} + ./mk.sh ${{matrix.flavour}} --github-repository="$GITHUB_REPOSITORY" - name: Archive installer uses: actions/upload-artifact@v6 with: @@ -146,7 +146,7 @@ jobs: uses: actions/download-artifact@v7 with: path: artifacts - - name: Calculate version number and set OOLITE_VERSION + - name: Calculate version number and set VER_FULL id: version run: | set -x @@ -166,14 +166,14 @@ jobs: echo "Found AppImage: $APPIMAGE_PATH" # 3. Run with packageinfo and extract the string inside quotes chmod +x "$APPIMAGE_PATH" - VERSION_STR=$("$APPIMAGE_PATH" packageinfo | awk -F'"' '/^[[:space:]]*version =/ {print $2; exit}') - if [[ -z "$VERSION_STR" ]]; then + VER_FULL=$("$APPIMAGE_PATH" packageinfo | awk -F'"' '/^[[:space:]]*version =/ {print $2; exit}') + if [[ -z "$VER_FULL" ]]; then echo "❌ Failed to extract version string from packageinfo output!" >&2 exit 1 fi - echo "Extracted Version: $VERSION_STR" + echo "Extracted Version: $VER_FULL" # 4. Output the extracted version for subsequent steps - echo "OOLITE_VERSION=$VERSION_STR" >> "$GITHUB_OUTPUT" + echo "VER_FULL=$VER_FULL" >> "$GITHUB_OUTPUT" - name: Remove old prereleases if: github.ref == 'refs/heads/master' || endsWith(github.ref, 'maintenance') uses: s00d/delete-older-releases@0.2.1 @@ -190,16 +190,16 @@ jobs: with: repo_token: "${{ secrets.GITHUB_TOKEN }}" # automatic_release_tag: "latest" - automatic_release_tag: "${{ steps.version.outputs.OOLITE_VERSION }}" + automatic_release_tag: "${{ steps.version.outputs.VER_FULL }}" prerelease: true - title: "Oolite ${{ steps.version.outputs.OOLITE_VERSION }}" + title: "Oolite ${{ steps.version.outputs.VER_FULL }}" files: | - artifacts/oolite-windows-pkg-win-snapshot/OoliteInstall-*-dev.exe artifacts/oolite-windows-pkg-win-deployment/OoliteInstall-*.exe - artifacts/oolite-windows-pkg-win/OoliteInstall-*.exe - artifacts/oolite-linux-pkg-appimage-snapshot/*.AppImage + artifacts/oolite-windows-pkg-win-test/OoliteInstall-*.exe + artifacts/oolite-windows-pkg-win-dev/OoliteInstall-*-dev.exe artifacts/oolite-linux-pkg-appimage-deployment/*.AppImage - artifacts/oolite-linux-pkg-appimage/*.AppImage + artifacts/oolite-linux-pkg-appimage-test/*.AppImage + artifacts/oolite-linux-pkg-appimage-dev/*.AppImage artifacts/oolite-flatpak/*.flatpak - name: Remove old workflow runs if: github.ref == 'refs/heads/master' || endsWith(github.ref, 'maintenance') diff --git a/.github/workflows/test_builds.yaml b/.github/workflows/test_builds.yaml index fcc032fd1..294654d68 100644 --- a/.github/workflows/test_builds.yaml +++ b/.github/workflows/test_builds.yaml @@ -44,14 +44,14 @@ jobs: - name: Build and test Oolite if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name run: | - ./mk.sh test + ./mk.sh test-dev - name: Build Oolite (no test) if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name run: | - ./mk.sh release-snapshot + ./mk.sh build-dev - name: Build AppImage run: | - ./mk.sh pkg-appimage-snapshot + ./mk.sh pkg-appimage-dev fedora: runs-on: ubuntu-latest @@ -88,14 +88,14 @@ jobs: - name: Build and test Oolite if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name run: | - ./mk.sh test + ./mk.sh test-dev - name: Build Oolite (no test) if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name run: | - ./mk.sh release-snapshot + ./mk.sh build-dev - name: Build AppImage run: | - ./mk.sh pkg-appimage-snapshot + ./mk.sh pkg-appimage-dev arch: runs-on: ubuntu-latest @@ -132,14 +132,14 @@ jobs: - name: Build and test Oolite if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name run: | - ./mk.sh test + ./mk.sh test-dev - name: Build Oolite (no test) if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name run: | - ./mk.sh release-snapshot + ./mk.sh build-dev - name: Build AppImage run: | - ./mk.sh pkg-appimage-snapshot + ./mk.sh pkg-appimage-dev windows: runs-on: windows-latest @@ -174,7 +174,7 @@ jobs: env: msystem: UCRT64 run: | - ./mk.sh test + ./mk.sh test-dev - name: Build Oolite (no test) if: github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name @@ -182,4 +182,4 @@ jobs: env: msystem: UCRT64 run: | - ./mk.sh release-snapshot + ./mk.sh build-dev diff --git a/README.md b/README.md index 44a3ba468..b87409bdf 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ where XXX is a version number. Many Linux package managers support Flatpak so yo double click the downloaded file to install it. The AppImage is named `Oolite_XXX-x86_64.AppImage` where XXX is a version number. Download this -file to where you would like it stored, make it executable and run, for example by typing +file to where you would like it stored, ./mk.sh it executable and run, for example by typing ```bash chmod +x Oolite_XXX-x86_64.AppImage @@ -125,7 +125,7 @@ default, but you can supply a further argument to specify an alternative like do Next run this in your Bash or MSYS2 prompt to build Oolite: ```bash -ShellScripts/common/build_oolite.sh release +./mk.sh release-dev ``` The completed build (executable and games files) can be found in the oolite.app directory. @@ -133,45 +133,61 @@ The completed build (executable and games files) can be found in the oolite.app Subsequently, you can clean and build as follows: ```bash -make clean -make release +./mk.sh clean +./mk.sh release-dev ``` -You can run a test from your Bash or MSYS2 prompt as follows: +You can run a test that launches the game and takes a snapshot from your Bash or MSYS2 prompt as follows: ```bash -make test +./mk.sh test ``` -Other targets are release-deployment for a production release and release-snapshot for a debug release. +release-dev keeps debug symbols in the binary. Other release targets remove those symbols from the binary although they +are made available in a separate symbols file. release-deployment is for a production release and release-test is for a +test release that supports the debug console which is used by expansion developers for debugging their OXPs. +You can install: +```bash +./mk.sh install-dev +``` -### Other Linux Make Targets +Other targets are install-deployment for a production install and install-test for a test install. -This target builds an AppImage for testing which can be found in build: +The underlying build system is Meson. You can run the deployment build directly using Meson build commands like this: ```bash -make pkg-appimage +meson setup build/meson_deployment -Ddeployment_release=true -Ddebug=false -Dstrip_bin=true -Db_lto=true --native-file clang.ini --reconfigure +meson compile -C build/meson_deployment ``` -The target pkg-appimage-deployment is the production release, while pkg-appimage-snapshot is for debugging. +### Other Linux ./mk.sh Targets -This target builds a Flatpak which can be found in build: +This target builds an AppImage for development which can be found in the `build` fodler: ```bash -make pkg-flatpak +./mk.sh pkg-appimage-dev ``` -Although there is a top level Makefile, the underlying build system is Meson. You can run the deployment -build directly using Meson build commands like this: +The target pkg-appimage-deployment is the production release, while pkg-appimage-test is for test. + +This target builds a Flatpak (deployment only) which can be found in the `build` folder: ```bash -meson setup build/meson_deployment -Ddeployment_release_configuration=true -Ddebug=false -Dstrip_bin=true -Db_lto=true --native-file clang.ini --reconfigure -meson compile -C build/meson_deployment -meson install -C build/meson_deployment +./mk.sh pkg-flatpak ``` +### Other Windows ./mk.sh Targets + +This target builds a Windows NSIS installer for development which can be found in the `build` folder: + +```bash +./mk.sh pkg-win-dev +``` + +The target pkg-win-deployment is the production release, while pkg-win-test is for test. + ### Mac OS Intel-based Macs can run old builds of Oolite, but current Macs are unsupported. It is hoped that they can be supported diff --git a/ShellScripts/Linux/install_freedesktop_fn.sh b/ShellScripts/Linux/install_freedesktop_fn.sh index b3a66a81c..25f47ebb5 100644 --- a/ShellScripts/Linux/install_freedesktop_fn.sh +++ b/ShellScripts/Linux/install_freedesktop_fn.sh @@ -1,61 +1,55 @@ #!/bin/bash -x # # Installs the manifest and injects version number -# -# Requires environment variables: -# VERSION -# APP_DATE -# echo "I am install_freedesktop_fn.sh $@" printenv | sort install_freedesktop() { - # Install metainfo (eg. for FlatHub and AppImageHub) - # $1: oolite.app directory path (source) - # $2: app folder (destination) - # $3: debug symbol folder - # $4: appdata or metainfo + local build_folder="$1" # oolite.app directory path (source) + local ver_full="$2" # Oolite version + local app_date="$3" # Oolite build date + local app_folder="$4" # app folder (destination) + local symbol_folder="$5" # debug symbol folder + local metainfo_suffix="$6" # can be appdata or metainfo local err_msg="❌ Error: Failed to" local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" - source ../common/get_version.sh + echo "Installing metainfo to to $app_folder" - echo "Installing metainfo to to $2" - - local appbin="$2/bin" - local appshr="$2/share" + local appbin="$app_folder/bin" + local appshr="$app_folder/share" # Install binaries and scripts - install -D "$1/oolite" "$appbin/oolite" || { echo "$err_msg install oolite binary" >&2; return 1; } - if [[ -f "$1/oolite.debug" ]]; then - install -D "$1/oolite.debug" "$2/$3/oolite.debug" || { echo "$err_msg install oolite debug symbols" >&2; return 1; } + install -D "$build_folder/oolite" "$appbin/oolite" || { echo "$err_msg install oolite binary" >&2; return 1; } + if [[ -f "$build_folder/oolite.debug" ]]; then + install -D "$build_folder/oolite.debug" "$app_folder/$symbol_folder/oolite.debug" || { echo "$err_msg install oolite debug symbols" >&2; return 1; } fi - install -D "$1/run_oolite.sh" "$appbin/run_oolite.sh" || { echo "$err_msg install run_oolite.sh" >&2; return 1; } + install -D "$build_folder/run_oolite.sh" "$appbin/run_oolite.sh" || { echo "$err_msg install run_oolite.sh" >&2; return 1; } # Resources copy local resourcesdir="$appshr/oolite/Resources" mkdir -p "$resourcesdir" - cp -rf "$1/Resources/." "$resourcesdir/" || { echo "$err_msg copy Resources folder" >&2; return 1; } + cp -rf "$build_folder/Resources/." "$resourcesdir/" || { echo "$err_msg copy Resources folder" >&2; return 1; } # AddOns copy if folder exists in oolite.app - if [ -d "$1/AddOns" ]; then + if [ -d "$build_folder/AddOns" ]; then local addonsdir="$appshr/oolite/AddOns" mkdir -p "$addonsdir" - cp -rf "$1/AddOns/." "$addonsdir/" || { echo "$err_msg copy AddOns folder" >&2; return 1; } + cp -rf "$build_folder/AddOns/." "$addonsdir/" || { echo "$err_msg copy AddOns folder" >&2; return 1; } fi rm -f "$resourcesdir/GNUstep.conf.orig" install -D "GNUstep.conf.template" "$resourcesdir/GNUstep.conf.template" || { echo "$err_msg GNUstep template" >&2; return 1; } - local app_metainfo="$appshr/metainfo/space.oolite.Oolite.$4.xml" + local app_metainfo="$appshr/metainfo/space.oolite.Oolite.$metainfo_suffix.xml" install -D ../../installers/FreeDesktop/space.oolite.Oolite.metainfo.xml.template "$app_metainfo" || { echo "$err_msg metainfo template" >&2; return 1; } - sed -i "s/@VER@/${VER_FULL}/g" "$app_metainfo" - sed -i "s/@DATE@/${APP_DATE}/g" "$app_metainfo" + sed -i "s/@VER@/${ver_full}/g" "$app_metainfo" + sed -i "s/@DATE@/${app_date}/g" "$app_metainfo" echo =========================================== echo Our manifest looks like this: @@ -64,8 +58,7 @@ install_freedesktop() { # Desktop and Icon install -D ../../installers/FreeDesktop/space.oolite.Oolite.desktop "$appshr/applications/space.oolite.Oolite.desktop" || { echo "$err_msg desktop file" >&2; return 1; } - - install -D "$1/Resources/Textures/oolite-logo1.png" "$appshr/icons/hicolor/256x256/apps/space.oolite.Oolite.png" || { echo "$err_msg icon file" >&2; return 1; } + install -D "$build_folder/Resources/Textures/oolite-logo1.png" "$appshr/icons/hicolor/256x256/apps/space.oolite.Oolite.png" || { echo "$err_msg icon file" >&2; return 1; } popd } \ No newline at end of file diff --git a/ShellScripts/common/generate_manifest_fn.sh b/ShellScripts/common/generate_manifest_fn.sh index 2fe7a426a..10f6e878d 100755 --- a/ShellScripts/common/generate_manifest_fn.sh +++ b/ShellScripts/common/generate_manifest_fn.sh @@ -1,16 +1,8 @@ generate_manifest() { - # Locate the xcconfig file - local oolite_version_file="src/Cocoa/oolite-version.xcconfig" - - if [[ ! -f "$oolite_version_file" ]]; then - echo "❌ $oolite_version_file not found!" >&2 - popd > /dev/null - return 1 - fi - - # Extract definition of $OOLITE_VERSION from the xcconfig - source "$oolite_version_file" - + local output_file="$1" + local deployment_release="$2" + local ver_full="$3" + local $ver_githash="$4" source ShellScripts/common/get_gitremote_fn.sh get_gitremote git_remote @@ -20,21 +12,22 @@ generate_manifest() { echo " title = \"Oolite core\";" echo " identifier = \"org.oolite.oolite\";" echo " " - echo " version = \"$VER_FULL\";" + echo " version = \"$ver_full\";" echo " git_remote_url = \"$git_remote\";" - echo " git_commit_hash = \"$VER_GITHASH\";" + echo " git_commit_hash = \"$ver_githash\";" - if [[ "$DEPLOYMENT_RELEASE_CONFIGURATION" == "yes" ]]; then + if [[ "$deployment_release" == "yes" ]]; then echo " debug_functionality_support = no;" else echo " debug_functionality_support = yes;" fi - - echo " required_oolite_version = \"$OOLITE_VERSION\";" + IFS='.' read -r major minor rest <<< "$ver_full" + local ver_short="$major.$minor" + echo " required_oolite_version = \"${ver_short}\";" echo " " echo " license = \"GPL 2+ / CC-BY-NC-SA 3.0 - see LICENSE.md for details\";" echo " author = \"Giles Williams, Jens Ayton and contributors\";" echo " information_url = \"https://oolite.space/\";" echo "}" - } > "$1" + } > "$output_file" } \ No newline at end of file diff --git a/ShellScripts/common/get_build_date_fn.sh b/ShellScripts/common/get_build_date_fn.sh new file mode 100755 index 000000000..a84169f9f --- /dev/null +++ b/ShellScripts/common/get_build_date_fn.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Calculates the Oolite build date +# + +get_build_date() { + local -n output_cpp_date=$1 + local -n output_app_date=$2 + local -n output_buildtime=$3 + local -n output_builder=$4 + # $5 is GITHUB_REPOSITORY environment variable from GitHub Actions + + # Run timestamp exactly once + local getversion_timestamp=$(git log -1 --format=%ct) + + # Date conversions use UTC for consistency + output_cpp_date=$(date -u -d "@$getversion_timestamp" +"%b %e %Y") + output_app_date=$(date -u -d "@$getversion_timestamp" +"%Y-%m-%d") + output_buildtime=$(date -u -d "@$getversion_timestamp" "+%Y.%m.%d %H:%M") + + if [[ "$5" == "OoliteProject/oolite" ]]; then + output_builder="OoliteProject" + else + output_builder="unknown" + fi +} \ No newline at end of file diff --git a/ShellScripts/common/get_version.sh b/ShellScripts/common/get_version.sh deleted file mode 100755 index 66f241dac..000000000 --- a/ShellScripts/common/get_version.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# -# Calculates the Oolite version number if not passed via env variables. Output goes to stdout. -# - -SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) -pushd "$SCRIPT_DIR" > /dev/null - -mkdir -p ../../build -cd ../../build - -# Timestamp of last commit/push -if [[ -z "${GETVERSION_TIMESTAMP}" ]]; then - # Run timestamp exactly once and export it for any subsequent child scripts - export GETVERSION_TIMESTAMP=$(git log -1 --format=%ct) -fi -# Date conversions use UTC for consistency -# Convert to __DATE__ format (e.g., Feb 20 2026) -CPP_DATE=$(date -u -d "@$GETVERSION_TIMESTAMP" +"%b %e %Y") -# Convert to YYYY-MM-DD -APP_DATE=$(date -u -d "@$GETVERSION_TIMESTAMP" +"%Y-%m-%d") -# Convert to YYMMDD format (e.g., 260313) -VER_DATE=$(date -u -d "@$GETVERSION_TIMESTAMP" +"%y%m%d") -# Convert to YYYY.MM.DD HH:MM format (e.g., 2026.06.21 07:56) -BUILDTIME=$(date -u -d "@$GETVERSION_TIMESTAMP" "+%Y.%m.%d %H:%M") - -if [[ -z "${VER_FULL}" ]]; then - if [[ -z "${GITVERSION_JSON}" ]]; then - # Run GitVersion exactly once and export it for any subsequent child scripts - if ! command -v gitversion &> /dev/null; then - echo "❌ gitversion binary not found!" >&2 - exit 1 - fi - export GITVERSION_JSON=$(gitversion) - fi - VER_MAJ=$(echo "$GITVERSION_JSON" | jq -r '.Major') - VER_MIN=$(echo "$GITVERSION_JSON" | jq -r '.Minor') - VER_REV=$(echo "$GITVERSION_JSON" | jq -r '.Patch') - if [[ "" == "$VER_REV" ]]; then - VER_REV="0" - fi - VER_DIST=$(echo "$GITVERSION_JSON" | jq -r '.VersionSourceDistance') - VER_SEMVER=$(echo "$GITVERSION_JSON" | jq -r '.SemVer') - VER_UNCOMMITTED=$(echo "$GITVERSION_JSON" | jq -r '.UncommittedChanges') - - if git diff --quiet; then - VER_FULL=$VER_SEMVER - else - VER_FULL="${VER_SEMVER}+dirty.${VER_UNCOMMITTED}" - fi - - VER_NSIS="$VER_MAJ.$VER_MIN.$VER_REV.$VER_DIST" - VER_GITREV=$(git rev-list --count HEAD) - VER_GITHASH=$(git rev-parse --short=7 HEAD) -fi - -echo "$VER_FULL" -popd > /dev/null diff --git a/ShellScripts/common/get_version_fn.sh b/ShellScripts/common/get_version_fn.sh new file mode 100755 index 000000000..5db99861e --- /dev/null +++ b/ShellScripts/common/get_version_fn.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# Calculates the Oolite version number +# + +# Get the name of the script that is sourcing this file +SUITE_PARENT=$(basename "${BASH_SOURCE[1]}") +# Define the ONLY script allowed to source this +ALLOWED_SCRIPT="mk.sh" +if [ "$SUITE_PARENT" != "$ALLOWED_SCRIPT" ]; then + echo "❌ This file can only be sourced by $ALLOWED_SCRIPT!" >&2 + return 1 2>/dev/null || exit 1 +fi + +get_version() { + local -n output_ver_full=$1 + local -n output_ver_nsis=$2 + local -n output_ver_gitrev=$3 + local -n output_ver_githash=$4 + + if [[ -n "$5" ]]; then # VER_FULL already populated + return 0 + fi + + if ! command -v gitversion &> /dev/null; then + echo "❌ gitversion binary not found!" >&2 + exit 1 + fi + + local gitversion_json=$(gitversion) + local ver_maj=$(echo "$gitversion_json" | jq -r '.Major') + local ver_min=$(echo "$gitversion_json" | jq -r '.Minor') + local ver_rev=$(echo "$gitversion_json" | jq -r '.Patch') + + if [[ "" == "$ver_rev" ]]; then + ver_rev="0" + fi + + local ver_dist=$(echo "$gitversion_json" | jq -r '.VersionSourceDistance') + local ver_semver=$(echo "$gitversion_json" | jq -r '.SemVer') + local ver_uncommitted=$(echo "$gitversion_json" | jq -r '.UncommittedChanges') + + if git diff --quiet; then + output_ver_full=$ver_semver + output_ver_nsis="$ver_maj.$ver_min.$ver_rev.$ver_dist" + else + output_ver_full="${ver_semver}+dirty.${ver_uncommitted}" + output_ver_nsis="$ver_maj.$ver_min.$ver_rev.$ver_uncommitted" + fi + + output_ver_gitrev=$(git rev-list --count HEAD) + output_ver_githash=$(git rev-parse --short=7 HEAD) +} \ No newline at end of file diff --git a/ShellScripts/common/install.sh b/ShellScripts/common/install.sh index 2b1dd59b6..c64b2d756 100755 --- a/ShellScripts/common/install.sh +++ b/ShellScripts/common/install.sh @@ -2,17 +2,23 @@ # Processes Oolite data files after compilation run_script() { + local stageprogpath="$1" + local bindir="$2" + local datadir="$3" + local host_os="$4" + local deployment_release="$5" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" > /dev/null cd ../.. - set -x - local appname=$(basename "$STAGEPROGPATH") - local progdir=$(dirname "$STAGEPROGPATH") + set -x + local appname=$(basename "$stageprogpath") + local progdir=$(dirname "$stageprogpath") local installdir="${INSTALLDIR:-$MESON_INSTALL_DESTDIR_PREFIX}" - local fullbindir="$installdir/$BINDIR" - local fulldatadir="$installdir/$DATADIR/oolite" # don't use appname here as Obj-C has oolite specifically + local fullbindir="$installdir/$bindir" + local fulldatadir="$installdir/$datadir/oolite" # don't use appname here as Obj-C has oolite specifically local progpath="$fullbindir/$appname" if ! mkdir -p "$fullbindir"; then echo "❌ Failed to create folder '$fullbindir'!" >&2 @@ -22,11 +28,11 @@ run_script() { echo "❌ Failed to create folder '$fulldatadir'!" >&2 return 1 fi - if ! cp -fu "$STAGEPROGPATH" "$progpath"; then - echo "❌ Failed to copy '$STAGEPROGPATH' to '$progpath'!" >&2 + if ! cp -fu "$stageprogpath" "$progpath"; then + echo "❌ Failed to copy '$stageprogpath' to '$progpath'!" >&2 return 1 - fi - if [[ "$HOST_OS" == "linux" ]]; then + fi + if [[ "$host_os" == "linux" ]]; then local run_oolite_src="$progdir/run_oolite.sh" local run_oolite_dst="$fullbindir/run_oolite.sh" if ! cp -fu "$run_oolite_src" "$run_oolite_dst"; then diff --git a/ShellScripts/common/post_build.sh b/ShellScripts/common/post_build.sh index fa9bd1c9c..b23947ef7 100755 --- a/ShellScripts/common/post_build.sh +++ b/ShellScripts/common/post_build.sh @@ -2,6 +2,18 @@ # Processes Oolite data files after compilation run_script() { + local origprogpath="$1" + local progdir="$2" + local host_os="$3" + local debug="$4" + local deployment_release="$5" + local espeak="$6" + local strip_bin="$7" + local ver_full="$8" + local ver_githash="$9" + local gnustep_folder="${10}" + local stamp_file="${11}" + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" > /dev/null @@ -9,32 +21,32 @@ run_script() { cd ../.. set -x - local appname=$(basename "$ORIGPROGPATH") - local appdir=$(dirname "$ORIGPROGPATH") - local progpath="$PROGDIR/$appname" - local resourcesdir="$PROGDIR/Resources" + local appname=$(basename "$origprogpath") + local appdir=$(dirname "$origprogpath") + local progpath="$progdir/$appname" + local resourcesdir="$progdir/Resources" mkdir -p "$resourcesdir" - if [[ ! -f "$ORIGPROGPATH" ]]; then - echo "❌ 'Oolite binary at '$ORIGPROGPATH' does not exist!" >&2 + if [[ ! -f "$origprogpath" ]]; then + echo "❌ 'Oolite binary at '$origprogpath' does not exist!" >&2 return 1 fi - if ! cp -fu "$ORIGPROGPATH" "$progpath"; then - echo "❌ Failed to copy '$ORIGPROGPATH' to '$progpath'!" >&2 + if ! cp -fu "$origprogpath" "$progpath"; then + echo "❌ Failed to copy '$origprogpath' to '$progpath'!" >&2 return 1 fi - generate_manifest "$resourcesdir/manifest.plist" + generate_manifest "$resourcesdir/manifest.plist" "$deployment_release" "$ver_full" "$ver_githash" cp -fu src/Cocoa/Info-Oolite.plist "$resourcesdir/Info-gnustep.plist" - if [[ "$DEPLOYMENT_RELEASE_CONFIGURATION" == "no" ]]; then - local addonsdir="$PROGDIR/AddOns" + if [[ "$deployment_release" == "no" ]]; then + local addonsdir="$progdir/AddOns" mkdir -p "$addonsdir" rm -rf "$addonsdir/Basic-debug.oxp" cp -rf DebugOXP/Debug.oxp "$addonsdir/Basic-debug.oxp" fi # Voice Data - if [[ "$ESPEAK" == "yes" ]]; then - if [[ "$HOST_OS" == "windows" ]]; then + if [[ "$espeak" == "yes" ]]; then + if [[ "$host_os" == "windows" ]]; then # Windows espeak-ng-data cp -rfu "$MINGW_PREFIX/share/espeak-ng-data" "$resourcesdir" else @@ -70,13 +82,13 @@ run_script() { rm -f "$resourcesdir/AIReference.html" "$resourcesdir/*.icns" # Strip binary if requested - if [[ "$STRIP_BIN" == "yes" ]]; then - if [[ "$HOST_OS" == "windows" ]]; then + if [[ "$strip_bin" == "yes" ]]; then + if [[ "$host_os" == "windows" ]]; then # Windows: Standard GNU strip is safest for PE/COFF strip "$progpath" else # Linux - local debugpath="$PROGDIR/$appname.debug" + local debugpath="$progdir/$appname.debug" # Extract symbols to file objcopy --only-keep-debug "$progpath" "$debugpath" # Compress the debug sections in the symbol file @@ -86,20 +98,20 @@ run_script() { # Add the debug link objcopy --add-gnu-debuglink="$debugpath" "$progpath" fi - elif [[ "$HOST_OS" == "linux" ]]; then + elif [[ "$host_os" == "linux" ]]; then # Compress the debug sections in the binary objcopy --compress-debug-sections=zlib-gnu "$progpath" fi - if [[ "$HOST_OS" == "windows" ]]; then + if [[ "$host_os" == "windows" ]]; then # Determine and copy DLL dependencies local unix_prefix=$(cygpath -u "$MINGW_PREFIX") - ldd "$progpath" | grep "$unix_prefix" | awk '{print $3}' | xargs -I {} cp -rfu {} "$PROGDIR" + ldd "$progpath" | grep "$unix_prefix" | awk '{print $3}' | xargs -I {} cp -rfu {} "$progdir" else # Copy Linux-specific wrapper script - cp -fu ShellScripts/Linux/run_oolite.sh "$PROGDIR" - local gnustep_conf="$GNUSTEP_FOLDER/etc/GNUstep/GNUstep.conf" - if [ ! -f "$gnustep_conf" ] && [ "$GNUSTEP_FOLDER" = "/usr" ] && [ -f "/etc/GNUstep/GNUstep.conf" ]; then + cp -fu ShellScripts/Linux/run_oolite.sh "$progdir" + local gnustep_conf="$gnustep_folder/etc/GNUstep/GNUstep.conf" + if [ ! -f "$gnustep_conf" ] && [ "$gnustep_folder" = "/usr" ] && [ -f "/etc/GNUstep/GNUstep.conf" ]; then gnustep_conf="/etc/GNUstep/GNUstep.conf" fi install -D "$gnustep_conf" "$resourcesdir/GNUstep.conf.orig" || { echo "$err_msg GNUstep config" >&2; return 1; } @@ -109,11 +121,11 @@ run_script() { grep -E "libgnustep-base|libobjc\.so\." | \ grep -vE "^[[:space:]]*.*=>[[:space:]]*/(usr/(local/)?|lib(64)?/)" | \ awk '{print $3}' | \ - xargs -I {} cp -Lrfu {} "$PROGDIR/" + xargs -I {} cp -Lrfu {} "$progdir/" fi echo "✅ Oolite post-build completed successfully" - touch "$appdir/$STAMP_FILE" + touch "$appdir/$stamp_file" popd > /dev/null } diff --git a/installers/appimage/create_appimage_fn.sh b/installers/appimage/create_appimage_fn.sh index 6e09dbf8c..a52545630 100755 --- a/installers/appimage/create_appimage_fn.sh +++ b/installers/appimage/create_appimage_fn.sh @@ -1,18 +1,18 @@ #!/bin/bash -x # # Creates the appimage. -# First parameter can be set to build type, typically one of "test", "dev" or omitted for release builds. -# create_appimage() { - # First parameter is a suffix for the build type eg. test, dev + local build_folder="$1" # Build folder + local ver_full="$2" # Oolite version + local app_date="$3" # Oolite build date + local build_type="$4" # Typically one of "test", "dev" or omitted for release builds + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" - mkdir -p ../../build cd ../../build source ../ShellScripts/Linux/os_detection.sh - source ../ShellScripts/common/get_version.sh source ../ShellScripts/Linux/install_freedesktop_fn.sh local arch=$(uname -m) @@ -22,9 +22,9 @@ create_appimage() { local appshr="$APPDIR/share" rm -rf "$APPDIR" - local abs_oolitedir=$(realpath -m "$1") + local abs_oolitedir=$(realpath -m "$build_folder") local abs_appdir=$(realpath -m "$APPDIR") - if ! install_freedesktop "$abs_oolitedir" "$abs_appdir" bin appdata; then + if ! install_freedesktop "$abs_oolitedir" "$ver_full" "$app_date" "$abs_appdir" "bin" "appdata"; then return 1 fi @@ -42,10 +42,10 @@ create_appimage() { local DESKTOP="$appshr/applications/space.oolite.Oolite.desktop" export DESKTOP local suffix - if (( $# == 2 )); then - suffix="_${2}-${VER_FULL}" + if [[ -n "$build_type" ]]; then + suffix="_$build_type-$ver_full" else - suffix="-$VER_FULL" + suffix="-$ver_full" fi local OUTNAME="oolite${suffix}-${arch}.AppImage" export OUTNAME diff --git a/installers/flatpak/create_flatpak_fn.sh b/installers/flatpak/create_flatpak_fn.sh index ad2905f26..681077bb3 100755 --- a/installers/flatpak/create_flatpak_fn.sh +++ b/installers/flatpak/create_flatpak_fn.sh @@ -1,7 +1,9 @@ #!/bin/bash -x create_flatpak() { - # First parameter is a suffix for the build type eg. test, dev + local ver_full="$1" # Oolite version + local github_repository="$2" # GitHub repository (set by GitHub Actions) + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" @@ -19,7 +21,6 @@ create_flatpak() { mv "$outputdir/gitversion" /usr/local/bin/gitversion rm -f ${gitversion_tgz} fi - source ../ShellScripts/common/get_version.sh cp ../installers/flatpak/space.oolite.Oolite.* ./ @@ -30,12 +31,7 @@ create_flatpak() { fi local manifest="space.oolite.Oolite.yaml" - - local env_block="env:\n VER_FULL: \"$VER_FULL\"\n GITHUB_REPOSITORY: \"$GITHUB_REPOSITORY\"" - # Swap the comment - sed -i "s|#[[:space:]]*CI builds add an env block here|$env_block|g" "$manifest" || return 1 - - # check manifest + sed -i "s|^\([[:space:]]*- \)./mk.sh.*|\1./mk.sh flatpak-deployment --ver-full=\"$ver_full\" --github-repository=\"$github_repository\"|" "$manifest" || return 1 local lint_exceptions=$(mktemp /tmp/oolite-lint-XXXXXX.json) cat < "$lint_exceptions" { @@ -46,7 +42,7 @@ create_flatpak() { EOF trap 'rm -f "$lint_exceptions"' RETURN EXIT - if command -v flatpak-builder-lint >/dev/null 2>&1; then + if command -v flatpak-builder-lint >/dev/null 2>&1; then # check manifest if ! flatpak-builder-lint manifest "$manifest" --exceptions --user-exceptions="$lint_exceptions"; then echo "❌ Flatpak manifest lint failed!" >&2 cat "$manifest" @@ -97,12 +93,7 @@ EOF return 1 fi - local suffix - if (( $# == 1 )); then - suffix="_${1}-${VER_FULL}" - else - suffix="-$VER_FULL" - fi + local suffix="-$ver_full" local ARCH=$(uname -m) local filename="space.oolite.Oolite${suffix}-${ARCH}.flatpak" echo "Creating Flatpak $filename..." diff --git a/installers/flatpak/flatpak_build.sh b/installers/flatpak/flatpak_build.sh deleted file mode 100755 index 5ff69cc84..000000000 --- a/installers/flatpak/flatpak_build.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -x -# -# Prepares the app directory for the flatpak builder -# - -echo "I am flatpak_build.sh $@" -printenv | sort - -source ShellScripts/common/get_version.sh -source ShellScripts/Linux/install_freedesktop_fn.sh - -export ADDITIONAL_CFLAGS="-DBUILD_DATE='\"$CPP_DATE\"'" -export ADDITIONAL_OBJCFLAGS="-DBUILD_DATE='\"$CPP_DATE\"'" -./mk.sh release-deployment - -ABS_OOLITEDIR=$(realpath -m "build/meson_deployment/oolite.app") -install_freedesktop $ABS_OOLITEDIR /app lib/debug/bin metainfo -# Ensure the destination directory exists -mkdir -p /app/lib/debug/source/oolite -# Copy the src directory recursively -cp -r src /app/lib/debug/source/oolite/ || { - echo "❌ $err_msg install oolite source code" >&2 - return 1 -} diff --git a/installers/flatpak/flatpak_postbuild_fn.sh b/installers/flatpak/flatpak_postbuild_fn.sh new file mode 100755 index 000000000..66fb4c6da --- /dev/null +++ b/installers/flatpak/flatpak_postbuild_fn.sh @@ -0,0 +1,24 @@ +#!/bin/bash -x +# +# Prepares the app directory for the flatpak builder +# + +flatpak_postbuild() { + local build_folder="$1" # Build folder + local ver_full="$2" # Oolite version + local app_date="$3" # Oolite build date + + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" + cd ../../build + source ../ShellScripts/Linux/install_freedesktop_fn.sh + + local abs_oolitedir=$(realpath -m "$build_folder") + install_freedesktop "$abs_oolitedir" "$ver_full" "$app_date" "/app" "lib/debug/bin" "metainfo" + mkdir -p /app/lib/debug/source/oolite # Ensure the destination directory exists + # Copy the src directory recursively + cp -r ../src /app/lib/debug/source/oolite/ || { + echo "❌ $err_msg install oolite source code" >&2 + return 1 + } +} \ No newline at end of file diff --git a/installers/flatpak/space.oolite.Oolite.yaml b/installers/flatpak/space.oolite.Oolite.yaml index 33456d2ff..8adb1e002 100644 --- a/installers/flatpak/space.oolite.Oolite.yaml +++ b/installers/flatpak/space.oolite.Oolite.yaml @@ -111,9 +111,10 @@ modules: buildsystem: simple build-options: no-debuginfo: true - # CI builds add an env block here build-commands: - - source installers/flatpak/flatpak_build.sh + # Update --ver-full for FlatHub release. For CI and local builds, create_flatpak.sh replaces + # --ver-full and --github-repository values + - ./mk.sh flatpak-deployment --ver-full="1.92.1" --github-repository="OoliteProject/oolite" sources: # Update tag and commit for FlatHub release. For CI and local builds, create_flatpak.sh replaces git source with: # - type: dir diff --git a/installers/win32/OOlite.nsi b/installers/win32/OOlite.nsi index 0f24d7858..6a70a8db3 100644 --- a/installers/win32/OOlite.nsi +++ b/installers/win32/OOlite.nsi @@ -1,5 +1,5 @@ ; Include the NSIS logic library. Required for the code that handles -; adding of the changelog file in the non-snapshot distributions +; adding of the changelog file in the non-dev distributions !include "LogicLib.nsh" ; Include the Sections library, required for being able to provide the @@ -35,8 +35,8 @@ !define SEMVER ${VERSION} !endif -!ifndef SNAPSHOT -!ifndef DEPLOYMENT +!ifndef DEV_RELEASE +!ifndef DEPLOYMENT_RELEASE !define EXTVER "-test" ; Official distribution with OXP developer tools !define ADDCHANGELOG 1 ; Official distributions go with a changelog file !else @@ -45,10 +45,10 @@ !endif !else !define EXTVER "-dev" -!define ADDCHANGELOG 0 ; Snapshot distributions do not need changelog +!define ADDCHANGELOG 0 ; Dev distributions do not need changelog !endif -!ifndef DEPLOYMENT +!ifndef DEPLOYMENT_RELEASE !define DEBUGOXPINCLUDED 1 !else !define DEBUGOXPINCLUDED 0 @@ -87,7 +87,7 @@ VIAddVersionKey "FileDescription" "A space combat/trading game, inspired by Elit VIAddVersionKey "LegalCopyright" "� 2003-2026 Giles Williams, Jens Ayton and contributors" VIAddVersionKey "FileVersion" "${VER}" VIAddVersionKey "ProductVersion" "${SEMVER}" -!ifdef SNAPSHOT +!ifdef DEV_RELEASE VIAddVersionKey "GIT Revision" "${VER_GITHASH}" !endif !ifdef BUILDTIME @@ -104,7 +104,7 @@ VIProductVersion "${VER}" !define MUI_UNICON oolite.ico !insertmacro MUI_PAGE_DIRECTORY -!ifndef DEPLOYMENT +!ifndef DEPLOYMENT_RELEASE !insertmacro MUI_PAGE_COMPONENTS !endif !insertmacro MUI_PAGE_INSTFILES @@ -127,14 +127,14 @@ VIProductVersion "${VER}" !insertmacro MUI_LANGUAGE "English" -!ifndef DEPLOYMENT +!ifndef DEPLOYMENT_RELEASE ; Create the main game and Debug OXP sections Section "Oolite Game" ooGame SectionIn RO ; The game itself cannot be unselected SectionEnd Section "Basic-debug.OXP" ooDebugOXP -; Do not use any of the Debug OXP files when we are building Deployment +; Do not use any of the Debug OXP files when we are building deployment release SetOutPath $INSTDIR File /r "${DST}\AddOns" SectionEnd @@ -200,7 +200,7 @@ uninst: done: FunctionEnd -!ifndef DEPLOYMENT +!ifndef DEPLOYMENT_RELEASE Function .onSelChange ${If} ${SectionIsSelected} ${ooDebugOXP} !insertmacro SelectSection ${ooDebugOXP} diff --git a/installers/win32/create_nsis_fn.sh b/installers/win32/create_nsis_fn.sh index 08190a328..3371e1b31 100644 --- a/installers/win32/create_nsis_fn.sh +++ b/installers/win32/create_nsis_fn.sh @@ -1,20 +1,20 @@ #!/bin/bash -x # # Creates the windows installer using NSIS. -# First parameter can be set to build type, typically one of "test", "dev" or omitted for release builds. -# Accepts two verion variables: -# VER_FULL - the full version number Oolite is getting built with -# VER_NSIS - the numberical version number (x.x.x.x) that the NSIS installer is built with -# create_nsis() { - # First parameter is a suffix for the build type eg. test, dev + local build_folder="$1" # Build folder + local ver_full="$2" # Oolite version + local ver_gitrev="$3" # Total number of commits in the history of current branch + local ver_githash="$4" # Git hash + local buildtime="$5" # Oolite build time + local build_type="$6" # Typically one of "test", "dev" or omitted for release builds + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" mkdir -p ../../build/nsis cd ../../build/nsis - source ../../ShellScripts/common/get_version.sh cp ../../installers/win32/* ./ @@ -39,28 +39,35 @@ create_nsis() { return 1 fi - local oolite_dir="../$1" + local oolite_dir="../$build_folder" oolite_dir="${oolite_dir//\//\\}" - # Passing arguments cause problems with some versions of NSIS. - # Because of this, we generate them into a separate file and include them. + + [[ "$ver_full" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+).*\.([0-9]+)$ ]] # Regex captures: Major, Minor, Patch, Distance + local ver_maj="${BASH_REMATCH[1]}" + local ver_min="${BASH_REMATCH[2]}" + local ver_rev="${BASH_REMATCH[3]}" + local ver_dist="${BASH_REMATCH[4]}" + local ver_nsis="${ver_maj}.${ver_min}.${ver_rev}.${ver_dist}" + + # Passing arguments can cause problems with NSIS so we generate them into a separate file and include them. echo "; Version Definitions for Oolite" > OoliteVersions.nsh echo "; NOTE - This file is auto-generated by the Makefile, any manual edits will be overwritten" >> OoliteVersions.nsh - echo "!define oolite_dir ${oolite_dir}" >> OoliteVersions.nsh - echo "!define VER_MAJ ${VER_MAJ}" >> OoliteVersions.nsh - echo "!define VER_MIN ${VER_MIN}" >> OoliteVersions.nsh - echo "!define VER_REV ${VER_REV}" >> OoliteVersions.nsh - echo "!define VER_GITREV ${VER_GITREV}" >> OoliteVersions.nsh - echo "!define VER_GITHASH ${VER_GITHASH}" >> OoliteVersions.nsh - echo "!define VERSION ${VER_NSIS}" >> OoliteVersions.nsh - echo "!define SEMVER ${VER_FULL}" >> OoliteVersions.nsh - echo "!define BUILDTIME \"${BUILDTIME}\"" >> OoliteVersions.nsh + echo "!define OOLITE_DIR ${oolite_dir}" >> OoliteVersions.nsh + echo "!define VER_MAJ ${ver_maj}" >> OoliteVersions.nsh + echo "!define VER_MIN ${ver_min}" >> OoliteVersions.nsh + echo "!define VER_REV ${ver_rev}" >> OoliteVersions.nsh + echo "!define VER_GITREV ${ver_gitrev}" >> OoliteVersions.nsh + echo "!define VER_GITHASH ${ver_githash}" >> OoliteVersions.nsh + echo "!define VERSION ${ver_nsis}" >> OoliteVersions.nsh + echo "!define SEMVER ${ver_full}" >> OoliteVersions.nsh + echo "!define BUILDTIME \"${buildtime}\"" >> OoliteVersions.nsh echo "!define BUILDHOST_IS64BIT 1" >> OoliteVersions.nsh - if [[ "$2" == "dev" ]]; then - echo "!define SNAPSHOT 1" >> OoliteVersions.nsh - elif [[ "$2" != "test" ]]; then - echo "!define DEPLOYMENT 1" >> OoliteVersions.nsh + if [[ "$build_type" == "dev" ]]; then + echo "!define DEV_RELEASE 1" >> OoliteVersions.nsh + elif [[ "$build_type" != "test" ]]; then + echo "!define DEPLOYMENT_RELEASE 1" >> OoliteVersions.nsh fi local nsis diff --git a/meson.build b/meson.build index badc7b786..6602937cd 100644 --- a/meson.build +++ b/meson.build @@ -2,11 +2,7 @@ project( 'oolite', ['c', 'cpp', 'objc'], meson_version: '>= 1.4.0', - version: run_command( - 'bash', - files('ShellScripts/common/get_version.sh'), - check: true, - ).stdout().strip(), + version: 'not used', default_options: [ 'optimization=2', ], @@ -15,20 +11,11 @@ project( host_os = host_machine.system() c_family = ['c', 'cpp', 'objc'] -version_string = meson.project_version() +version_string = get_option('ver_full') # use instead of meson project version! add_project_arguments( '-DOO_VERSION_FULL="@0@"'.format(version_string), - language: c_family, -) - -github_repository = get_option('github_repository') -if github_repository == 'OoliteProject/oolite' - builder = 'OoliteProject' -else - builder = 'unknown' -endif -add_project_arguments( - '-DOO_BUILDER="@0@"'.format(builder), + '-DOO_BUILD_DATE="@0@"'.format(get_option('build_date')), + '-DOO_BUILDER="@0@"'.format(get_option('builder')), language: c_family, ) @@ -47,7 +34,7 @@ if get_option('no_shaders') add_project_arguments('-DNO_SHADERS=1', language: c_family) endif -if get_option('deployment_release_configuration') +if get_option('deployment_release') add_project_arguments( '-DNDEBUG', '-DOO_CHECK_GL_HEAVY=0', @@ -81,10 +68,9 @@ else endif endif -if get_option('snapshot_build') +if get_option('dev_release') add_project_arguments( - '-DSNAPSHOT_BUILD', - '-DOOLITE_SNAPSHOT_VERSION="@0@"'.format(version_string), + '-DDEV_RELEASE', language: c_family, ) endif diff --git a/meson.options b/meson.options index 7ff139544..f53c1418e 100644 --- a/meson.options +++ b/meson.options @@ -32,11 +32,11 @@ option('debug_graphviz', type: 'boolean', value: true, description: 'Enable AI state-machine graph visualization via GraphViz syntax output') # Release Variant Control -option('deployment_release_configuration', type: 'boolean', value: false, +option('deployment_release', type: 'boolean', value: false, description: 'Force a strict production deployment setup (overrides and disables most debugging instrumentation)') -option('snapshot_build', type: 'boolean', value: false, - description: 'Mark the compilation as a development snapshot build') +option('dev_release', type: 'boolean', value: false, + description: 'Mark the compilation as a development release') option('strip_bin', type: 'boolean', value: false, description: 'Enable stripping') @@ -44,8 +44,20 @@ option('strip_bin', type: 'boolean', value: false, description: 'Enable strippin option('pdb', type: 'boolean', value: false, description: 'Windows Clang builds only: Generate native .pdb debug symbol files') -# GitHub repository variable from CI if available -option('github_repository', type: 'string', value: '', - description: 'GitHub repository variable from CI if available') +# Oolite version +option('ver_full', type: 'string', value: '', + description: 'Oolite version') + +# Git hash of commit +option('ver_githash', type: 'string', value: '', + description: 'Git hash of commit') + +# Oolite build date +option('build_date', type: 'string', value: 'unknown', + description: 'Oolite build date') + +# Oolite builder +option('builder', type: 'string', value: 'unknown', + description: 'Oolite builder') diff --git a/mk.sh b/mk.sh index 7c9aca50b..b8fd481e4 100755 --- a/mk.sh +++ b/mk.sh @@ -3,148 +3,196 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$SCRIPT_DIR" > /dev/null -# Strict expansions, but NO 'set -e' -set -o pipefail +set -u -o pipefail # Strict expansions # --- Error Handling Trap --- cleanup_and_exit() { local exit_code=$? - # If the exit code is 0 (success) but this function was triggered, - # force it to 1 to indicate an error. if [[ $exit_code -eq 0 ]]; then - exit_code=1 + exit_code=1 # force 0 exit code to 1 to indicate an error fi - echo "❌ Oolite build failed on line $1 with exit code $exit_code!" >&2 - - # Always pop the directory stack before exiting - popd > /dev/null 2>&1 || true - - # Exit only if not sourced - if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + popd > /dev/null 2>&1 || true # Always pop the directory stack before exiting + if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then # Exit only if not sourced exit "$exit_code" fi } - -# Trap any command errors (ERR) passing ${LINENO} to know exactly where it failed. -trap 'cleanup_and_exit ${LINENO}' ERR - -# --- Environment Variables & Defaults --- -NATIVE_FILE="${NATIVE_FILE:-clang.ini}" -BUILDER="${BUILDER:-unknown}" -GITHUB_REPOSITORY="${GITHUB_REPOSITORY:-}" +trap 'cleanup_and_exit ${LINENO}' ERR # Trap any command errors (ERR) passing ${LINENO} to know where it failed # --- Feature Flags & Options --- +NATIVE_FILE="" +VER_FULL="" +GITHUB_REPOSITORY="" CLEAN_BUILD=false SETUP_FLAGS=() # Array to cleanly store additional meson setup arguments +COMPILE_FLAGS=() # Array to cleanly store additional meson compile arguments +INSTALL_FLAGS=() # Array to cleanly store additional meson install arguments -# --- Helper Functions --- -# Replicates $(call meson_build,flags,suffix) -meson_build() { +meson_setup() { local build_dir="build/meson_$2" - # If --clean was specified, delete the specific build directory first if [[ "$CLEAN_BUILD" == true ]]; then echo "--> Cleaning target build directory: ${build_dir}" - rm -rf "$build_dir" + rm -rf "$build_dir" # If --clean was specified, delete the specific build directory first fi - echo "--> Running Meson build for: $2" + echo "--> Running Meson setup for: $2" # Setup with --reconfigure, fallback to fresh setup. SETUP_FLAGS safely expands the array only if it's not empty - meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dgithub_repository="${GITHUB_REPOSITORY}" --native-file "${NATIVE_FILE}" --reconfigure 2>/dev/null || \ - meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dgithub_repository="${GITHUB_REPOSITORY}" --native-file "${NATIVE_FILE}" - meson compile -C "$build_dir" + meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dver_full="$VER_FULL" -Dver_githash="$VER_GITHASH" -Dbuild_date="${CPP_DATE}" -Dbuilder="${BUILDER}" --native-file "${NATIVE_FILE}" --reconfigure 2>/dev/null || \ + meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dver_full="$VER_FULL" -Dver_githash="$VER_GITHASH" -Dbuild_date="${CPP_DATE}" -Dbuilder="${BUILDER}" --native-file "${NATIVE_FILE}" +} + +meson_build() { + echo "--> Running Meson build for: $1" + meson compile -C "build/meson_$1" ${COMPILE_FLAGS[@]+"${COMPILE_FLAGS[@]}"} } meson_install() { echo "--> Running Meson install for: $1" - meson install -C "build/meson_$1" + meson install -C "build/meson_$1" ${INSTALL_FLAGS[@]+"${INSTALL_FLAGS[@]}"} } -# --- Script Help Menu --- -show_help() { +show_help() { # Script Help Menu echo "Usage: $0 [options] " echo "" echo "Options:" - echo -e " \033[36m--clean\033[0m Delete target build directory before compiling" - echo -e " \033[36m--setup-flags=\"...\"\033[0m Pass additional arguments directly to 'meson setup'" + echo -e " \033[36m--clean\033[0m Delete target build directory before compiling" + echo -e " \033[36m--setup-flags=\"...\"\033[0m Pass additional arguments directly to 'meson setup'" + echo -e " \033[36m--native-file=\"...\"\033[0m Specify native file (defaults to clang.ini)" + echo -e " \033[36m--ver-full=\"...\"\033[0m Specify full version string" + echo -e " \033[36m--github-repository=\"...\"\033[0m Specify target GitHub repository" echo "" echo "Targets:" - echo -e " \033[36mrelease\033[0m Build a test release executable" - echo -e " \033[36mrelease-deployment\033[0m Build a release deployment executable" - echo -e " \033[36mrelease-snapshot\033[0m Build a snapshot release executable" - echo -e " \033[36mdebug\033[0m Build a debug executable" - echo -e " \033[36minstall\033[0m Install the test release build" - echo -e " \033[36minstall-deployment\033[0m Install the release deployment build" - echo -e " \033[36minstall-snapshot\033[0m Install the snapshot release build" - echo -e " \033[36mtest\033[0m Run test suite (depends on release-snapshot)" - echo -e " \033[36mclean\033[0m Remove all generated build artifacts" - echo -e " \033[36mpkg-flatpak\033[0m Package a Flatpak application" - echo -e " \033[36mpkg-appimage\033[0m Package a test release AppImage" - echo -e " \033[36mpkg-appimage-deployment\033[0m Package a deployment AppImage" - echo -e " \033[36mpkg-appimage-snapshot\033[0m Package a snapshot AppImage" - echo -e " \033[36mpkg-win\033[0m Package a Windows NSIS test release installer" - echo -e " \033[36mpkg-win-deployment\033[0m Package a Windows NSIS deployment installer" - echo -e " \033[36mpkg-win-snapshot\033[0m Package a Windows NSIS snapshot installer" + echo -e " \033[36msetup-deployment\033[0m Setup a deployment release executable" + echo -e " \033[36msetup-test\033[0m Setup a test release executable" + echo -e " \033[36msetup-dev\033[0m Setup a dev release executable" + echo -e " \033[36msetup-debug\033[0m Setup a debug executable" + echo -e " \033[36mcompile-deployment\033[0m Compile a deployment release executable" + echo -e " \033[36mcompile-test\033[0m Compile a test release executable" + echo -e " \033[36mcompile-dev\033[0m Compile a dev release executable" + echo -e " \033[36mcompile-debug\033[0m Compile a debug executable" + echo -e " \033[36mbuild-deployment\033[0m Setup and compile a deployment release executable" + echo -e " \033[36mbuild-test\033[0m Setup and compile a test release executable" + echo -e " \033[36mbuild-dev\033[0m Setup and compile a dev release executable" + echo -e " \033[36mbuild-debug\033[0m Setup and compile a debug executable" + echo -e " \033[36minstall-deployment\033[0m Install the deployment release installation" + echo -e " \033[36minstall-test\033[0m Install the test release installation" + echo -e " \033[36minstall-dev\033[0m Install the dev release installation" + echo -e " \033[36minstall-debug\033[0m Install the debug installation" + echo -e " \033[36mtest\033[0m Run test suite (depends on build-dev)" + echo -e " \033[36mclean\033[0m Remove all generated build artifacts" + echo -e " \033[36mpkg-flatpak\033[0m Package a Flatpak application" + echo -e " \033[36mpkg-appimage-deployment\033[0m Package a Linux deployment release AppImage" + echo -e " \033[36mpkg-appimage-test\033[0m Package a Linux test release AppImage" + echo -e " \033[36mpkg-appimage-dev\033[0m Package a Linux dev release AppImage" + echo -e " \033[36mpkg-win-deployment\033[0m Package a Windows NSIS deployment release installer" + echo -e " \033[36mpkg-win-test\033[0m Package a Windows NSIS test release installer" + echo -e " \033[36mpkg-win-dev\033[0m Package a Windows NSIS dev release installer" } -# --- Target Execution Logic --- -execute_target() { +execute_target() { # Target Execution Logic case "$1" in - release) - meson_build "-Ddebug=false -Dstrip_bin=true -Db_lto=true" "release" + setup-deployment) + meson_setup "-Ddeployment_release=true -Ddebug=false -Dstrip_bin=true -Db_lto=true" "deployment" + ;; + setup-test) + meson_setup "-Ddebug=false -Dstrip_bin=true -Db_lto=true" "test" + ;; + setup-dev) + meson_setup "-Ddev_release=true -Ddebug=false -Dstrip_bin=false" "dev" ;; - release-deployment) - meson_build "-Ddeployment_release_configuration=true -Ddebug=false -Dstrip_bin=true -Db_lto=true" "deployment" + setup-debug) + meson_setup "-Ddebug=true -Dstrip_bin=false" "debug" ;; - release-snapshot) - meson_build "-Dsnapshot_build=true -Ddebug=false -Dstrip_bin=false" "snapshot" + compile-deployment) + meson_build "deployment" ;; - debug) - meson_build "-Ddebug=true -Dstrip_bin=false" "debug" + compile-test) + meson_build "test" ;; - install) - meson_install "release" + compile-dev) + meson_build "dev" + ;; + compile-debug) + meson_build "debug" + ;; + build-deployment) + execute_target "setup-deployment" + execute_target "compile-deployment" + ;; + build-test) + execute_target "setup-test" + execute_target "compile-test" + ;; + build-dev) + execute_target "setup-dev" + execute_target "compile-dev" + ;; + build-debug) + execute_target "setup-debug" + execute_target "compile-debug" ;; install-deployment) meson_install "deployment" ;; - install-snapshot) - meson_install "snapshot" + install-test) + meson_install "test" + ;; + install-dev) + meson_install "dev" + ;; + install-debug) + meson_install "debug" + ;; + test-deployment) + execute_target "build-deployment" + source tests/run_test_fn.sh && run_test + ;; + test-test) + execute_target "build-test" + source tests/run_test_fn.sh && run_test ;; - test) - execute_target "release-snapshot" + test-dev) + execute_target "build-dev" + source tests/run_test_fn.sh && run_test + ;; + test-debug) + execute_target "build-debug" source tests/run_test_fn.sh && run_test ;; clean) echo "--> Cleaning all build artifacts..." rm -rf build/meson_* ;; - pkg-flatpak) - source installers/flatpak/create_flatpak_fn.sh && create_flatpak + flatpak-deployment) # This is used internally by the flatpak YAML + execute_target "build-deployment" + source installers/flatpak/flatpak_postbuild_fn.sh && flatpak_postbuild meson_deployment/oolite.app "$VER_FULL" "$APP_DATE" ;; - pkg-appimage) - execute_target "release" - source installers/appimage/create_appimage_fn.sh && create_appimage meson_release/oolite.app "test" + pkg-flatpak) + source installers/flatpak/create_flatpak_fn.sh && create_flatpak "$VER_FULL" "$GITHUB_REPOSITORY" ;; pkg-appimage-deployment) - execute_target "release-deployment" - source installers/appimage/create_appimage_fn.sh && create_appimage meson_deployment/oolite.app + execute_target "build-deployment" + source installers/appimage/create_appimage_fn.sh && create_appimage meson_deployment/oolite.app "$VER_FULL" "$APP_DATE" "" ;; - pkg-appimage-snapshot) - execute_target "release-snapshot" - source installers/appimage/create_appimage_fn.sh && create_appimage meson_snapshot/oolite.app "dev" + pkg-appimage-test) + execute_target "build-test" + source installers/appimage/create_appimage_fn.sh && create_appimage meson_test/oolite.app "$VER_FULL" "$APP_DATE" "test" ;; - pkg-win) - execute_target "release" - source installers/win32/create_nsis_fn.sh && create_nsis meson_release/oolite.app "test" + pkg-appimage-dev) + execute_target "build-dev" + source installers/appimage/create_appimage_fn.sh && create_appimage meson_dev/oolite.app "$VER_FULL" "$APP_DATE" "dev" ;; pkg-win-deployment) - execute_target "release-deployment" - source installers/win32/create_nsis_fn.sh && create_nsis meson_deployment/oolite.app + execute_target "build-deployment" + source installers/win32/create_nsis_fn.sh && create_nsis meson_deployment/oolite.app "$VER_FULL" "$VER_GITREV" "$VER_GITHASH" "$BUILDTIME" "" + ;; + pkg-win-test) + execute_target "build-test" + source installers/win32/create_nsis_fn.sh && create_nsis meson_test/oolite.app "$VER_FULL" "$VER_GITREV" "$VER_GITHASH" "$BUILDTIME" "test" ;; - pkg-win-snapshot) - execute_target "release-snapshot" - source installers/win32/create_nsis_fn.sh && create_nsis meson_snapshot/oolite.app "dev" + pkg-win-dev) + execute_target "build-dev" + source installers/win32/create_nsis_fn.sh && create_nsis meson_dev/oolite.app "$VER_FULL" "$VER_GITREV" "$VER_GITHASH" "$BUILDTIME" "dev" ;; help|--help|-h) show_help @@ -157,21 +205,40 @@ execute_target() { esac } -# --- Flexible Argument Parser --- TARGET="" - -while [[ $# -gt 0 ]]; do +while [[ $# -gt 0 ]]; do # Flexible Argument Parser case "$1" in --clean) CLEAN_BUILD=true shift ;; --setup-flags=*) - # Handle inline assignment format (e.g., --setup-flags="-Dfoo=bar") read -r -a flags_array <<< "${1#*=}" SETUP_FLAGS+=("${flags_array[@]}") shift ;; + --compile-flags=*) + read -r -a flags_array <<< "${1#*=}" + COMPILE_FLAGS+=("${flags_array[@]}") + shift + ;; + --install-flags=*) + read -r -a flags_array <<< "${1#*=}" + INSTALL_FLAGS+=("${flags_array[@]}") + shift + ;; + --native-file=*) + NATIVE_FILE="${1#*=}" + shift + ;; + --ver-full=*) + VER_FULL="${1#*=}" + shift + ;; + --github-repository=*) + GITHUB_REPOSITORY="${1#*=}" + shift + ;; help|--help|-h) show_help exit 0 @@ -192,20 +259,24 @@ while [[ $# -gt 0 ]]; do esac done -# Fallback to help menu if no target was provided if [[ -z "$TARGET" ]]; then - show_help + show_help # Fallback to help menu if no target was provided exit 1 fi +if [[ -z "$NATIVE_FILE" ]]; then + NATIVE_FILE="clang.ini" # Apply default for NATIVE_FILE if it wasn't passed as a parameter +fi + +source ShellScripts/common/get_build_date_fn.sh && get_build_date CPP_DATE APP_DATE BUILDTIME BUILDER "$GITHUB_REPOSITORY" +source ShellScripts/common/get_version_fn.sh && get_version VER_FULL VER_NSIS VER_GITREV VER_GITHASH "$VER_FULL" execute_target "$TARGET" -# Successful Exit - remove the ERR trap so it doesn't accidentally fire during normal bailing. -trap - ERR + +trap - ERR # Successful Exit - remove the ERR trap so it doesn't accidentally fire during normal bailing popd > /dev/null -# Only print build success if it wasn't a help menu or a cleanup action if [[ "$TARGET" != "help" && "$TARGET" != "--help" && "$TARGET" != "-h" && "$TARGET" != "clean" ]]; then - echo "✅ Oolite target '$TARGET' completed successfully" + echo "✅ Oolite target '$TARGET' completed successfully" # Print success if not a help menu or a cleanup action fi if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then diff --git a/src/Core/OOLogHeader.m b/src/Core/OOLogHeader.m index c2522d6b0..1e19beb86 100644 --- a/src/Core/OOLogHeader.m +++ b/src/Core/OOLogHeader.m @@ -161,7 +161,7 @@ void OOPrintLogHeader(void) #endif NSString *versionString = nil; - #if (defined (SNAPSHOT_BUILD)) + #if (defined (DEV_RELEASE)) versionString = @"development version " @OO_VERSION_FULL; #else versionString = @"version " @OO_VERSION_FULL; diff --git a/src/Core/Universe.m b/src/Core/Universe.m index 68138c75e..bd8ecc0ce 100644 --- a/src/Core/Universe.m +++ b/src/Core/Universe.m @@ -5243,7 +5243,7 @@ - (void) drawUniverse // should come after the HUD to avoid it being overlapped by it [self drawMessage]; -#if (defined (SNAPSHOT_BUILD)) +#if (defined (DEV_RELEASE)) [self drawWatermarkString:@"Development version " @OO_VERSION_FULL]; #endif diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index 1a9a19ace..a33b942b1 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -144,11 +144,7 @@ - (NSMutableDictionary *) getNativeSize - (NSString*) getWindowCaption { -#ifdef BUILD_DATE - NSString *caption = [NSString stringWithFormat:@"Oolite v%@ by %@ - %s", @OO_VERSION_FULL, @OO_BUILDER, BUILD_DATE]; -#else - NSString *caption = [NSString stringWithFormat:@"Oolite v%@ by %@ - %s", @OO_VERSION_FULL, @OO_BUILDER, __DATE__]; -#endif + NSString *caption = [NSString stringWithFormat:@"Oolite v%@ by %@ - %@", @OO_VERSION_FULL, @OO_BUILDER, @OO_BUILD_DATE]; return [[caption retain] autorelease]; } diff --git a/src/meson.build b/src/meson.build index 55f9e304d..ad8b1c374 100644 --- a/src/meson.build +++ b/src/meson.build @@ -37,40 +37,36 @@ oolite_bin = executable( prog_dir = meson.global_build_root() / appname + '.app' stamp_file = '.oolite_bundle.stamp' -post_build_env_args = [ - 'ORIGPROGPATH=' + meson.current_build_dir() / appname, - 'PROGDIR=' + prog_dir, - 'HOST_OS=' + host_os, - 'DEBUG=' + (get_option('debug') ? 'yes' : 'no'), - 'DEPLOYMENT_RELEASE_CONFIGURATION=' + ( - get_option('deployment_release_configuration') ? 'yes' : 'no' - ), - 'ESPEAK=' + (get_option('espeak') ? 'yes' : 'no'), - 'STRIP_BIN=' + (get_option('strip_bin') ? 'yes' : 'no'), - 'VER_FULL=' + version_string, - 'GNUSTEP_FOLDER=' + gnustep_folder, - 'STAMP_FILE=' + stamp_file, +post_build_args = [ + meson.current_build_dir() / appname, + prog_dir, + host_os, + get_option('debug') ? 'yes' : 'no', + get_option('deployment_release') ? 'yes' : 'no', + get_option('espeak') ? 'yes' : 'no', + get_option('strip_bin') ? 'yes' : 'no', + version_string, + get_option('ver_githash'), + gnustep_folder, + stamp_file, ] post_build_script = find_program('../ShellScripts/common/post_build.sh') oolite_app_bundle = custom_target('post_build', input: oolite_bin, output: stamp_file, - depend_files: [post_build_script.full_path()], command: [ - 'env', - post_build_env_args, - post_build_script.full_path(), + post_build_script, + post_build_args, ], build_by_default: true, install: false, ) -install_env_args = [ - 'STAGEPROGPATH=' + prog_dir / appname, - 'BINDIR=' + get_option('bindir'), - 'DATADIR=' + get_option('datadir'), - 'HOST_OS=' + host_os, - 'DEPLOYMENT_RELEASE_CONFIGURATION=' + ( - get_option('deployment_release_configuration') ? 'yes' : 'no'), +install_args = [ + prog_dir / appname, + get_option('bindir'), + get_option('datadir'), + host_os, + get_option('deployment_release') ? 'yes' : 'no', ] install_script = find_program('../ShellScripts/common/install.sh') -meson.add_install_script('env', install_env_args, install_script.full_path()) \ No newline at end of file +meson.add_install_script(install_script, install_args) From 4a9e977e1bf8e50986683839fd82ce9072bb1226 Mon Sep 17 00:00:00 2001 From: mcarans Date: Sat, 27 Jun 2026 19:52:18 +1200 Subject: [PATCH 04/19] Fix test Fix Windows --- ShellScripts/common/get_version_fn.sh | 6 +++--- mk.sh | 21 +++++++++++++-------- tests/run_test_fn.sh | 6 +++--- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ShellScripts/common/get_version_fn.sh b/ShellScripts/common/get_version_fn.sh index 5db99861e..12e6db1cc 100755 --- a/ShellScripts/common/get_version_fn.sh +++ b/ShellScripts/common/get_version_fn.sh @@ -18,6 +18,9 @@ get_version() { local -n output_ver_gitrev=$3 local -n output_ver_githash=$4 + output_ver_gitrev=$(git rev-list --count HEAD) + output_ver_githash=$(git rev-parse --short=7 HEAD) + if [[ -n "$5" ]]; then # VER_FULL already populated return 0 fi @@ -47,7 +50,4 @@ get_version() { output_ver_full="${ver_semver}+dirty.${ver_uncommitted}" output_ver_nsis="$ver_maj.$ver_min.$ver_rev.$ver_uncommitted" fi - - output_ver_gitrev=$(git rev-list --count HEAD) - output_ver_githash=$(git rev-parse --short=7 HEAD) } \ No newline at end of file diff --git a/mk.sh b/mk.sh index b8fd481e4..b6b24d3ef 100755 --- a/mk.sh +++ b/mk.sh @@ -28,6 +28,11 @@ CLEAN_BUILD=false SETUP_FLAGS=() # Array to cleanly store additional meson setup arguments COMPILE_FLAGS=() # Array to cleanly store additional meson compile arguments INSTALL_FLAGS=() # Array to cleanly store additional meson install arguments +if [[ -v MINGW_PREFIX ]]; then + meson() { # Windows path override + PATH="$MINGW_PREFIX/bin:$PATH" command meson "$@" + } +fi meson_setup() { local build_dir="build/meson_$2" @@ -144,20 +149,20 @@ execute_target() { # Target Execution Logic meson_install "debug" ;; test-deployment) - execute_target "build-deployment" - source tests/run_test_fn.sh && run_test + echo "❌ Cannot test deployment as not set up for debug console!" >&2 + exit 1 ;; test-test) execute_target "build-test" - source tests/run_test_fn.sh && run_test + source tests/run_test_fn.sh && run_test "test" ;; test-dev) execute_target "build-dev" - source tests/run_test_fn.sh && run_test + source tests/run_test_fn.sh && run_test "dev" ;; test-debug) execute_target "build-debug" - source tests/run_test_fn.sh && run_test + source tests/run_test_fn.sh && run_test "debug" ;; clean) echo "--> Cleaning all build artifacts..." @@ -198,7 +203,7 @@ execute_target() { # Target Execution Logic show_help ;; *) - echo "Error: Unknown target '$1'" >&2 + echo "❌ Unknown target '$1'" >&2 show_help exit 1 ;; @@ -244,13 +249,13 @@ while [[ $# -gt 0 ]]; do # Flexible Argument Parser exit 0 ;; -*) - echo "Error: Unknown option '$1'" >&2 + echo "❌ Unknown option '$1'" >&2 show_help exit 1 ;; *) if [[ -n "$TARGET" ]]; then - echo "Error: Multiple targets specified ('$TARGET' and '$1'). Only one target allowed." >&2 + echo "❌ Multiple targets specified ('$TARGET' and '$1'). Only one target allowed." >&2 exit 1 fi TARGET="$1" diff --git a/tests/run_test_fn.sh b/tests/run_test_fn.sh index 1da802206..5061c75e5 100755 --- a/tests/run_test_fn.sh +++ b/tests/run_test_fn.sh @@ -22,10 +22,10 @@ run_test() { local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" - local BUILD_TYPE="${1:-snapshot}" + local BUILD_TYPE="${1:-dev}" local TARGET_DIR=$(readlink -f "../build/meson_${BUILD_TYPE}/oolite.app") - if [[ -n "$MSYSTEM" ]]; then - local MESA_DLL="${MSYSTEM_PREFIX}/bin/opengl32.dll" + if [[ -v MINGW_PREFIX ]]; then + local MESA_DLL="${MINGW_PREFIX}/bin/opengl32.dll" if [[ -f "$MESA_DLL" ]]; then echo "📦 Copying $MSYSTEM Mesa driver at $MESA_DLL" cp "$MESA_DLL" "$TARGET_DIR/" From 0f975f31212cb8ac392074c51e9c268c01fede2a Mon Sep 17 00:00:00 2001 From: mcarans Date: Sat, 27 Jun 2026 20:14:10 +1200 Subject: [PATCH 05/19] Try to install gitversion for flatpak build --- .github/workflows/build-all.yaml | 9 +++++++++ ShellScripts/Linux/os_detection.sh | 5 ++++- installers/flatpak/create_flatpak_fn.sh | 11 ----------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index 8ddd479e4..e87a91e56 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -78,6 +78,15 @@ jobs: fetch-depth: 0 - name: Build flatpak run: | + echo "Installing gitversion..." + source ShellScripts/common/download_github_fn.sh + OUTPUTDIR="." + download_latest_release gitversion_tgz "GitTools" "GitVersion" "linux-x64" "$OUTPUTDIR" + tar xfz ${gitversion_tgz} --directory "$OUTPUTDIR" + chmod +x "$OUTPUTDIR/gitversion" + mkdir -p /usr/local/bin + mv "$OUTPUTDIR/gitversion" /usr/local/bin/gitversion + rm -f ${gitversion_tgz} ./mk.sh pkg-flatpak --github-repository="$GITHUB_REPOSITORY" - name: Archive installer uses: actions/upload-artifact@v6 diff --git a/ShellScripts/Linux/os_detection.sh b/ShellScripts/Linux/os_detection.sh index 20e62ab61..bbffc97a6 100644 --- a/ShellScripts/Linux/os_detection.sh +++ b/ShellScripts/Linux/os_detection.sh @@ -5,7 +5,10 @@ if [ -f /etc/os-release ]; then . /etc/os-release - OS_FAMILY="${ID} ${ID_LIKE}" + if [[ -v ID_LIKE ]]; then + OS_FAMILY="${ID} ${ID_LIKE}" + else + OS_FAMILY="${ID}" else echo "❌ /etc/os-release not found - cannot detect OS!" >&2 exit 1 diff --git a/installers/flatpak/create_flatpak_fn.sh b/installers/flatpak/create_flatpak_fn.sh index 681077bb3..09c3517b3 100755 --- a/installers/flatpak/create_flatpak_fn.sh +++ b/installers/flatpak/create_flatpak_fn.sh @@ -10,17 +10,6 @@ create_flatpak() { cd ../.. mkdir -p build cd build - if ! command -v gitversion &> /dev/null; then - echo "Installing gitversion..." - source ../ShellScripts/common/download_github_fn.sh - local outputdir="." - download_latest_release gitversion_tgz "GitTools" "GitVersion" "linux-x64" "$outputdir" - tar xfz ${gitversion_tgz} --directory "$outputdir" - chmod +x "$outputdir/gitversion" - mkdir -p /usr/local/bin - mv "$outputdir/gitversion" /usr/local/bin/gitversion - rm -f ${gitversion_tgz} - fi cp ../installers/flatpak/space.oolite.Oolite.* ./ From abb006c8ea4e456ad49770cc1300d03c1896a650 Mon Sep 17 00:00:00 2001 From: mcarans Date: Sat, 27 Jun 2026 20:14:54 +1200 Subject: [PATCH 06/19] Try to install gitversion for flatpak build --- ShellScripts/Linux/os_detection.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ShellScripts/Linux/os_detection.sh b/ShellScripts/Linux/os_detection.sh index bbffc97a6..8dc20794e 100644 --- a/ShellScripts/Linux/os_detection.sh +++ b/ShellScripts/Linux/os_detection.sh @@ -9,6 +9,7 @@ if [ -f /etc/os-release ]; then OS_FAMILY="${ID} ${ID_LIKE}" else OS_FAMILY="${ID}" + fi else echo "❌ /etc/os-release not found - cannot detect OS!" >&2 exit 1 From efbc83ee4ce24cd4590f3e2715995ca71697bb33 Mon Sep 17 00:00:00 2001 From: mcarans Date: Sat, 27 Jun 2026 20:32:35 +1200 Subject: [PATCH 07/19] Try to fix Windows path --- installers/win32/create_nsis_fn.sh | 2 +- mk.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/installers/win32/create_nsis_fn.sh b/installers/win32/create_nsis_fn.sh index 3371e1b31..7415a4e43 100644 --- a/installers/win32/create_nsis_fn.sh +++ b/installers/win32/create_nsis_fn.sh @@ -71,7 +71,7 @@ create_nsis() { fi local nsis - if [[ -n "$MINGW_PREFIX" ]]; then + if [[ -v MINGW_PREFIX ]]; then nsis=$MINGW_PREFIX/bin/makensis else nsis=/nsis/makensis.exe diff --git a/mk.sh b/mk.sh index b6b24d3ef..697d9f8d9 100755 --- a/mk.sh +++ b/mk.sh @@ -30,7 +30,7 @@ COMPILE_FLAGS=() # Array to cleanly store additional meson compile arguments INSTALL_FLAGS=() # Array to cleanly store additional meson install arguments if [[ -v MINGW_PREFIX ]]; then meson() { # Windows path override - PATH="$MINGW_PREFIX/bin:$PATH" command meson "$@" + PATH="$MINGW_PREFIX/bin:/usr/bin:$PATH" command meson "$@" } fi @@ -41,6 +41,7 @@ meson_setup() { rm -rf "$build_dir" # If --clean was specified, delete the specific build directory first fi echo "--> Running Meson setup for: $2" + type meson # for debugging # Setup with --reconfigure, fallback to fresh setup. SETUP_FLAGS safely expands the array only if it's not empty meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dver_full="$VER_FULL" -Dver_githash="$VER_GITHASH" -Dbuild_date="${CPP_DATE}" -Dbuilder="${BUILDER}" --native-file "${NATIVE_FILE}" --reconfigure 2>/dev/null || \ meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dver_full="$VER_FULL" -Dver_githash="$VER_GITHASH" -Dbuild_date="${CPP_DATE}" -Dbuilder="${BUILDER}" --native-file "${NATIVE_FILE}" From 4a1bdfadef3399cc6831ce0c358d2ddb6f8b65b0 Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 28 Jun 2026 09:35:07 +1200 Subject: [PATCH 08/19] Windows locally builds. Try fix CI --- .github/workflows/build-all.yaml | 2 ++ mk.sh | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index e87a91e56..9b7da8e9e 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -114,8 +114,10 @@ jobs: - name: Set up MSYS2 uses: msys2/setup-msys2@v2 with: + msystem: UCRT64 update: true cache: false + path-type: minimal - name: Checkout Oolite uses: actions/checkout@v6 with: diff --git a/mk.sh b/mk.sh index 697d9f8d9..ff21cd55f 100755 --- a/mk.sh +++ b/mk.sh @@ -4,6 +4,7 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$SCRIPT_DIR" > /dev/null set -u -o pipefail # Strict expansions +which bash # --- Error Handling Trap --- cleanup_and_exit() { @@ -28,11 +29,6 @@ CLEAN_BUILD=false SETUP_FLAGS=() # Array to cleanly store additional meson setup arguments COMPILE_FLAGS=() # Array to cleanly store additional meson compile arguments INSTALL_FLAGS=() # Array to cleanly store additional meson install arguments -if [[ -v MINGW_PREFIX ]]; then - meson() { # Windows path override - PATH="$MINGW_PREFIX/bin:/usr/bin:$PATH" command meson "$@" - } -fi meson_setup() { local build_dir="build/meson_$2" @@ -41,7 +37,6 @@ meson_setup() { rm -rf "$build_dir" # If --clean was specified, delete the specific build directory first fi echo "--> Running Meson setup for: $2" - type meson # for debugging # Setup with --reconfigure, fallback to fresh setup. SETUP_FLAGS safely expands the array only if it's not empty meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dver_full="$VER_FULL" -Dver_githash="$VER_GITHASH" -Dbuild_date="${CPP_DATE}" -Dbuilder="${BUILDER}" --native-file "${NATIVE_FILE}" --reconfigure 2>/dev/null || \ meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dver_full="$VER_FULL" -Dver_githash="$VER_GITHASH" -Dbuild_date="${CPP_DATE}" -Dbuilder="${BUILDER}" --native-file "${NATIVE_FILE}" From 5ede762f2927c3c1f4bc80511ed220db2efd4dfe Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 28 Jun 2026 09:48:47 +1200 Subject: [PATCH 09/19] Force bash on Windows in CI --- .github/workflows/build-all.yaml | 1 - mk.sh | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index 9b7da8e9e..18f8e7948 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -117,7 +117,6 @@ jobs: msystem: UCRT64 update: true cache: false - path-type: minimal - name: Checkout Oolite uses: actions/checkout@v6 with: diff --git a/mk.sh b/mk.sh index ff21cd55f..a9065a9ed 100755 --- a/mk.sh +++ b/mk.sh @@ -4,7 +4,10 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$SCRIPT_DIR" > /dev/null set -u -o pipefail # Strict expansions -which bash + +if [[ -v MINGW_PREFIX ]]; then + export BASH="$(cygpath -w /usr/bin/bash.exe)" +fi # --- Error Handling Trap --- cleanup_and_exit() { From b31e571e612073c6def4b55563e9ecfc576d4a11 Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 28 Jun 2026 09:55:38 +1200 Subject: [PATCH 10/19] Explicitly find bash in meson --- mk.sh | 4 ---- src/meson.build | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mk.sh b/mk.sh index a9065a9ed..483c40a28 100755 --- a/mk.sh +++ b/mk.sh @@ -5,10 +5,6 @@ pushd "$SCRIPT_DIR" > /dev/null set -u -o pipefail # Strict expansions -if [[ -v MINGW_PREFIX ]]; then - export BASH="$(cygpath -w /usr/bin/bash.exe)" -fi - # --- Error Handling Trap --- cleanup_and_exit() { local exit_code=$? diff --git a/src/meson.build b/src/meson.build index ad8b1c374..d3126ffc4 100644 --- a/src/meson.build +++ b/src/meson.build @@ -35,6 +35,7 @@ oolite_bin = executable( install: false, ) +bash_prog = find_program('bash') prog_dir = meson.global_build_root() / appname + '.app' stamp_file = '.oolite_bundle.stamp' post_build_args = [ @@ -55,6 +56,7 @@ oolite_app_bundle = custom_target('post_build', input: oolite_bin, output: stamp_file, command: [ + bash_prog, post_build_script, post_build_args, ], From dd2fb55682133f52f680531df3234d70879e5c20 Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 28 Jun 2026 09:57:05 +1200 Subject: [PATCH 11/19] Explicitly find bash in meson --- src/meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/meson.build b/src/meson.build index d3126ffc4..7ba71670a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -51,7 +51,7 @@ post_build_args = [ gnustep_folder, stamp_file, ] -post_build_script = find_program('../ShellScripts/common/post_build.sh') +post_build_script = files('../ShellScripts/common/post_build.sh') oolite_app_bundle = custom_target('post_build', input: oolite_bin, output: stamp_file, @@ -70,5 +70,5 @@ install_args = [ host_os, get_option('deployment_release') ? 'yes' : 'no', ] -install_script = find_program('../ShellScripts/common/install.sh') -meson.add_install_script(install_script, install_args) +install_script = files('../ShellScripts/common/install.sh') +meson.add_install_script(bash_prog, install_script, install_args) From 92b318ac24874064265f0c09f962d1629ae1eff0 Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 28 Jun 2026 10:18:16 +1200 Subject: [PATCH 12/19] update README --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b87409bdf..a684b37dd 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ default, but you can supply a further argument to specify an alternative like do Next run this in your Bash or MSYS2 prompt to build Oolite: ```bash -./mk.sh release-dev +./mk.sh build-dev ``` The completed build (executable and games files) can be found in the oolite.app directory. @@ -134,7 +134,7 @@ Subsequently, you can clean and build as follows: ```bash ./mk.sh clean -./mk.sh release-dev +./mk.sh build-dev ``` You can run a test that launches the game and takes a snapshot from your Bash or MSYS2 prompt as follows: @@ -143,8 +143,8 @@ You can run a test that launches the game and takes a snapshot from your Bash or ./mk.sh test ``` -release-dev keeps debug symbols in the binary. Other release targets remove those symbols from the binary although they -are made available in a separate symbols file. release-deployment is for a production release and release-test is for a +build-dev keeps debug symbols in the binary. Other build targets remove those symbols from the binary although they +are made available in a separate symbols file. build-deployment is for a production build and build-test is for a test release that supports the debug console which is used by expansion developers for debugging their OXPs. You can install: @@ -155,11 +155,11 @@ You can install: Other targets are install-deployment for a production install and install-test for a test install. -The underlying build system is Meson. You can run the deployment build directly using Meson build commands like this: +The underlying build system is Meson, but it is recommended to run via the mk.sh script which also allow you to pass +meson setup, compile and install flags. Type the following for help: ```bash -meson setup build/meson_deployment -Ddeployment_release=true -Ddebug=false -Dstrip_bin=true -Db_lto=true --native-file clang.ini --reconfigure -meson compile -C build/meson_deployment +./mk.sh help ``` ### Other Linux ./mk.sh Targets From 9dcaaf4da190449f165db02ec4c9bf665b54ab57 Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 28 Jun 2026 10:20:46 +1200 Subject: [PATCH 13/19] update README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a684b37dd..0125f1be7 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ You can run a test that launches the game and takes a snapshot from your Bash or build-dev keeps debug symbols in the binary. Other build targets remove those symbols from the binary although they are made available in a separate symbols file. build-deployment is for a production build and build-test is for a -test release that supports the debug console which is used by expansion developers for debugging their OXPs. +test release that supports the debug console which is used by expansion developers for debugging their OXPs. You can install: @@ -162,6 +162,9 @@ meson setup, compile and install flags. Type the following for help: ./mk.sh help ``` +build-dev runs 2 targets which can be run independently: setup-dev which runs meson setup and compile-dev which runs +meson compile. + ### Other Linux ./mk.sh Targets This target builds an AppImage for development which can be found in the `build` fodler: From ca72ee64ccef90f37c79e5eb0413a9043e8f4dfc Mon Sep 17 00:00:00 2001 From: mcarans Date: Mon, 29 Jun 2026 07:03:06 +1200 Subject: [PATCH 14/19] Fix README.md Add missing help descriptions --- README.md | 2 +- mk.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0125f1be7..004930571 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ Next run this in your Bash or MSYS2 prompt to build Oolite: ./mk.sh build-dev ``` -The completed build (executable and games files) can be found in the oolite.app directory. +The completed build (executable and games files) can be found in the build/meson_dev/oolite.app directory. Subsequently, you can clean and build as follows: diff --git a/mk.sh b/mk.sh index 483c40a28..35d4668f0 100755 --- a/mk.sh +++ b/mk.sh @@ -57,6 +57,8 @@ show_help() { # Script Help Menu echo "Options:" echo -e " \033[36m--clean\033[0m Delete target build directory before compiling" echo -e " \033[36m--setup-flags=\"...\"\033[0m Pass additional arguments directly to 'meson setup'" + echo -e " \033[36m--compile-flags=\"...\"\033[0m Pass additional arguments directly to 'meson compile'" + echo -e " \033[36m--install-flags=\"...\"\033[0m Pass additional arguments directly to 'meson install'" echo -e " \033[36m--native-file=\"...\"\033[0m Specify native file (defaults to clang.ini)" echo -e " \033[36m--ver-full=\"...\"\033[0m Specify full version string" echo -e " \033[36m--github-repository=\"...\"\033[0m Specify target GitHub repository" From decdf5e98cdf33b0d0540b79f10c864acb1fe57f Mon Sep 17 00:00:00 2001 From: mcarans Date: Mon, 29 Jun 2026 16:36:29 +1200 Subject: [PATCH 15/19] Make help columns line up perfectly --- mk.sh | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/mk.sh b/mk.sh index 35d4668f0..e66a6ea8a 100755 --- a/mk.sh +++ b/mk.sh @@ -55,40 +55,40 @@ show_help() { # Script Help Menu echo "Usage: $0 [options] " echo "" echo "Options:" - echo -e " \033[36m--clean\033[0m Delete target build directory before compiling" + echo -e " \033[36m--clean\033[0m Delete target build directory before compiling" echo -e " \033[36m--setup-flags=\"...\"\033[0m Pass additional arguments directly to 'meson setup'" - echo -e " \033[36m--compile-flags=\"...\"\033[0m Pass additional arguments directly to 'meson compile'" - echo -e " \033[36m--install-flags=\"...\"\033[0m Pass additional arguments directly to 'meson install'" + echo -e " \033[36m--compile-flags=\"...\"\033[0m Pass additional arguments directly to 'meson compile'" + echo -e " \033[36m--install-flags=\"...\"\033[0m Pass additional arguments directly to 'meson install'" echo -e " \033[36m--native-file=\"...\"\033[0m Specify native file (defaults to clang.ini)" echo -e " \033[36m--ver-full=\"...\"\033[0m Specify full version string" echo -e " \033[36m--github-repository=\"...\"\033[0m Specify target GitHub repository" echo "" echo "Targets:" - echo -e " \033[36msetup-deployment\033[0m Setup a deployment release executable" - echo -e " \033[36msetup-test\033[0m Setup a test release executable" - echo -e " \033[36msetup-dev\033[0m Setup a dev release executable" - echo -e " \033[36msetup-debug\033[0m Setup a debug executable" - echo -e " \033[36mcompile-deployment\033[0m Compile a deployment release executable" - echo -e " \033[36mcompile-test\033[0m Compile a test release executable" - echo -e " \033[36mcompile-dev\033[0m Compile a dev release executable" - echo -e " \033[36mcompile-debug\033[0m Compile a debug executable" - echo -e " \033[36mbuild-deployment\033[0m Setup and compile a deployment release executable" - echo -e " \033[36mbuild-test\033[0m Setup and compile a test release executable" - echo -e " \033[36mbuild-dev\033[0m Setup and compile a dev release executable" - echo -e " \033[36mbuild-debug\033[0m Setup and compile a debug executable" - echo -e " \033[36minstall-deployment\033[0m Install the deployment release installation" - echo -e " \033[36minstall-test\033[0m Install the test release installation" - echo -e " \033[36minstall-dev\033[0m Install the dev release installation" - echo -e " \033[36minstall-debug\033[0m Install the debug installation" - echo -e " \033[36mtest\033[0m Run test suite (depends on build-dev)" - echo -e " \033[36mclean\033[0m Remove all generated build artifacts" - echo -e " \033[36mpkg-flatpak\033[0m Package a Flatpak application" - echo -e " \033[36mpkg-appimage-deployment\033[0m Package a Linux deployment release AppImage" - echo -e " \033[36mpkg-appimage-test\033[0m Package a Linux test release AppImage" - echo -e " \033[36mpkg-appimage-dev\033[0m Package a Linux dev release AppImage" - echo -e " \033[36mpkg-win-deployment\033[0m Package a Windows NSIS deployment release installer" - echo -e " \033[36mpkg-win-test\033[0m Package a Windows NSIS test release installer" - echo -e " \033[36mpkg-win-dev\033[0m Package a Windows NSIS dev release installer" + echo -e " \033[36msetup-deployment\033[0m Setup a deployment release executable" + echo -e " \033[36msetup-test\033[0m Setup a test release executable" + echo -e " \033[36msetup-dev\033[0m Setup a dev release executable" + echo -e " \033[36msetup-debug\033[0m Setup a debug executable" + echo -e " \033[36mcompile-deployment\033[0m Compile a deployment release executable" + echo -e " \033[36mcompile-test\033[0m Compile a test release executable" + echo -e " \033[36mcompile-dev\033[0m Compile a dev release executable" + echo -e " \033[36mcompile-debug\033[0m Compile a debug executable" + echo -e " \033[36mbuild-deployment\033[0m Setup and compile a deployment release executable" + echo -e " \033[36mbuild-test\033[0m Setup and compile a test release executable" + echo -e " \033[36mbuild-dev\033[0m Setup and compile a dev release executable" + echo -e " \033[36mbuild-debug\033[0m Setup and compile a debug executable" + echo -e " \033[36minstall-deployment\033[0m Install the deployment release installation" + echo -e " \033[36minstall-test\033[0m Install the test release installation" + echo -e " \033[36minstall-dev\033[0m Install the dev release installation" + echo -e " \033[36minstall-debug\033[0m Install the debug installation" + echo -e " \033[36mtest\033[0m Run test suite (depends on build-dev)" + echo -e " \033[36mclean\033[0m Remove all generated build artifacts" + echo -e " \033[36mpkg-flatpak\033[0m Package a Flatpak application" + echo -e " \033[36mpkg-appimage-deployment\033[0m Package a Linux deployment release AppImage" + echo -e " \033[36mpkg-appimage-test\033[0m Package a Linux test release AppImage" + echo -e " \033[36mpkg-appimage-dev\033[0m Package a Linux dev release AppImage" + echo -e " \033[36mpkg-win-deployment\033[0m Package a Windows NSIS deployment release installer" + echo -e " \033[36mpkg-win-test\033[0m Package a Windows NSIS test release installer" + echo -e " \033[36mpkg-win-dev\033[0m Package a Windows NSIS dev release installer" } execute_target() { # Target Execution Logic From ebfc664c75024f95ec5b9b831a88186b0390a1ca Mon Sep 17 00:00:00 2001 From: mcarans Date: Mon, 29 Jun 2026 16:37:39 +1200 Subject: [PATCH 16/19] Fix README --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 004930571..62a3dd511 100644 --- a/README.md +++ b/README.md @@ -133,8 +133,7 @@ The completed build (executable and games files) can be found in the build/meson Subsequently, you can clean and build as follows: ```bash -./mk.sh clean -./mk.sh build-dev +./mk.sh build-dev --clean ``` You can run a test that launches the game and takes a snapshot from your Bash or MSYS2 prompt as follows: From 05ebaeb0b32f34f35da5f53941692f94b693b94e Mon Sep 17 00:00:00 2001 From: mcarans Date: Mon, 29 Jun 2026 16:44:03 +1200 Subject: [PATCH 17/19] Fix install_deps.sh --- ShellScripts/Windows/install_deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShellScripts/Windows/install_deps.sh b/ShellScripts/Windows/install_deps.sh index e0424de02..709b4b715 100755 --- a/ShellScripts/Windows/install_deps.sh +++ b/ShellScripts/Windows/install_deps.sh @@ -58,6 +58,7 @@ run_script() { pacboy -S mesa --noconfirm pacboy -S sdl3 --noconfirm + mkdir -p ../../build/packages cd ../../build # install gitversion local outputdir="." @@ -67,7 +68,6 @@ run_script() { mv "$outputdir/gitversion.exe" "$MINGW_PREFIX/bin/gitversion.exe" rm -f ${gitversion_zip} - mkdir -p packages cd packages curl -s "$oolite_deps_url" | \ grep -oP '"browser_download_url": "\K[^"]+' | \ From beec7c57a11120f3ac1c183fda0ee7c3bfb292a7 Mon Sep 17 00:00:00 2001 From: mcarans Date: Thu, 2 Jul 2026 14:33:51 +1200 Subject: [PATCH 18/19] Make an install Gitversion function for Linux to avoid copy paste coding --- .github/workflows/build-all.yaml | 9 ++------ ShellScripts/Linux/install_gitversion_fn.sh | 22 +++++++++++++++++++ ShellScripts/Linux/install_packages_root.sh | 12 +++------- ShellScripts/Windows/install_deps.sh | 4 ++-- ...ub_fn.sh => download_github_release_fn.sh} | 2 +- 5 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 ShellScripts/Linux/install_gitversion_fn.sh rename ShellScripts/common/{download_github_fn.sh => download_github_release_fn.sh} (98%) diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index 18f8e7948..8b7f018ec 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -79,14 +79,9 @@ jobs: - name: Build flatpak run: | echo "Installing gitversion..." - source ShellScripts/common/download_github_fn.sh - OUTPUTDIR="." - download_latest_release gitversion_tgz "GitTools" "GitVersion" "linux-x64" "$OUTPUTDIR" - tar xfz ${gitversion_tgz} --directory "$OUTPUTDIR" - chmod +x "$OUTPUTDIR/gitversion" + source ShellScripts/Linux/install_gitversion_fn.sh mkdir -p /usr/local/bin - mv "$OUTPUTDIR/gitversion" /usr/local/bin/gitversion - rm -f ${gitversion_tgz} + install_gitversion "." ./mk.sh pkg-flatpak --github-repository="$GITHUB_REPOSITORY" - name: Archive installer uses: actions/upload-artifact@v6 diff --git a/ShellScripts/Linux/install_gitversion_fn.sh b/ShellScripts/Linux/install_gitversion_fn.sh new file mode 100644 index 000000000..cc4deffe4 --- /dev/null +++ b/ShellScripts/Linux/install_gitversion_fn.sh @@ -0,0 +1,22 @@ +install_gitversion() { + local outputdir="$1" + + # If current user ID is NOT 0 (root) + if [[ $EUID -ne 0 ]]; then + echo "This script requires root to install dependencies. Rerun and escalate privileges (eg. sudo ...)" + return 1 + fi + + local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) + pushd "$script_dir" + + source ../common/download_github_release_fn.sh + + download_github_release gitversion_tgz "GitTools" "GitVersion" "linux-x64" "$outputdir" + tar xfz ${gitversion_tgz} --directory "$outputdir" + chmod +x "$outputdir/gitversion" + mv "$outputdir/gitversion" /usr/local/bin/gitversion + rm -f ${gitversion_tgz} + + popd +} \ No newline at end of file diff --git a/ShellScripts/Linux/install_packages_root.sh b/ShellScripts/Linux/install_packages_root.sh index 5d3672c79..ddd9a31a5 100755 --- a/ShellScripts/Linux/install_packages_root.sh +++ b/ShellScripts/Linux/install_packages_root.sh @@ -14,9 +14,8 @@ run_script() { local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" - source ../common/download_github_fn.sh - - source ./install_package_fn.sh + source install_gitversion_fn.sh + source install_package_fn.sh if ! install_package base-devel; then return 1 @@ -101,12 +100,7 @@ run_script() { # install gitversion local outputdir="../../build" mkdir -p "$outputdir" - download_latest_release gitversion_tgz "GitTools" "GitVersion" "linux-x64" "$outputdir" - tar xfz ${gitversion_tgz} --directory "$outputdir" - chmod +x "$outputdir/gitversion" - mv "$outputdir/gitversion" /usr/local/bin/gitversion - rm -f ${gitversion_tgz} - + install_gitversion "$outputdir" popd } diff --git a/ShellScripts/Windows/install_deps.sh b/ShellScripts/Windows/install_deps.sh index 709b4b715..0a2ecd1c2 100755 --- a/ShellScripts/Windows/install_deps.sh +++ b/ShellScripts/Windows/install_deps.sh @@ -35,7 +35,7 @@ run_script() { local script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$script_dir" - source ../common/download_github_fn.sh + source ../common/download_github_release_fn.sh local oolite_deps_url="https://api.github.com/repos/OoliteProject/oolite_windeps_build/releases/latest" @@ -62,7 +62,7 @@ run_script() { cd ../../build # install gitversion local outputdir="." - download_latest_release gitversion_zip "GitTools" "GitVersion" "win-x64" "$outputdir" + download_github_release gitversion_zip "GitTools" "GitVersion" "win-x64" "$outputdir" unzip -o ${gitversion_zip} -d "$outputdir" chmod +x "$outputdir/gitversion.exe" mv "$outputdir/gitversion.exe" "$MINGW_PREFIX/bin/gitversion.exe" diff --git a/ShellScripts/common/download_github_fn.sh b/ShellScripts/common/download_github_release_fn.sh similarity index 98% rename from ShellScripts/common/download_github_fn.sh rename to ShellScripts/common/download_github_release_fn.sh index 6b0b95ecd..74ed92a60 100755 --- a/ShellScripts/common/download_github_fn.sh +++ b/ShellScripts/common/download_github_release_fn.sh @@ -1,6 +1,6 @@ #!/bin/bash -download_latest_release() { +download_github_release() { local -n downloaded_file="$1" local owner="$2" local repository="$3" From 59e3b02d9aaf734a50f4f8bd4625e2a85a9a62b5 Mon Sep 17 00:00:00 2001 From: mcarans Date: Fri, 3 Jul 2026 10:06:47 +1200 Subject: [PATCH 19/19] Rename function meson_compile Ensure install depends on build --- mk.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mk.sh b/mk.sh index e66a6ea8a..8fc1395ed 100755 --- a/mk.sh +++ b/mk.sh @@ -41,7 +41,7 @@ meson_setup() { meson setup "$build_dir" $1 ${SETUP_FLAGS[@]+"${SETUP_FLAGS[@]}"} -Dver_full="$VER_FULL" -Dver_githash="$VER_GITHASH" -Dbuild_date="${CPP_DATE}" -Dbuilder="${BUILDER}" --native-file "${NATIVE_FILE}" } -meson_build() { +meson_compile() { echo "--> Running Meson build for: $1" meson compile -C "build/meson_$1" ${COMPILE_FLAGS[@]+"${COMPILE_FLAGS[@]}"} } @@ -106,16 +106,16 @@ execute_target() { # Target Execution Logic meson_setup "-Ddebug=true -Dstrip_bin=false" "debug" ;; compile-deployment) - meson_build "deployment" + meson_compile "deployment" ;; compile-test) - meson_build "test" + meson_compile "test" ;; compile-dev) - meson_build "dev" + meson_compile "dev" ;; compile-debug) - meson_build "debug" + meson_compile "debug" ;; build-deployment) execute_target "setup-deployment" @@ -134,15 +134,19 @@ execute_target() { # Target Execution Logic execute_target "compile-debug" ;; install-deployment) + execute_target "build-deployment" meson_install "deployment" ;; install-test) + execute_target "build-test" meson_install "test" ;; install-dev) + execute_target "build-dev" meson_install "dev" ;; install-debug) + execute_target "build-debug" meson_install "debug" ;; test-deployment)