libretro: refactor mkLibretroCore function
Separate it on its own separate file, remove some unnecessary parameters and allow more flexibility.
This commit is contained in:
parent
27b6e16af7
commit
64ae43e9e5
File diff suppressed because it is too large
Load Diff
@ -167,6 +167,7 @@ stdenv.mkDerivation rec {
|
||||
platforms = platforms.unix;
|
||||
changelog = "https://github.com/libretro/RetroArch/blob/v${version}/CHANGES.md";
|
||||
maintainers = with maintainers; teams.libretro.members ++ [ matthewbauer kolbycrouch ];
|
||||
mainProgram = "retroarch";
|
||||
# FIXME: error while building in macOS:
|
||||
# "Undefined symbols for architecture <arch>"
|
||||
# See also retroarch/wrapper.nix that is also broken in macOS
|
||||
|
80
pkgs/applications/emulators/retroarch/mkLibretroCore.nix
Normal file
80
pkgs/applications/emulators/retroarch/mkLibretroCore.nix
Normal file
@ -0,0 +1,80 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, core
|
||||
, makeWrapper
|
||||
, retroarch
|
||||
, zlib
|
||||
, makefile ? "Makefile.libretro"
|
||||
, extraBuildInputs ? [ ]
|
||||
, extraNativeBuildInputs ? [ ]
|
||||
# Location of resulting RetroArch core on $out
|
||||
, libretroCore ? "/lib/retroarch/cores"
|
||||
# The core filename is derivated from the core name
|
||||
# Setting `normalizeCore` to `true` will convert `-` to `_` on the core filename
|
||||
, normalizeCore ? true
|
||||
, ...
|
||||
}@args:
|
||||
|
||||
let
|
||||
d2u = if normalizeCore then (lib.replaceChars [ "-" ] [ "_" ]) else (x: x);
|
||||
coreDir = placeholder "out" + libretroCore;
|
||||
coreFilename = "${d2u core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary}";
|
||||
mainProgram = "retroarch-${core}";
|
||||
extraArgs = builtins.removeAttrs args [
|
||||
"lib"
|
||||
"stdenv"
|
||||
"core"
|
||||
"makeWrapper"
|
||||
"retroarch"
|
||||
"zlib"
|
||||
"makefile"
|
||||
"extraBuildInputs"
|
||||
"extraNativeBuildInputs"
|
||||
"libretroCore"
|
||||
"normalizeCore"
|
||||
"makeFlags"
|
||||
"meta"
|
||||
];
|
||||
in
|
||||
stdenv.mkDerivation ({
|
||||
pname = "libretro-${core}";
|
||||
|
||||
buildInputs = [ zlib ] ++ extraBuildInputs;
|
||||
nativeBuildInputs = [ makeWrapper ] ++ extraNativeBuildInputs;
|
||||
|
||||
inherit makefile;
|
||||
|
||||
makeFlags = [
|
||||
"platform=${{
|
||||
linux = "unix";
|
||||
darwin = "osx";
|
||||
windows = "win";
|
||||
}.${stdenv.hostPlatform.parsed.kernel.name} or stdenv.hostPlatform.parsed.kernel.name}"
|
||||
"ARCH=${{
|
||||
armv7l = "arm";
|
||||
armv6l = "arm";
|
||||
i686 = "x86";
|
||||
}.${stdenv.hostPlatform.parsed.cpu.name} or stdenv.hostPlatform.parsed.cpu.name}"
|
||||
] ++ (args.makeFlags or [ ]);
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dt ${coreDir} ${coreFilename}
|
||||
makeWrapper ${retroarch}/bin/retroarch $out/bin/${mainProgram} \
|
||||
--add-flags "-L ${coreDir}/${coreFilename} $@"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
passthru = { inherit core libretroCore; };
|
||||
|
||||
meta = with lib; {
|
||||
inherit mainProgram;
|
||||
inherit (retroarch.meta) platforms;
|
||||
homepage = "https://www.libretro.com/";
|
||||
maintainers = with maintainers; teams.libretro.members ++ [ hrdinka ];
|
||||
} // (args.meta or { });
|
||||
} // extraArgs)
|
Loading…
Reference in New Issue
Block a user