From 5a32e16298e007442f91ed0f6fa4546ddf9a5ab5 Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Thu, 18 Sep 2025 19:20:09 +0200 Subject: [PATCH] stuntrally: 2.7 -> 3.3 Signed-off-by: Marcin Serwin --- pkgs/games/stuntrally/default.nix | 95 +++++++++++-------- .../mygui-use-pkg-config-for-ogre-next.patch | 38 ++++++++ pkgs/games/stuntrally/mygui.nix | 65 +++++++++++++ ...untrally-init-data-dirs-to-nix-paths.patch | 26 +++++ ...ntrally-use-pkg-config-for-ogre-next.patch | 45 +++++++++ pkgs/top-level/all-packages.nix | 2 +- 6 files changed, 229 insertions(+), 42 deletions(-) create mode 100644 pkgs/games/stuntrally/mygui-use-pkg-config-for-ogre-next.patch create mode 100644 pkgs/games/stuntrally/mygui.nix create mode 100644 pkgs/games/stuntrally/stuntrally-init-data-dirs-to-nix-paths.patch create mode 100644 pkgs/games/stuntrally/stuntrally-use-pkg-config-for-ogre-next.patch diff --git a/pkgs/games/stuntrally/default.nix b/pkgs/games/stuntrally/default.nix index 656d4ca91510..4ab171a6d40f 100644 --- a/pkgs/games/stuntrally/default.nix +++ b/pkgs/games/stuntrally/default.nix @@ -2,87 +2,100 @@ lib, fetchFromGitHub, stdenv, + callPackage, cmake, boost, - ogre_13, - mygui, - ois, SDL2, - libX11, libvorbis, pkg-config, - makeWrapper, enet, - libXcursor, bullet, openal, - tinyxml, tinyxml-2, + rapidjson, + ogre-next, + ninja, + libX11, }: let - stuntrally_ogre = ogre_13.overrideAttrs (old: { - cmakeFlags = old.cmakeFlags ++ [ - "-DOGRE_NODELESS_POSITIONING=ON" - "-DOGRE_RESOURCEMANAGER_STRICT=0" - ]; - }); - stuntrally_mygui = mygui.override { - withOgre = true; - ogre = stuntrally_ogre; - }; + mygui = callPackage ./mygui.nix { }; in - stdenv.mkDerivation rec { pname = "stuntrally"; - version = "2.7"; + version = "3.3"; src = fetchFromGitHub { owner = "stuntrally"; - repo = "stuntrally"; - rev = version; - hash = "sha256-0Eh9ilIHSh/Uz8TuPnXxLQfy7KF7qqNXUgBXQUCz9ys="; + repo = "stuntrally3"; + tag = version; + hash = "sha256-BJMMsJ/ONZTpvXetaaHlgm6rih9oZmtJNBXv0IM855Y="; }; + tracks = fetchFromGitHub { owner = "stuntrally"; - repo = "tracks"; - rev = version; - hash = "sha256-fglm1FetFGHM/qGTtpxDb8+k2iAREn5DQR5GPujuLms="; + repo = "tracks3"; + tag = version; + hash = "sha256-nvIN5hIfTfnuJdlLNlmpmYo3WQhUxYWz14OFra/55w4="; }; - postPatch = '' - substituteInPlace config/*-default.cfg \ - --replace "screenshot_png = off" "screenshot_png = on" - substituteInPlace source/*/BaseApp_Create.cpp \ - --replace "Codec_FreeImage" "Codec_STBI" - ''; + patches = [ + ./stuntrally-use-pkg-config-for-ogre-next.patch + ./stuntrally-init-data-dirs-to-nix-paths.patch + ]; - preConfigure = '' - rmdir data/tracks - ln -s ${tracks}/ data/tracks + postPatch = '' + substituteInPlace bin/Release/plugins.cfg \ + --replace-fail "PluginFolder=." "PluginFolder=${ogre-next}/lib/OGRE/" + substituteInPlace src/vdrift/paths.cpp \ + --replace-fail "@GAME_DATA_DIR@" "$out/share/stuntrally3/data" \ + --replace-fail "@GAME_CONFIG_DIR@" "$out/share/stuntrally3/config" ''; nativeBuildInputs = [ cmake pkg-config - makeWrapper + ninja ]; + buildInputs = [ boost - stuntrally_ogre - stuntrally_mygui - ois + ogre-next + mygui + rapidjson SDL2 - libX11 libvorbis enet - libXcursor bullet openal - tinyxml tinyxml-2 + libX11 ]; + installPhase = '' + runHook preInstall + + pushd .. + + share_dir=$out/share/stuntrally3 + mkdir -p $share_dir + cp -r config $share_dir/config + cp bin/Release/plugins.cfg $share_dir/config + cp -r data $share_dir/data + cp -r ${tracks} $share_dir/data/tracks + + mkdir -p $out/bin + cp bin/Release/{sr-editor3,sr-translator,stuntrally3} $out/bin + + popd + + runHook postInstall + ''; + + passthru = { + inherit mygui; + }; + meta = { description = "Stunt Rally game with Track Editor, based on VDrift and OGRE"; homepage = "http://stuntrally.tuxfamily.org/"; diff --git a/pkgs/games/stuntrally/mygui-use-pkg-config-for-ogre-next.patch b/pkgs/games/stuntrally/mygui-use-pkg-config-for-ogre-next.patch new file mode 100644 index 000000000000..e5f0fc0d3cb5 --- /dev/null +++ b/pkgs/games/stuntrally/mygui-use-pkg-config-for-ogre-next.patch @@ -0,0 +1,38 @@ +diff --git a/CMake/Dependencies.cmake b/CMake/Dependencies.cmake +index fcf7cc4..7239f20 100644 +--- a/CMake/Dependencies.cmake ++++ b/CMake/Dependencies.cmake +@@ -84,7 +84,10 @@ elseif(MYGUI_RENDERSYSTEM EQUAL 7) + endif() + elseif(MYGUI_RENDERSYSTEM EQUAL 8) + # Find OGRE +- find_package(OGRE_next) ++ find_package(PkgConfig REQUIRED) ++ pkg_check_modules(OGRE REQUIRED IMPORTED_TARGET GLOBAL OGRE) ++ pkg_check_modules(OGRE_HLMS REQUIRED IMPORTED_TARGET GLOBAL OGRE-Hlms) ++ set(OGRE_INCLUDE_DIR "${OGRE_INCLUDE_DIRS}") + macro_log_feature(OGRE_FOUND "ogre" "Support for the Ogre render system" "" TRUE "" "") + endif() + +diff --git a/Platforms/Ogre2/Ogre2Platform/CMakeLists.txt b/Platforms/Ogre2/Ogre2Platform/CMakeLists.txt +index c40cd8f..2647ae8 100644 +--- a/Platforms/Ogre2/Ogre2Platform/CMakeLists.txt ++++ b/Platforms/Ogre2/Ogre2Platform/CMakeLists.txt +@@ -1,6 +1,6 @@ + set (PROJECTNAME MyGUI.Ogre2Platform) + +-message(STATUS "Platform Ogre-next:" ${OGRE_NEXT}) ++message(STATUS "Platform Ogre-next: ${OGRE_HLMS_INCLUDE_DIRS}") + + include_directories( + include +@@ -8,8 +8,7 @@ include_directories( + ${OGRE_CONFIG_INCLUDE_DIR} + ${OGRE_INCLUDE_DIR} + ${OGRE_SOURCE_DIR} +- ${OGRE_NEXT}/Components/Hlms/Unlit/include +- ${OGRE_NEXT}/Components/Hlms/Common/include ++ ${OGRE_HLMS_INCLUDE_DIRS} + ) + + include(${PROJECTNAME}.list) diff --git a/pkgs/games/stuntrally/mygui.nix b/pkgs/games/stuntrally/mygui.nix new file mode 100644 index 000000000000..111d3fe2266d --- /dev/null +++ b/pkgs/games/stuntrally/mygui.nix @@ -0,0 +1,65 @@ +{ + stdenv, + lib, + fetchFromGitHub, + cmake, + pkg-config, + ninja, + boost, + freetype, + libuuid, + ois, + ogre-next, + libX11, +}: +stdenv.mkDerivation { + pname = "mygui"; + version = "0-unstable-2024-02-01"; + + __structuredAttrs = true; + strictDeps = true; + + src = fetchFromGitHub { + owner = "cryham"; + repo = "mygui-next"; + rev = "a1490ffe01d503c31a00d8277007ffcb27a4258e"; + hash = "sha256-R80rTsbmkYtrjIYqdYmbfciEM4rtEzLtsM4XfShJwns="; + }; + + patches = [ ./mygui-use-pkg-config-for-ogre-next.patch ]; + + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace-fail 'cmake_minimum_required(VERSION 2.6)' \ + 'cmake_minimum_required(VERSION 3.10)' + ''; + + nativeBuildInputs = [ + cmake + pkg-config + ninja + ]; + + buildInputs = [ + boost + freetype + libuuid + ois + ogre-next + libX11 + ]; + + cmakeFlags = [ + (lib.cmakeBool "MYGUI_BUILD_DEMOS" false) + (lib.cmakeBool "MYGUI_BUILD_TOOLS" false) + (lib.cmakeBool "MYGUI_DONT_USE_OBSOLETE" true) + (lib.cmakeFeature "MYGUI_RENDERSYSTEM" "8") + ]; + + meta = { + description = "Library for creating GUIs for games and 3D applications (Stunt Rally fork)"; + homepage = "http://mygui.info/"; + license = lib.licenses.mit; + platforms = lib.platforms.linux; + }; +} diff --git a/pkgs/games/stuntrally/stuntrally-init-data-dirs-to-nix-paths.patch b/pkgs/games/stuntrally/stuntrally-init-data-dirs-to-nix-paths.patch new file mode 100644 index 000000000000..f02c20842004 --- /dev/null +++ b/pkgs/games/stuntrally/stuntrally-init-data-dirs-to-nix-paths.patch @@ -0,0 +1,26 @@ +diff --git a/src/common/Main.cpp b/src/common/Main.cpp +index f63a5b8..8260bcf 100644 +--- a/src/common/Main.cpp ++++ b/src/common/Main.cpp +@@ -154,7 +154,7 @@ void MainEntryPoints::createSystems( + PATHS::UserConfigDir()+"/", + PATHS::CacheDir()+"/", + PATHS::GameConfigDir()+"/", +- String("./") ); ++ PATHS::GameConfigDir()+"/" ); + + app->mGraphicsSystem = graphicsSystem; + +diff --git a/src/vdrift/paths.cpp b/src/vdrift/paths.cpp +index 9122031..d06bb59 100755 +--- a/src/vdrift/paths.cpp ++++ b/src/vdrift/paths.cpp +@@ -145,6 +145,8 @@ void PATHS::Init(bool log_paths) + fs::path exe = execname(); // binary dir + game_bin = exe.parent_path().string(); + ++ game_data = "@GAME_DATA_DIR@"; ++ game_config = "@GAME_CONFIG_DIR@"; + + // Find game data dir and defaults config dir + char *datadir = getenv("STUNTRALLY3_DATA_ROOT"); diff --git a/pkgs/games/stuntrally/stuntrally-use-pkg-config-for-ogre-next.patch b/pkgs/games/stuntrally/stuntrally-use-pkg-config-for-ogre-next.patch new file mode 100644 index 000000000000..6271caaea3f8 --- /dev/null +++ b/pkgs/games/stuntrally/stuntrally-use-pkg-config-for-ogre-next.patch @@ -0,0 +1,45 @@ +diff --git a/CMake/DependenciesConfig.cmake b/CMake/DependenciesConfig.cmake +index aca28ea..76f4186 100644 +--- a/CMake/DependenciesConfig.cmake ++++ b/CMake/DependenciesConfig.cmake +@@ -7,11 +7,14 @@ find_package(Bullet REQUIRED) + find_package(enet REQUIRED) + find_package(MyGUI REQUIRED) + find_package(Ogg REQUIRED) +-find_package(OGRE REQUIRED) ++find_package(PkgConfig REQUIRED) ++pkg_check_modules(OGRE REQUIRED IMPORTED_TARGET GLOBAL OGRE) ++pkg_check_modules(OGRE-Hlms REQUIRED IMPORTED_TARGET GLOBAL OGRE-Hlms) ++pkg_check_modules(OGRE-Overlay REQUIRED IMPORTED_TARGET GLOBAL OGRE-Overlay) + find_package(OpenAL REQUIRED) + find_package(RapidJSON REQUIRED) + find_package(SDL2 REQUIRED) + find_package(tinyxml2 REQUIRED) + find_package(Vorbis REQUIRED) + +-include(AddMissingTargets) +\ No newline at end of file ++include(AddMissingTargets) +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d84ae0c..22c367d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -175,14 +175,16 @@ foreach( EXE ${EXE_LIST} ) + endif () + + target_link_libraries( +- ${EXE} ++ ${EXE} + PRIVATE + boost::boost + Bullet::Bullet + enet::enet + MyGUI::MyGUI + Ogg::ogg +- OGRE::OGRE ++ PkgConfig::OGRE ++ PkgConfig::OGRE-Hlms ++ PkgConfig::OGRE-Overlay + OpenAL::OpenAL + rapidjson + SDL2::SDL2 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6d24e7993433..d7c2af5b46f2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12905,7 +12905,7 @@ with pkgs; protonup-ng = with python3Packages; toPythonApplication protonup-ng; - stuntrally = callPackage ../games/stuntrally { boost = boost183; }; + stuntrally = callPackage ../games/stuntrally { }; the-powder-toy = callPackage ../by-name/th/the-powder-toy/package.nix { lua = lua5_2;