Dee Anzorge 2024-11-24 00:55:43 +01:00
parent b69edc44cc
commit cd321ca9a4
7 changed files with 25 additions and 100 deletions

View file

@ -1,5 +1,5 @@
{ lib, stdenv, runtimeShell, pkg-config, gettext, ncurses, CoreFoundation
, tiles, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, freetype, Cocoa, zlib
{ lib, stdenv, runtimeShell, pkg-config, gettext, ncurses
, tiles, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, freetype, zlib
, debug
, useXdgDir
}:
@ -10,7 +10,7 @@ let
commonDeps = [
gettext
zlib
] ++ optionals stdenv.hostPlatform.isDarwin [ CoreFoundation ];
];
cursesDeps = commonDeps ++ [ ncurses ];
@ -22,8 +22,7 @@ let
SDL2_mixer
SDL2_ttf
freetype
]
++ optionals stdenv.hostPlatform.isDarwin [ Cocoa ];
];
patchDesktopFile = ''
substituteInPlace $out/share/applications/org.cataclysmdda.CataclysmDDA.desktop \

View file

@ -1,20 +1,16 @@
{ newScope, darwin }:
{ newScope }:
let
callPackage = newScope self;
stable = rec {
tiles = callPackage ./stable.nix {
inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa;
};
tiles = callPackage ./stable.nix { };
curses = tiles.override { tiles = false; };
};
git = rec {
tiles = callPackage ./git.nix {
inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa;
};
tiles = callPackage ./git.nix { };
curses = tiles.override { tiles = false; };
};

View file

@ -1,5 +1,5 @@
{ lib, callPackage, CoreFoundation, fetchFromGitHub, fetchpatch, pkgs, wrapCDDA, attachPkgs
, tiles ? true, Cocoa
{ lib, callPackage, fetchFromGitHub, fetchpatch, pkgs, wrapCDDA, attachPkgs
, tiles ? true
, debug ? false
, useXdgDir ? false
, version ? "2024-07-28"
@ -9,7 +9,7 @@
let
common = callPackage ./common.nix {
inherit CoreFoundation tiles Cocoa debug useXdgDir;
inherit tiles debug useXdgDir;
};
self = common.overrideAttrs (common: rec {
@ -24,7 +24,7 @@ let
patches = [
# Unconditionally look for translation files in $out/share/locale
./locale-path-git.patch
./locale-path.patch
];
makeFlags = common.makeFlags ++ [

View file

@ -1,28 +0,0 @@
diff --git a/src/debug.cpp b/src/debug.cpp
index fa63a3b..1e8f554 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -1494,6 +1494,14 @@ std::string game_info::operating_system()
}
#if !defined(__CYGWIN__) && !defined (__ANDROID__) && ( defined (__linux__) || defined(unix) || defined(__unix__) || defined(__unix) || ( defined(__APPLE__) && defined(__MACH__) ) || defined(BSD) ) // linux; unix; MacOs; BSD
+ //
+class FILEDeleter
+{
+ public:
+ void operator()( FILE *f ) const noexcept {
+ pclose( f );
+ }
+};
/** Execute a command with the shell by using `popen()`.
* @param command The full command to execute.
* @note The output buffer is limited to 512 characters.
@@ -1504,7 +1512,7 @@ static std::string shell_exec( const std::string &command )
std::vector<char> buffer( 512 );
std::string output;
try {
- std::unique_ptr<FILE, decltype( &pclose )> pipe( popen( command.c_str(), "r" ), pclose );
+ std::unique_ptr<FILE, FILEDeleter> pipe( popen( command.c_str(), "r" ) );
if( pipe ) {
while( fgets( buffer.data(), buffer.size(), pipe.get() ) != nullptr ) {
output += buffer.data();

View file

@ -1,17 +0,0 @@
diff --git a/src/translations.cpp b/src/translations.cpp
--- a/src/translations.cpp
+++ b/src/translations.cpp
@@ -52,13 +52,11 @@ std::string locale_dir()
#define CATA_IS_ON_BSD
#endif
-#if !defined(__ANDROID__) && ((defined(__linux__) || defined(CATA_IS_ON_BSD) || (defined(MACOSX) && !defined(TILES))))
if( !PATH_INFO::base_path().empty() ) {
loc_dir = PATH_INFO::base_path() + "share/locale";
} else {
loc_dir = PATH_INFO::langdir();
}
-#endif
#endif // LOCALIZE
return loc_dir;
}

View file

@ -1,12 +1,11 @@
diff --git a/src/translations.cpp b/src/translations.cpp
index 76bdfd0..6dd6109 100644
--- a/src/translations.cpp
+++ b/src/translations.cpp
@@ -61,13 +61,11 @@ std::string locale_dir()
#define BSD
@@ -52,13 +52,11 @@ std::string locale_dir()
#define CATA_IS_ON_BSD
#endif
-#if !defined(__ANDROID__) && ((defined(__linux__) || defined(BSD) || (defined(MACOSX) && !defined(TILES))))
-#if !defined(__ANDROID__) && ((defined(__linux__) || defined(CATA_IS_ON_BSD) || (defined(MACOSX) && !defined(TILES))))
if( !PATH_INFO::base_path().empty() ) {
loc_dir = PATH_INFO::base_path() + "share/locale";
} else {

View file

@ -1,66 +1,42 @@
{ lib
, callPackage
, CoreFoundation
, fetchFromGitHub
, fetchpatch
, pkgs
, wrapCDDA
, attachPkgs
, tiles ? true
, Cocoa
, debug ? false
, useXdgDir ? false
}:
let
common = callPackage ./common.nix {
inherit CoreFoundation tiles Cocoa debug useXdgDir;
inherit tiles debug useXdgDir;
};
self = common.overrideAttrs (common: rec {
version = "0.G";
version = "0.H";
src = fetchFromGitHub {
owner = "CleverRaven";
repo = "Cataclysm-DDA";
rev = version;
sha256 = "sha256-Hda0dVVHNeZ8MV5CaCbSpdOCG2iqQEEmXdh16vwIBXk=";
tag = "${version}-RELEASE";
sha256 = "sha256-ZCD5qgqYSX7sS+Tc1oNYq9soYwNUUuWamY2uXfLjGoY=";
};
patches = [
# fix compilation of the vendored flatbuffers under gcc14
(fetchpatch {
name = "fix-flatbuffers-with-gcc14";
url = "https://github.com/CleverRaven/Cataclysm-DDA/commit/1400b1018ff37196bd24ba4365bd50beb571ac14.patch";
hash = "sha256-H0jct6lSQxu48eOZ4f8HICxo89qX49Ksw+Xwwtp7iFM=";
})
# Unconditionally look for translation files in $out/share/locale
./locale-path.patch
# Fixes for failing build with GCC 13, remove on updating next release after 0.G
(fetchpatch {
url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-dangling-reference-warning.patch";
hash = "sha256-9nPbyz49IYBOVHqr7jzCIyS8z/SQgpK4EjEz1fruIPE=";
})
(fetchpatch {
url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-cstdint.patch";
hash = "sha256-8IBW2OzAHVgEJZoViQ490n37sl31hA55ePuqDL/lil0=";
})
(fetchpatch {
url = "https://sources.debian.org/data/main/c/cataclysm-dda/0.G-4/debian/patches/gcc13-keyword-requires.patch";
hash = "sha256-8yvHh0YKC7AC/qzia7AZAfMewMC0RiSepMXpOkMXRd8=";
})
# Fix build w/ glibc-2.39
# From https://github.com/BrettDong/Cataclysm-DDA/commit/9b206e2dc969ad79345596e03c3980bd155d2f48
./glibc-2.39.diff
];
makeFlags = common.makeFlags ++ [
# Makefile declares version as 0.F, with no minor release number
"VERSION=${version}"
];
env.NIX_CFLAGS_COMPILE = toString [
# Needed with GCC 12
"-Wno-error=array-bounds"
];
meta = common.meta // {
maintainers = with lib.maintainers;
common.meta.maintainers;
changelog = "https://github.com/CleverRaven/Cataclysm-DDA/blob/${version}/data/changelog.txt";
};
});