Unverified Commit 08ebf3f7 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

stuntrally: 2.7 -> 3.3, modernize, and move to by name; ogre-next: init at 3.0.0 (#445054)

parents 60858311 d0ca39ce
Loading
Loading
Loading
Loading
+86 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchpatch2,

  cmake,
  ninja,
  pkg-config,

  SDL2,
  xorg,
  libGL,
  zlib,
  freetype,
  tinyxml,
  openvr,
  rapidjson,
  zziplib,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "ogre-next";
  version = "3.0.0";

  src = fetchFromGitHub {
    owner = "OGRECave";
    repo = "ogre-next";
    tag = "v${finalAttrs.version}";
    hash = "sha256-nJkCGKl9+6gApVtqk5OZjTOJllAJIiBKuquTYvR4NPs=";
  };

  patches = [
    (fetchpatch2 {
      # https://github.com/OGRECave/ogre-next/pull/542
      url = "https://github.com/OGRECave/ogre-next/commit/c1dad50e8510dea9d75d97b0ace33a870993895c.patch?full_index=1";
      hash = "sha256-JYsksDxcLrkHqlgdP3KdHlFuvYxNazlchPGoTXE9LYQ=";
    })
  ];

  nativeBuildInputs = [
    cmake
    pkg-config
    ninja
  ];

  buildInputs = [
    SDL2
    freetype
    zziplib
    zlib
    tinyxml
    openvr
    rapidjson
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [
    libGL
    xorg.libX11
    xorg.libXaw
    xorg.libXrandr
    xorg.libXt
    xorg.libxcb
  ];

  # TODO: Figure out Vulkan plugin deps

  cmakeFlags = [
    (lib.cmakeBool "OGRE_BUILD_COMPONENT_PLANAR_REFLECTIONS" true)

    # Use STB instead of freeimage since the latter is marked as insecure
    (lib.cmakeBool "OGRE_CONFIG_ENABLE_FREEIMAGE" false)
    (lib.cmakeBool "OGRE_CONFIG_ENABLE_STBI" true)
  ];

  meta = {
    description = "3D Object-Oriented Graphics Rendering Engine";
    homepage = "https://www.ogre3d.org/";
    maintainers = with lib.maintainers; [
      marcin-serwin
    ];
    platforms = lib.platforms.linux;
    license = lib.licenses.mit;

    # build problems around NEON intrinsics
    broken = stdenv.hostPlatform.isAarch64;
  };
})
+38 −0
Original line number Diff line number Diff line
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)
+65 −0
Original line number Diff line number Diff line
{
  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;
  };
}
+118 −0
Original line number Diff line number Diff line
{
  lib,
  fetchFromGitHub,
  stdenv,
  callPackage,
  cmake,
  boost,
  SDL2,
  libvorbis,
  pkg-config,
  makeWrapper,
  enet,
  bullet,
  openal,
  tinyxml-2,
  rapidjson,
  ogre-next,
  ninja,
  libX11,
}:

let
  mygui = callPackage ./mygui.nix { };
in
stdenv.mkDerivation (finalAttrs: {
  pname = "stuntrally";
  version = "3.3";

  src = fetchFromGitHub {
    owner = "stuntrally";
    repo = "stuntrally3";
    tag = finalAttrs.version;
    hash = "sha256-BJMMsJ/ONZTpvXetaaHlgm6rih9oZmtJNBXv0IM855Y=";
  };

  tracks = fetchFromGitHub {
    owner = "stuntrally";
    repo = "tracks3";
    tag = finalAttrs.version;
    hash = "sha256-nvIN5hIfTfnuJdlLNlmpmYo3WQhUxYWz14OFra/55w4=";
  };

  patches = [
    ./stuntrally-use-pkg-config-for-ogre-next.patch
    ./stuntrally-init-data-dirs-to-nix-paths.patch
  ];

  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"
  '';

  strictDeps = true;
  nativeBuildInputs = [
    cmake
    pkg-config
    ninja
    makeWrapper
  ];

  buildInputs = [
    boost
    ogre-next
    mygui
    rapidjson
    SDL2
    libvorbis
    enet
    bullet
    openal
    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 ${finalAttrs.tracks} $share_dir/data/tracks

    install -Dm644 -t $out/share/icons/hicolor/512x512/apps data/gui/{stuntrally,sr-editor}.png
    install -Dm644 -t $out/share/applications dist/{stuntrally3,sr-editor3}.desktop

    for binary in sr-editor3 sr-translator stuntrally3
    do
      install -Dm755 -t $out/bin bin/Release/$binary
      # Force X11, otherwise fails with `OGRE EXCEPTION(9:UnimplementedException)`
      wrapProgram $out/bin/$binary \
        --set SDL_VIDEODRIVER x11
    done

    popd

    runHook postInstall
  '';

  passthru = {
    inherit mygui;
  };

  meta = {
    description = "3D racing game with Sci-Fi elements and own Track Editor";
    homepage = "https://cryham.org/stuntrally/";
    mainProgram = "stuntrally3";
    license = lib.licenses.gpl3Plus;
    maintainers = with lib.maintainers; [ pSub ];
    platforms = lib.platforms.linux;
  };
})
+26 −0
Original line number Diff line number Diff line
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");
Loading