diff options
author | Michael Raskin <7c6f434c@mail.ru> | 2018-01-22 22:47:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-22 22:47:25 +0000 |
commit | beb70f1370bd1a35e473ff0cc489e057b5432fd2 (patch) | |
tree | 940e35714bd23e4c442d2e44a9adb43a3f487080 /pkgs/games/cataclysm-dda | |
parent | a03b2b99af92a97198c903436823d3135a5f6e49 (diff) | |
parent | cf8cd83effe519c0bfc121cd4e3b62dc60cad3fa (diff) | |
download | nixpkgs-beb70f1370bd1a35e473ff0cc489e057b5432fd2.tar nixpkgs-beb70f1370bd1a35e473ff0cc489e057b5432fd2.tar.gz nixpkgs-beb70f1370bd1a35e473ff0cc489e057b5432fd2.tar.bz2 nixpkgs-beb70f1370bd1a35e473ff0cc489e057b5432fd2.tar.lz nixpkgs-beb70f1370bd1a35e473ff0cc489e057b5432fd2.tar.xz nixpkgs-beb70f1370bd1a35e473ff0cc489e057b5432fd2.tar.zst nixpkgs-beb70f1370bd1a35e473ff0cc489e057b5432fd2.zip |
Merge pull request #34107 from mnacamura/cdda-darwin
cataclysm-dda{,-git}: build on Darwin
Diffstat (limited to 'pkgs/games/cataclysm-dda')
-rw-r--r-- | pkgs/games/cataclysm-dda/default.nix | 35 | ||||
-rw-r--r-- | pkgs/games/cataclysm-dda/git.nix | 26 | ||||
-rw-r--r-- | pkgs/games/cataclysm-dda/patches/fix_locale_dir.patch | 20 | ||||
-rw-r--r-- | pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patch | 20 |
4 files changed, 92 insertions, 9 deletions
diff --git a/pkgs/games/cataclysm-dda/default.nix b/pkgs/games/cataclysm-dda/default.nix index b46114ec62b..550d557e57e 100644 --- a/pkgs/games/cataclysm-dda/default.nix +++ b/pkgs/games/cataclysm-dda/default.nix @@ -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; }; } diff --git a/pkgs/games/cataclysm-dda/git.nix b/pkgs/games/cataclysm-dda/git.nix index 0437a1b130f..264dc8b65a0 100644 --- a/pkgs/games/cataclysm-dda/git.nix +++ b/pkgs/games/cataclysm-dda/git.nix @@ -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; }; } diff --git a/pkgs/games/cataclysm-dda/patches/fix_locale_dir.patch b/pkgs/games/cataclysm-dda/patches/fix_locale_dir.patch new file mode 100644 index 00000000000..775a8ec6007 --- /dev/null +++ b/pkgs/games/cataclysm-dda/patches/fix_locale_dir.patch @@ -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"); diff --git a/pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patch b/pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patch new file mode 100644 index 00000000000..c3140af03c8 --- /dev/null +++ b/pkgs/games/cataclysm-dda/patches/fix_locale_dir_git.patch @@ -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 ); |