cataclysm-dda{,-git}: apply locale patch dynamically

Each time src/translations.cpp is modified, we have to update the locale
patch. Using sed to patch dynamically should be handy.
This commit is contained in:
Mitsuhiro Nakamura 2020-04-08 10:54:28 +09:00
parent d6863de058
commit bf71f12cb5
5 changed files with 5 additions and 45 deletions

View File

@ -21,6 +21,11 @@ let
postPatch = ''
patchShebangs .
# Locale patch required for Darwin builds, see:
# https://github.com/NixOS/nixpkgs/pull/74064#issuecomment-560083970
sed -i src/translations.cpp \
-e 's@#elif (defined(__linux__) || (defined(MACOSX) && !defined(TILES)))@#elif 1@'
'';
makeFlags = [

View File

@ -16,8 +16,6 @@ stdenv.mkDerivation (common // rec {
sha256 = "15l6w6lxays7qmsv0ci2ry53asb9an9dh7l7fc13256k085qcg68";
};
patches = [ ./patches/fix_locale_dir.patch ];
meta = with stdenv.lib.maintainers; common.meta // {
maintainers = common.meta.maintainers ++ [ skeidel ];
};

View File

@ -18,11 +18,6 @@ stdenv.mkDerivation (common // rec {
sha256 = "0ww2q5gykxm802z1kffmnrfahjlx123j1gfszklpsv0b1fccm1ab";
};
patches = [
# Locale patch required for Darwin builds, see: https://github.com/NixOS/nixpkgs/pull/74064#issuecomment-560083970
./patches/fix_locale_dir_git.patch
];
makeFlags = common.makeFlags ++ [
"VERSION=git-${version}-${substring 0 8 src.rev}"
];

View File

@ -1,18 +0,0 @@
--- a/src/translations.cpp
+++ b/src/translations.cpp
@@ -212,14 +212,12 @@ void set_language()
auto env = getenv( "LANGUAGE" );
locale_dir = std::string( PATH_INFO::base_path() + "lang/mo/" + ( env ? env : "none" ) +
"/LC_MESSAGES/cataclysm-dda.mo" );
-#elif (defined(__linux__) || (defined(MACOSX) && !defined(TILES)))
+#else
if( !PATH_INFO::base_path().empty() ) {
locale_dir = PATH_INFO::base_path() + "share/locale";
} else {
locale_dir = "lang/mo";
}
-#else
- locale_dir = "lang/mo";
#endif
const char *locale_dir_char = locale_dir.c_str();

View File

@ -1,20 +0,0 @@
diff --git a/src/translations.cpp b/src/translations.cpp
index 067e2cd77d..5660d18b3d 100644
--- a/src/translations.cpp
+++ b/src/translations.cpp
@@ -211,14 +211,12 @@ void set_language()
auto env = getenv( "LANGUAGE" );
locale_dir = std::string( FILENAMES["base_path"] + "lang/mo/" + ( env ? env : "none" ) +
"/LC_MESSAGES/cataclysm-dda.mo" );
-#elif (defined(__linux__) || (defined(MACOSX) && !defined(TILES)))
+#else
if( !FILENAMES["base_path"].empty() ) {
locale_dir = FILENAMES["base_path"] + "share/locale";
} else {
locale_dir = "lang/mo";
}
-#else
- locale_dir = "lang/mo";
#endif
const char *locale_dir_char = locale_dir.c_str();