3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #34107 from mnacamura/cdda-darwin

cataclysm-dda{,-git}: build on Darwin
This commit is contained in:
Michael Raskin 2018-01-22 22:47:25 +00:00 committed by GitHub
commit beb70f1370
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 98 additions and 11 deletions

View file

@ -1,5 +1,5 @@
{ fetchFromGitHub, stdenv, makeWrapper, pkgconfig, ncurses, lua, SDL2, SDL2_image, SDL2_ttf,
SDL2_mixer, freetype, gettext }:
SDL2_mixer, freetype, gettext, Cocoa, libicns }:
stdenv.mkDerivation rec {
version = "0.C";
@ -12,9 +12,13 @@ stdenv.mkDerivation rec {
sha256 = "03sdzsk4qdq99qckq0axbsvg1apn6xizscd8pwp5w6kq2fyj5xkv";
};
nativeBuildInputs = [ makeWrapper pkgconfig ];
nativeBuildInputs = [ makeWrapper pkgconfig ]
++ stdenv.lib.optionals stdenv.isDarwin [ libicns ];
buildInputs = [ ncurses lua SDL2 SDL2_image SDL2_ttf SDL2_mixer freetype gettext ];
buildInputs = [ ncurses lua SDL2 SDL2_image SDL2_ttf SDL2_mixer freetype gettext ]
++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa ];
patches = [ ./patches/fix_locale_dir.patch ];
postPatch = ''
patchShebangs .
@ -26,11 +30,32 @@ stdenv.mkDerivation rec {
-i src/{crafting,skill,weather_data,melee,vehicle,overmap,iuse_actor}.cpp
'';
makeFlags = "PREFIX=$(out) LUA=1 TILES=1 SOUND=1 RELEASE=1 USE_HOME_DIR=1";
makeFlags = [
"PREFIX=$(out) LUA=1 TILES=1 SOUND=1 RELEASE=1 USE_HOME_DIR=1"
] ++ stdenv.lib.optionals stdenv.isDarwin [
"NATIVE=osx CLANG=1"
"OSX_MIN=10.6" # SDL for macOS only supports deploying on 10.6 and above
];
postBuild = stdenv.lib.optionalString stdenv.isDarwin ''
# iconutil on macOS is not available in nixpkgs
png2icns data/osx/AppIcon.icns data/osx/AppIcon.iconset/*
'';
postInstall = ''
wrapProgram $out/bin/cataclysm-tiles \
--add-flags "--datadir $out/share/"
'' + stdenv.lib.optionalString stdenv.isDarwin ''
app=$out/Applications/Cataclysm.app
install -D -m 444 data/osx/Info.plist -t $app/Contents
install -D -m 444 data/osx/AppIcon.icns -t $app/Contents/Resources
mkdir $app/Contents/MacOS
launcher=$app/Contents/MacOS/Cataclysm.sh
cat << SCRIPT > $launcher
#!/bin/sh
$out/bin/cataclysm-tiles
SCRIPT
chmod 555 $launcher
'';
# Disable, possible problems with hydra
@ -64,6 +89,6 @@ stdenv.mkDerivation rec {
homepage = http://en.cataclysmdda.com/;
license = licenses.cc-by-sa-30;
maintainers = [ maintainers.skeidel ];
platforms = platforms.linux;
platforms = platforms.unix;
};
}

View file

@ -1,5 +1,5 @@
{ fetchFromGitHub, stdenv, makeWrapper, pkgconfig, ncurses, lua, SDL2, SDL2_image, SDL2_ttf,
SDL2_mixer, freetype, gettext }:
SDL2_mixer, freetype, gettext, CoreFoundation, Cocoa }:
stdenv.mkDerivation rec {
version = "2017-12-09";
@ -14,7 +14,10 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ makeWrapper pkgconfig ];
buildInputs = [ ncurses lua SDL2 SDL2_image SDL2_ttf SDL2_mixer freetype gettext ];
buildInputs = [ ncurses lua SDL2 SDL2_image SDL2_ttf SDL2_mixer freetype gettext ]
++ stdenv.lib.optionals stdenv.isDarwin [ CoreFoundation Cocoa ];
patches = [ ./patches/fix_locale_dir_git.patch ];
postPatch = ''
patchShebangs .
@ -26,11 +29,26 @@ stdenv.mkDerivation rec {
-i src/{crafting,skill,weather_data,melee,vehicle,overmap,iuse_actor}.cpp
'';
makeFlags = "PREFIX=$(out) LUA=1 TILES=1 SOUND=1 RELEASE=1 USE_HOME_DIR=1";
makeFlags = [
"PREFIX=$(out) LUA=1 TILES=1 SOUND=1 RELEASE=1 USE_HOME_DIR=1"
] ++ stdenv.lib.optionals stdenv.isDarwin [
"NATIVE=osx CLANG=1"
];
postInstall = ''
wrapProgram $out/bin/cataclysm-tiles \
--add-flags "--datadir $out/share/cataclysm-dda/"
'' + stdenv.lib.optionalString stdenv.isDarwin ''
app=$out/Applications/Cataclysm.app
install -D -m 444 data/osx/Info.plist -t $app/Contents
install -D -m 444 data/osx/AppIcon.icns -t $app/Contents/Resources
mkdir $app/Contents/MacOS
launcher=$app/Contents/MacOS/Cataclysm.sh
cat << SCRIPT > $launcher
#!/bin/sh
$out/bin/cataclysm-tiles
SCRIPT
chmod 555 $launcher
'';
# https://hydra.nixos.org/build/65193254
@ -65,6 +83,6 @@ stdenv.mkDerivation rec {
'';
homepage = http://en.cataclysmdda.com/;
license = licenses.cc-by-sa-30;
platforms = platforms.linux;
platforms = platforms.unix;
};
}

View file

@ -0,0 +1,20 @@
diff --git a/src/translations.cpp b/src/translations.cpp
index 6520cfe..49f7b2c 100644
--- a/src/translations.cpp
+++ b/src/translations.cpp
@@ -72,15 +72,11 @@ void set_language(bool reload_options)
// Step 2. Bind to gettext domain.
const char *locale_dir;
-#ifdef __linux__
if (!FILENAMES["base_path"].empty()) {
locale_dir = std::string(FILENAMES["base_path"] + "share/locale").c_str();
} else {
locale_dir = "lang/mo";
}
-#else
- locale_dir = "lang/mo";
-#endif // __linux__
bindtextdomain("cataclysm-dda", locale_dir);
bind_textdomain_codeset("cataclysm-dda", "UTF-8");

View file

@ -0,0 +1,20 @@
diff --git a/src/translations.cpp b/src/translations.cpp
index 3a86291..e6c5f84 100644
--- a/src/translations.cpp
+++ b/src/translations.cpp
@@ -176,15 +176,11 @@ void set_language()
// Step 2. Bind to gettext domain.
std::string locale_dir;
-#if (defined __linux__ || (defined MACOSX && !defined TILES))
if( !FILENAMES["base_path"].empty() ) {
locale_dir = FILENAMES["base_path"] + "share/locale";
} else {
locale_dir = "lang/mo";
}
-#else
- locale_dir = "lang/mo";
-#endif // __linux__
const char *locale_dir_char = locale_dir.c_str();
bindtextdomain( "cataclysm-dda", locale_dir_char );

View file

@ -18148,9 +18148,13 @@ with pkgs;
bzflag = callPackage ../games/bzflag { };
cataclysm-dda = callPackage ../games/cataclysm-dda { };
cataclysm-dda = callPackage ../games/cataclysm-dda {
inherit (darwin.apple_sdk.frameworks) Cocoa;
};
cataclysm-dda-git = callPackage ../games/cataclysm-dda/git.nix { };
cataclysm-dda-git = callPackage ../games/cataclysm-dda/git.nix {
inherit (darwin.apple_sdk.frameworks) CoreFoundation Cocoa;
};
chessdb = callPackage ../games/chessdb { };