From ad7eb5b4e60f2343142c52e272b112faa0feaa5e Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 30 Sep 2021 09:21:13 -0300 Subject: [PATCH] higan: 110 -> 115+unstable=2021-08-18 --- .../emulators/higan/0001-change-flags.diff | 25 --- .../emulators/higan/001-include-cmath.patch | 8 + .../higan/002-sips-to-png2icns.patch | 24 +++ pkgs/misc/emulators/higan/default.nix | 203 ++++++++++-------- pkgs/top-level/all-packages.nix | 1 - 5 files changed, 144 insertions(+), 117 deletions(-) delete mode 100644 pkgs/misc/emulators/higan/0001-change-flags.diff create mode 100644 pkgs/misc/emulators/higan/001-include-cmath.patch create mode 100644 pkgs/misc/emulators/higan/002-sips-to-png2icns.patch diff --git a/pkgs/misc/emulators/higan/0001-change-flags.diff b/pkgs/misc/emulators/higan/0001-change-flags.diff deleted file mode 100644 index 745bba5d518d..000000000000 --- a/pkgs/misc/emulators/higan/0001-change-flags.diff +++ /dev/null @@ -1,25 +0,0 @@ -diff -Naur higan-110-old/higan/GNUmakefile higan-110-new/higan/GNUmakefile ---- higan-110-old/higan/GNUmakefile 2020-04-15 11:06:00.279935557 -0300 -+++ higan-110-new/higan/GNUmakefile 2020-04-15 11:08:32.982417291 -0300 -@@ -11,7 +11,7 @@ - include $(nall.path)/GNUmakefile - - ifeq ($(platform),local) -- flags += -march=native -+ flags += - endif - - ifeq ($(platform),windows) -diff -Naur higan-110-old/nall/GNUmakefile higan-110-new/nall/GNUmakefile ---- higan-110-old/nall/GNUmakefile 2020-04-15 11:06:00.396935154 -0300 -+++ higan-110-new/nall/GNUmakefile 2020-04-15 11:10:37.738011488 -0300 -@@ -127,7 +127,8 @@ - - # linux settings - ifeq ($(platform),linux) -- options += -ldl -+ flags += $(CXXFLAGS) -+ options += $(LDFLAGS) -ldl - endif - - # bsd settings diff --git a/pkgs/misc/emulators/higan/001-include-cmath.patch b/pkgs/misc/emulators/higan/001-include-cmath.patch new file mode 100644 index 000000000000..67644e656aa7 --- /dev/null +++ b/pkgs/misc/emulators/higan/001-include-cmath.patch @@ -0,0 +1,8 @@ +diff -Naur source-old/higan/fc/ppu/ppu.cpp source-new/higan/fc/ppu/ppu.cpp +--- source-old/higan/fc/ppu/ppu.cpp 1969-12-31 21:00:01.000000000 -0300 ++++ source-new/higan/fc/ppu/ppu.cpp 2021-09-29 22:23:19.107527772 -0300 +@@ -1,3 +1,4 @@ ++#include + #include + + namespace higan::Famicom { diff --git a/pkgs/misc/emulators/higan/002-sips-to-png2icns.patch b/pkgs/misc/emulators/higan/002-sips-to-png2icns.patch new file mode 100644 index 000000000000..0585c8a38c72 --- /dev/null +++ b/pkgs/misc/emulators/higan/002-sips-to-png2icns.patch @@ -0,0 +1,24 @@ +diff -Naur source-old/higan-ui/GNUmakefile source-new/higan-ui/GNUmakefile +--- source-old/higan-ui/GNUmakefile 1969-12-31 21:00:01.000000000 -0300 ++++ source-new/higan-ui/GNUmakefile 2021-09-29 22:35:35.744721052 -0300 +@@ -61,7 +61,7 @@ + mkdir -p $(output.path)/$(name).app/Contents/Resources/ + mv $(output.path)/$(name) $(output.path)/$(name).app/Contents/MacOS/$(name) + cp resource/$(name).plist $(output.path)/$(name).app/Contents/Info.plist +- sips -s format icns resource/$(name).png --out $(output.path)/$(name).app/Contents/Resources/$(name).icns ++ png2icns $(output.path)/$(name).app/Contents/Resources/$(name).icns resource/$(name).png + endif + + verbose: nall.verbose ruby.verbose hiro.verbose all; +diff -Naur source-old/icarus/GNUmakefile source-new/icarus/GNUmakefile +--- source-old/icarus/GNUmakefile 1969-12-31 21:00:01.000000000 -0300 ++++ source-new/icarus/GNUmakefile 2021-09-29 22:35:53.639846113 -0300 +@@ -26,7 +26,7 @@ + mkdir -p $(output.path)/$(name).app/Contents/Resources/ + mv $(output.path)/$(name) $(output.path)/$(name).app/Contents/MacOS/$(name) + cp resource/$(name).plist $(output.path)/$(name).app/Contents/Info.plist +- sips -s format icns resource/$(name).png --out $(output.path)/$(name).app/Contents/Resources/$(name).icns ++ png2icns $(output.path)/$(name).app/Contents/Resources/$(name).icns resource/$(name).png + endif + + verbose: hiro.verbose nall.verbose all; diff --git a/pkgs/misc/emulators/higan/default.nix b/pkgs/misc/emulators/higan/default.nix index 8e10b7bb3154..558cb53c3d5d 100644 --- a/pkgs/misc/emulators/higan/default.nix +++ b/pkgs/misc/emulators/higan/default.nix @@ -1,135 +1,156 @@ -{ lib, stdenv, fetchFromGitHub -, pkg-config -, libX11, libXv -, udev -, libGLU, libGL, SDL2 -, libao, openal, libpulseaudio +{ lib +, stdenv +, fetchFromGitHub +, SDL2 , alsa-lib -, gtk2, gtksourceview +, gtk3 +, gtksourceview3 +, libGL +, libGLU +, libX11 +, libXv +, libao +, libpulseaudio +, openal +, pkg-config , runtimeShell +, udev # Darwin dependencies -, libicns, Carbon, Cocoa, OpenGL, OpenAL}: +, libicns +, Carbon +, Cocoa +, OpenAL +, OpenGL +}: -let - inherit (lib) optionals; -in stdenv.mkDerivation rec { - pname = "higan"; - version = "110"; + version = "115+unstable=2021-08-18"; src = fetchFromGitHub { owner = "higan-emu"; repo = "higan"; - rev = "v${version}"; - sha256 = "11rvm53c3p2f6zk8xbyv2j51xp8zmqnch7zravhj3fk590qrjrr2"; + rev = "9bf1b3314b2bcc73cbc11d344b369c31562aff10"; + hash = "sha256-HZItJ97x20OjFKv2OVbMja7g+c1ZXcgcaC/XDe3vMZM="; }; - patches = [ ./0001-change-flags.diff ]; - postPatch = '' - sed '1i#include ' -i higan/fc/ppu/ppu.cpp + nativeBuildInputs = [ + pkg-config + ] ++ lib.optionals stdenv.isDarwin [ + libicns + ]; - for file in icarus/GNUmakefile higan/target-higan/GNUmakefile; do - substituteInPlace "$file" \ - --replace 'sips -s format icns data/$(name).png --out out/$(name).app/Contents/Resources/$(name).icns' \ - 'png2icns out/$(name).app/Contents/Resources/$(name).icns data/$(name).png' - done - ''; + buildInputs = [ + SDL2 + libao + ] ++ lib.optionals stdenv.isLinux [ + alsa-lib + gtk3 + gtksourceview3 + libGL + libGLU + libX11 + libXv + libpulseaudio + openal + udev + ] ++ lib.optionals stdenv.isDarwin [ + Carbon + Cocoa + OpenAL + OpenGL + ]; - nativeBuildInputs = [ pkg-config ] - ++ optionals stdenv.isDarwin [ libicns ]; + patches = [ + # Includes cmath header + ./001-include-cmath.patch + # Uses png2icns instead of sips + ./002-sips-to-png2icns.patch + ]; - buildInputs = [ SDL2 libao ] - ++ optionals stdenv.isLinux [ alsa-lib udev libpulseaudio openal - gtk2 gtksourceview libX11 libXv - libGLU libGL ] - ++ optionals stdenv.isDarwin [ Carbon Cocoa OpenGL OpenAL ]; + dontConfigure = true; + + enableParallelBuilding = true; buildPhase = '' - make compiler=c++ -C higan openmp=true target=higan - make compiler=c++ -C genius openmp=true - make compiler=c++ -C icarus openmp=true + runHook preBuild + + make -j $NIX_BUILD_CORES compiler=${stdenv.cc.targetPrefix}c++ \ + platform=linux openmp=true hiro=gtk3 build=accuracy local=false \ + cores="cv fc gb gba md ms msx ngp pce sfc sg ws" -C higan-ui + make -j $NIX_BUILD_CORES compiler=${stdenv.cc.targetPrefix}c++ \ + platform=linux openmp=true hiro=gtk3 -C icarus + + runHook postBuild ''; - installPhase = (if stdenv.isDarwin then '' - mkdir "$out" - mv higan/out/higan.app "$out"/ - mv icarus/out/icarus.app "$out"/ - mv genius/out/genius.app "$out"/ + installPhase = '' + runHook preInstall + + '' + (if stdenv.isDarwin then '' + mkdir ${placeholder "out"} + mv higan/out/higan.app ${placeholder "out"}/ + mv icarus/out/icarus.app ${placeholder "out"}/ '' else '' - install -dm 755 "$out"/bin "$out"/share/applications "$out"/share/pixmaps + install -d ${placeholder "out"}/bin + install higan-ui/out/higan -t ${placeholder "out"}/bin/ + install icarus/out/icarus -t ${placeholder "out"}/bin/ - install -m 755 higan/out/higan -t "$out"/bin/ - install -m 644 higan/target-higan/resource/higan.desktop \ - -t $out/share/applications/ - install -m 644 higan/target-higan/resource/higan.svg \ - $out/share/pixmaps/higan-icon.svg - install -m 644 higan/target-higan/resource/higan.png \ - $out/share/pixmaps/higan-icon.png + install -d ${placeholder "out"}/share/applications + install higan-ui/resource/higan.desktop -t ${placeholder "out"}/share/applications/ + install icarus/resource/icarus.desktop -t ${placeholder "out"}/share/applications/ - install -m 755 icarus/out/icarus -t "$out"/bin/ - install -m 644 icarus/data/icarus.desktop -t $out/share/applications/ - install -m 644 icarus/data/icarus.svg $out/share/pixmaps/icarus-icon.svg - install -m 644 icarus/data/icarus.png $out/share/pixmaps/icarus-icon.png - - install -m 755 genius/out/genius -t "$out"/bin/ - install -m 644 genius/data/genius.desktop -t $out/share/applications/ - install -m 644 genius/data/genius.svg $out/share/pixmaps/genius-icon.svg - install -m 644 genius/data/genius.png $out/share/pixmaps/genius-icon.png + install -d ${placeholder "out"}/share/pixmaps + install higan/higan/resource/higan.svg ${placeholder "out"}/share/pixmaps/higan-icon.svg + install higan/higan/resource/logo.png ${placeholder "out"}/share/pixmaps/higan-icon.png + install icarus/resource/icarus.svg ${placeholder "out"}/share/pixmaps/icarus-icon.svg + install icarus/resource/icarus.png ${placeholder "out"}/share/pixmaps/icarus-icon.png '') + '' - mkdir -p "$out"/share/higan "$out"/share/icarus - cp --recursive --no-dereference --preserve='links' --no-preserve='ownership' \ - higan/System/ "$out"/share/higan/ - cp --recursive --no-dereference --preserve='links' --no-preserve='ownership' \ - icarus/Database icarus/Firmware $out/share/icarus/ - ''; + install -d ${placeholder "out"}/share/higan + cp -rd extras/ higan/System/ ${placeholder "out"}/share/higan/ - fixupPhase = let - dest = if stdenv.isDarwin - then "\\$HOME/Library/Application Support/higan" - else "\\$HOME/higan"; - in '' + install -d ${placeholder "out"}/share/icarus + cp -rd icarus/Database icarus/Firmware ${placeholder "out"}/share/icarus/ + '' + ( # A dirty workaround, suggested by @cpages: # we create a first-run script to populate # $HOME with all the stuff needed at runtime - - mkdir -p "$out"/bin - cat < $out/bin/higan-init.sh + let + dest = if stdenv.isDarwin + then "\\$HOME/Library/Application Support/higan" + else "\\$HOME/higan"; + in '' + mkdir -p ${placeholder "out"}/bin + cat < ${placeholder "out"}/bin/higan-init.sh #!${runtimeShell} - cp --recursive --update $out/share/higan/System/ "${dest}"/ + cp --recursive --update ${placeholder "out"}/share/higan/System/ "${dest}"/ EOF - chmod +x $out/bin/higan-init.sh + chmod +x ${placeholder "out"}/bin/higan-init.sh + '') + '' + + runHook postInstall ''; meta = with lib; { + homepage = "https://github.com/higan-emu/higan"; description = "An open-source, cycle-accurate multi-system emulator"; longDescription = '' - higan is a multi-system game console emulator. The purpose of higan is to - serve as hardware documentation in source code form: it is meant to be as - accurate and complete as possible, with code that is easy to read and - understand. + higan is a multi-system emulator, originally developed by Near, with an + uncompromising focus on accuracy and code readability. - It currently supports the following systems: - - Famicom + Famicom Disk System - - Super Famicom + Super Game Boy - - Game Boy + Game Boy Color - - Game Boy Advance + Game Boy Player - - SG-1000 + SC-3000 - - Master System + Game Gear - - Mega Drive + Mega CD - - PC Engine + SuperGrafx - - MSX + MSX2 - - ColecoVision - - Neo Geo Pocket + Neo Geo Pocket Color - - WonderSwan + WonderSwan Color + SwanCrystal + Pocket Challenge V2 + It currently emulates the following systems: Famicom, Famicom Disk System, + Super Famicom, Super Game Boy, Game Boy, Game Boy Color, Game Boy Advance, + Game Boy Player, SG-1000, SC-3000, Master System, Game Gear, Mega Drive, + Mega CD, PC Engine, SuperGrafx, MSX, MSX2, ColecoVision, Neo Geo Pocket, + Neo Geo Pocket Color, WonderSwan, WonderSwan Color, SwanCrystal, Pocket + Challenge V2. ''; - homepage = "https://byuu.org/higan/"; license = licenses.gpl3Plus; maintainers = with maintainers; [ AndersonTorres ]; platforms = platforms.unix; }; } -# TODO: Qt and GTK3+ support +# TODO: select between Qt, GTK2 and GTK3 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4f91cf812e3c..5bd4305a4fbd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -32571,7 +32571,6 @@ with pkgs; }; higan = callPackage ../misc/emulators/higan { - inherit (gnome2) gtksourceview; inherit (darwin.apple_sdk.frameworks) Carbon Cocoa OpenGL OpenAL; };