From 01cf1a2ae91389ae5eb8b873d5792090dc528bb3 Mon Sep 17 00:00:00 2001 From: Nadia Holmquist Pedersen Date: Wed, 5 Feb 2025 19:11:45 +0100 Subject: [PATCH] ares: 141 -> 143, switch to CMake build system --- pkgs/by-name/ar/ares/darwin-build-fixes.patch | 25 +++++ pkgs/by-name/ar/ares/package.nix | 96 +++++++++++-------- .../patches/001-dont-rebuild-on-install.patch | 22 ----- 3 files changed, 82 insertions(+), 61 deletions(-) create mode 100644 pkgs/by-name/ar/ares/darwin-build-fixes.patch delete mode 100644 pkgs/by-name/ar/ares/patches/001-dont-rebuild-on-install.patch diff --git a/pkgs/by-name/ar/ares/darwin-build-fixes.patch b/pkgs/by-name/ar/ares/darwin-build-fixes.patch new file mode 100644 index 000000000000..e0fe64bc94da --- /dev/null +++ b/pkgs/by-name/ar/ares/darwin-build-fixes.patch @@ -0,0 +1,25 @@ +diff --git a/cmake/macos/compilerconfig.cmake b/cmake/macos/compilerconfig.cmake +index 99272c662..50f94db37 100644 +--- a/cmake/macos/compilerconfig.cmake ++++ b/cmake/macos/compilerconfig.cmake +@@ -27,7 +27,7 @@ message(DEBUG "macOS SDK Path: ${CMAKE_OSX_SYSROOT}") + string(REGEX MATCH ".+/SDKs/MacOSX([0-9]+\\.[0-9])+\\.sdk$" _ ${CMAKE_OSX_SYSROOT}) + set(_ares_macos_current_sdk ${CMAKE_MATCH_1}) + message(DEBUG "macOS SDK version: ${_ares_macos_current_sdk}") +-if(_ares_macos_current_sdk VERSION_LESS _ares_macos_minimum_sdk) ++if(FALSE) + message( + FATAL_ERROR + "Your macOS SDK version (${_ares_macos_current_sdk}) is too low. " +diff --git a/cmake/macos/helpers.cmake b/cmake/macos/helpers.cmake +index 864a629f0..f455345bf 100644 +--- a/cmake/macos/helpers.cmake ++++ b/cmake/macos/helpers.cmake +@@ -35,7 +35,6 @@ function(ares_configure_executable target) + endif() + endif() + +- _bundle_dependencies(${target}) + + install(TARGETS ${target} BUNDLE DESTINATION "." COMPONENT Application) + endif() diff --git a/pkgs/by-name/ar/ares/package.nix b/pkgs/by-name/ar/ares/package.nix index f712b24feb9d..3da9d7dd7e1d 100644 --- a/pkgs/by-name/ar/ares/package.nix +++ b/pkgs/by-name/ar/ares/package.nix @@ -2,7 +2,8 @@ lib, SDL2, alsa-lib, - autoPatchelfHook, + apple-sdk_14, + cmake, fetchFromGitHub, gtk3, gtksourceview3, @@ -11,42 +12,39 @@ libX11, libXv, libao, - libicns, libpulseaudio, + libretro-shaders-slang, librashader, + ninja, + moltenvk, openal, pkg-config, stdenv, udev, vulkan-loader, - which, wrapGAppsHook3, + zlib, }: stdenv.mkDerivation (finalAttrs: { pname = "ares"; - version = "141"; + version = "143"; src = fetchFromGitHub { owner = "ares-emulator"; repo = "ares"; - rev = "v${finalAttrs.version}"; - hash = "sha256-iNcoNdGw/DfYc9tsOGsPYoZLhVwNzJe8bVotx6Rl0j4="; + tag = "v${finalAttrs.version}"; + hash = "sha256-uuFKbS7WvxkTyyQfuQ6iKPvRt+54zUPdjUlQ/ohBAr8="; }; - patches = [ - ./patches/001-dont-rebuild-on-install.patch - ]; - nativeBuildInputs = [ - autoPatchelfHook + cmake + ninja pkg-config - which - wrapGAppsHook3 ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - libicns + ++ lib.optionals stdenv.hostPlatform.isLinux [ + wrapGAppsHook3 ]; buildInputs = @@ -54,6 +52,12 @@ stdenv.mkDerivation (finalAttrs: { SDL2 libao librashader + vulkan-loader + zlib + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + apple-sdk_14 + moltenvk ] ++ lib.optionals stdenv.hostPlatform.isLinux [ alsa-lib @@ -68,31 +72,48 @@ stdenv.mkDerivation (finalAttrs: { udev ]; - appendRunpaths = [ - (lib.makeLibraryPath [ - librashader - vulkan-loader - ]) + patches = [ + ./darwin-build-fixes.patch ]; - makeFlags = - lib.optionals stdenv.hostPlatform.isLinux [ - "hiro=gtk3" - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - "hiro=cocoa" - "lto=false" - "vulkan=false" - ] - ++ [ - "local=false" - "openmp=true" - "prefix=$(out)" - ]; + cmakeFlags = [ + (lib.cmakeBool "ARES_BUILD_LOCAL" false) + (lib.cmakeBool "ARES_SKIP_DEPS" true) + ]; - enableParallelBuilding = true; + postInstall = + if stdenv.hostPlatform.isDarwin then + '' + mkdir $out/Applications + cp -a desktop-ui/ares.app $out/Applications/ares.app + # Shaders directory is already populated with Metal shaders, so can't simply symlink the slang shaders directory itself + for f in ${libretro-shaders-slang}/share/libretro/shaders/shaders_slang/*; do + ln -s "$f" $out/Applications/ares.app/Contents/Resources/Shaders/ + done + '' + else + '' + ln -s ${libretro-shaders-slang}/share/libretro $out/share/libretro + ''; - env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-mmacosx-version-min=10.14"; + postFixup = + if stdenv.hostPlatform.isDarwin then + '' + install_name_tool \ + -add_rpath ${librashader}/lib \ + -add_rpath ${moltenvk}/lib \ + $out/Applications/ares.app/Contents/MacOS/ares + '' + else + '' + patchelf $out/bin/.ares-wrapped \ + --add-rpath ${ + lib.makeLibraryPath [ + librashader + vulkan-loader + ] + } + ''; meta = { homepage = "https://ares-emu.net"; @@ -104,8 +125,5 @@ stdenv.mkDerivation (finalAttrs: { AndersonTorres ]; platforms = lib.platforms.unix; - broken = stdenv.hostPlatform.isDarwin; }; }) -# TODO: select between Qt and GTK3 -# TODO: call Darwin hackers to deal with specific errors diff --git a/pkgs/by-name/ar/ares/patches/001-dont-rebuild-on-install.patch b/pkgs/by-name/ar/ares/patches/001-dont-rebuild-on-install.patch deleted file mode 100644 index 7b6bbfc21bdc..000000000000 --- a/pkgs/by-name/ar/ares/patches/001-dont-rebuild-on-install.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 65cc7647110edd768e7baa7991143014316e655a Mon Sep 17 00:00:00 2001 -From: Madoura <93990818+Madouura@users.noreply.github.com> -Date: Mon, 9 May 2022 10:17:06 -0500 -Subject: [PATCH] Update GNUmakefile - ---- - desktop-ui/GNUmakefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/desktop-ui/GNUmakefile b/desktop-ui/GNUmakefile -index 8e27b11d3..0bee561fb 100644 ---- a/desktop-ui/GNUmakefile -+++ b/desktop-ui/GNUmakefile -@@ -106,7 +106,7 @@ endif - $(call rdelete,$(object.path)) - $(call rdelete,$(output.path)) - --install: all -+install: - ifeq ($(platform),windows) - $(call mkdir,$(prefix)/$(name)/) - else ifeq ($(shell id -un),root)