mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-05 11:44:02 +00:00
famistudio: .NET 7 -> 8 (#361867)
This commit is contained in:
commit
7c0fc9cf18
@ -1,69 +0,0 @@
|
||||
{ depname
|
||||
, version
|
||||
, src
|
||||
, sourceRoot
|
||||
, stdenv
|
||||
, lib
|
||||
, patches ? []
|
||||
, extraPostPatch ? ""
|
||||
, buildInputs ? []
|
||||
}:
|
||||
|
||||
let
|
||||
rebuildscriptName = if stdenv.hostPlatform.isLinux then
|
||||
"build_linux"
|
||||
else if stdenv.hostPlatform.isDarwin then
|
||||
"build_macos"
|
||||
else throw "Don't know how to rebuild FamiStudio's vendored ${depname} for ${stdenv.hostPlatform.system}";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "famistudio-nativedep-${depname}";
|
||||
inherit version src sourceRoot patches buildInputs;
|
||||
|
||||
postPatch = let
|
||||
libnameBase = lib.optionalString stdenv.hostPlatform.isLinux "lib" + depname;
|
||||
in ''
|
||||
# Use one name for build script, eases with patching
|
||||
mv ${rebuildscriptName}.sh build.sh
|
||||
|
||||
# Scripts use hardcoded compilers and try to copy built libraries into FamiStudio's build tree
|
||||
# Not all scripts use the same compiler, so don't fail on replacing that
|
||||
substituteInPlace build.sh \
|
||||
--replace-fail '../../FamiStudio/' "$out/lib/" \
|
||||
--replace-quiet 'g++' "$CXX"
|
||||
|
||||
# Replacing gcc via sed, would break -static-libgcc otherwise
|
||||
sed -i -e "s/^gcc/$CC/g" build.sh
|
||||
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
# Darwin rebuild scripts try to make a universal2 dylib
|
||||
# - build dylib for non-hostPlatform
|
||||
# - copy built library into special directory for later packaging script
|
||||
# - join two dylibs together into a universal2 dylib
|
||||
# Remove everything we don't need
|
||||
sed -ri \
|
||||
-e '/-target ${if stdenv.hostPlatform.isx86_64 then "arm64" else "x86_64"}/d' \
|
||||
-e '/..\/..\/Setup/d' \
|
||||
build.sh
|
||||
|
||||
# Replace joining multi-arch dylibs with copying dylib for target arch
|
||||
substituteInPlace build.sh \
|
||||
--replace-fail 'lipo -create -output ${libnameBase}.dylib' 'cp ${libnameBase}_${if stdenv.hostPlatform.isx86_64 then "x86_64" else "arm64"}.dylib ${libnameBase}.dylib #'
|
||||
'' + extraPostPatch;
|
||||
|
||||
dontConfigure = true;
|
||||
dontInstall = true; # rebuild script automatically installs
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
mkdir -p $out/lib
|
||||
|
||||
# Delete all prebuilt libraries, make sure everything is rebuilt
|
||||
find . -name '*.so' -or -name '*.dylib' -or -name '*.a' -delete
|
||||
|
||||
# When calling normally, an error won't cause derivation to fail
|
||||
source ./build.sh
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
{ stdenv
|
||||
, lib
|
||||
, buildDotnetModule
|
||||
, dotnetCorePackages
|
||||
, callPackage
|
||||
, fetchFromGitHub
|
||||
, ffmpeg
|
||||
, glfw
|
||||
, libglvnd
|
||||
, libogg
|
||||
, libvorbis
|
||||
, openal
|
||||
, portaudio
|
||||
, rtmidi
|
||||
}:
|
||||
|
||||
let
|
||||
csprojName = if stdenv.hostPlatform.isLinux then
|
||||
"FamiStudio.Linux"
|
||||
else if stdenv.hostPlatform.isDarwin then
|
||||
"FamiStudio.Mac"
|
||||
else throw "Don't know how to build FamiStudio for ${stdenv.hostPlatform.system}";
|
||||
in
|
||||
buildDotnetModule rec {
|
||||
pname = "famistudio";
|
||||
version = "4.2.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "BleuBleu";
|
||||
repo = "FamiStudio";
|
||||
rev = "refs/tags/${version}";
|
||||
hash = "sha256-WYy/6cWQg3Ayok/eAdnvlWAvdcuhy/sdlWOVvaYcPkc=";
|
||||
};
|
||||
|
||||
postPatch = let
|
||||
libname = library: "${library}${stdenv.hostPlatform.extensions.sharedLibrary}";
|
||||
buildNativeWrapper = args: callPackage ./build-native-wrapper.nix (args // {
|
||||
inherit version src;
|
||||
sourceRoot = "${src.name}/ThirdParty/${args.depname}";
|
||||
});
|
||||
nativeWrapperToReplaceFormat = args: let
|
||||
libPrefix = lib.optionalString stdenv.hostPlatform.isLinux "lib";
|
||||
in {
|
||||
package = buildNativeWrapper args;
|
||||
expectedName = "${libPrefix}${args.depname}";
|
||||
ourName = "${libPrefix}${args.depname}";
|
||||
};
|
||||
librariesToReplace = [
|
||||
# Unmodified native libraries that we can fully substitute
|
||||
{ package = glfw; expectedName = "libglfw"; ourName = "libglfw"; }
|
||||
{ package = rtmidi; expectedName = "librtmidi"; ourName = "librtmidi"; }
|
||||
] ++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
{ package = openal; expectedName = "libopenal32"; ourName = "libopenal"; }
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
{ package = portaudio; expectedName = "libportaudio.2"; ourName = "libportaudio.2"; }
|
||||
] ++ [
|
||||
# Native libraries, with extra code for the C# wrapping
|
||||
(nativeWrapperToReplaceFormat { depname = "GifDec"; })
|
||||
(nativeWrapperToReplaceFormat { depname = "NesSndEmu"; })
|
||||
(nativeWrapperToReplaceFormat { depname = "NotSoFatso"; extraPostPatch = ''
|
||||
# C++17 does not allow register storage class specifier
|
||||
substituteInPlace build.sh \
|
||||
--replace-fail "$CXX" "$CXX -std=c++14"
|
||||
''; })
|
||||
(nativeWrapperToReplaceFormat { depname = "ShineMp3"; })
|
||||
(nativeWrapperToReplaceFormat { depname = "Stb"; })
|
||||
(nativeWrapperToReplaceFormat { depname = "Vorbis"; buildInputs = [ libogg libvorbis ]; })
|
||||
];
|
||||
libraryReplaceArgs = lib.strings.concatMapStringsSep " "
|
||||
(library: "--replace-fail '${libname library.expectedName}' '${lib.getLib library.package}/lib/${libname library.ourName}'")
|
||||
librariesToReplace;
|
||||
in ''
|
||||
# Don't use any prebuilt libraries
|
||||
rm FamiStudio/*.{dll,dylib,so*}
|
||||
|
||||
# Replace copying of vendored prebuilt native libraries with copying of our native libraries
|
||||
substituteInPlace ${projectFile} ${libraryReplaceArgs}
|
||||
|
||||
# Un-hardcode target platform if set
|
||||
sed -i -e '/PlatformTarget/d' ${projectFile}
|
||||
|
||||
# Don't require a special name to be preserved, our OpenAL isn't 32-bit
|
||||
substituteInPlace FamiStudio/Source/AudioStreams/OpenALStream.cs \
|
||||
--replace-fail 'libopenal32' 'libopenal'
|
||||
'';
|
||||
|
||||
projectFile = "FamiStudio/${csprojName}.csproj";
|
||||
nugetDeps = ./deps.nix;
|
||||
dotnet-sdk = dotnetCorePackages.sdk_7_0;
|
||||
dotnet-runtime = dotnetCorePackages.runtime_7_0;
|
||||
|
||||
runtimeDeps = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
libglvnd
|
||||
];
|
||||
|
||||
executables = [ "FamiStudio" ];
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $out/share/famistudio
|
||||
for datdir in Setup/Demo\ {Instruments,Songs}; do
|
||||
cp -R "$datdir" $out/share/famistudio/
|
||||
done
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
# FFMpeg looked up from PATH
|
||||
wrapProgram $out/bin/FamiStudio \
|
||||
--prefix PATH : ${lib.makeBinPath [ ffmpeg ]}
|
||||
'';
|
||||
|
||||
passthru.updateScript = ./update.sh;
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://famistudio.org/";
|
||||
description = "NES Music Editor";
|
||||
longDescription = ''
|
||||
FamiStudio is very simple music editor for the Nintendo Entertainment System
|
||||
or Famicom. It is targeted at both chiptune artists and NES homebrewers.
|
||||
'';
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ OPNA2608 ];
|
||||
platforms = platforms.unix;
|
||||
mainProgram = "FamiStudio";
|
||||
};
|
||||
}
|
84
pkgs/by-name/fa/famistudio/build-native-wrapper.nix
Normal file
84
pkgs/by-name/fa/famistudio/build-native-wrapper.nix
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
depname,
|
||||
version,
|
||||
src,
|
||||
sourceRoot,
|
||||
stdenv,
|
||||
lib,
|
||||
patches ? [ ],
|
||||
extraPostPatch ? "",
|
||||
buildInputs ? [ ],
|
||||
}:
|
||||
|
||||
let
|
||||
rebuildscriptName =
|
||||
if stdenv.hostPlatform.isLinux then
|
||||
"build_linux"
|
||||
else if stdenv.hostPlatform.isDarwin then
|
||||
"build_macos"
|
||||
else
|
||||
throw "Don't know how to rebuild FamiStudio's vendored ${depname} for ${stdenv.hostPlatform.system}";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "famistudio-nativedep-${depname}";
|
||||
inherit
|
||||
version
|
||||
src
|
||||
sourceRoot
|
||||
patches
|
||||
buildInputs
|
||||
;
|
||||
|
||||
postPatch =
|
||||
let
|
||||
libnameBase = lib.optionalString stdenv.hostPlatform.isLinux "lib" + depname;
|
||||
in
|
||||
''
|
||||
# Use one name for build script, eases with patching
|
||||
mv ${rebuildscriptName}.sh build.sh
|
||||
|
||||
# Scripts use hardcoded compilers and try to copy built libraries into FamiStudio's build tree
|
||||
# Not all scripts use the same compiler, so don't fail on replacing that
|
||||
substituteInPlace build.sh \
|
||||
--replace-fail '../../FamiStudio/' "$out/lib/" \
|
||||
--replace-quiet 'g++' "$CXX"
|
||||
|
||||
# Replacing gcc via sed, would break -static-libgcc otherwise
|
||||
sed -i -e "s/^gcc/$CC/g" build.sh
|
||||
''
|
||||
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
# Darwin rebuild scripts try to make a universal2 dylib
|
||||
# - build dylib for non-hostPlatform
|
||||
# - copy built library into special directory for later packaging script
|
||||
# - join two dylibs together into a universal2 dylib
|
||||
# Remove everything we don't need
|
||||
sed -ri \
|
||||
-e '/-target ${if stdenv.hostPlatform.isx86_64 then "arm64" else "x86_64"}/d' \
|
||||
-e '/..\/..\/Setup/d' \
|
||||
build.sh
|
||||
|
||||
# Replace joining multi-arch dylibs with copying dylib for target arch
|
||||
substituteInPlace build.sh \
|
||||
--replace-fail 'lipo -create -output ${libnameBase}.dylib' 'cp ${libnameBase}_${
|
||||
if stdenv.hostPlatform.isx86_64 then "x86_64" else "arm64"
|
||||
}.dylib ${libnameBase}.dylib #'
|
||||
''
|
||||
+ extraPostPatch;
|
||||
|
||||
dontConfigure = true;
|
||||
dontInstall = true; # rebuild script automatically installs
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
mkdir -p $out/lib
|
||||
|
||||
# Delete all prebuilt libraries, make sure everything is rebuilt
|
||||
find . -name '*.so' -or -name '*.dylib' -or -name '*.a' -delete
|
||||
|
||||
# When calling normally, an error won't cause derivation to fail
|
||||
source ./build.sh
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
}
|
171
pkgs/by-name/fa/famistudio/package.nix
Normal file
171
pkgs/by-name/fa/famistudio/package.nix
Normal file
@ -0,0 +1,171 @@
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
buildDotnetModule,
|
||||
dotnetCorePackages,
|
||||
callPackage,
|
||||
fetchFromGitHub,
|
||||
ffmpeg,
|
||||
glfw,
|
||||
libglvnd,
|
||||
libogg,
|
||||
libvorbis,
|
||||
openal,
|
||||
portaudio,
|
||||
rtmidi,
|
||||
}:
|
||||
|
||||
let
|
||||
csprojName =
|
||||
if stdenv.hostPlatform.isLinux then
|
||||
"FamiStudio.Linux"
|
||||
else if stdenv.hostPlatform.isDarwin then
|
||||
"FamiStudio.Mac"
|
||||
else
|
||||
throw "Don't know how to build FamiStudio for ${stdenv.hostPlatform.system}";
|
||||
in
|
||||
buildDotnetModule rec {
|
||||
pname = "famistudio";
|
||||
version = "4.2.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "BleuBleu";
|
||||
repo = "FamiStudio";
|
||||
rev = "refs/tags/${version}";
|
||||
hash = "sha256-WYy/6cWQg3Ayok/eAdnvlWAvdcuhy/sdlWOVvaYcPkc=";
|
||||
};
|
||||
|
||||
postPatch =
|
||||
let
|
||||
libname = library: "${library}${stdenv.hostPlatform.extensions.sharedLibrary}";
|
||||
buildNativeWrapper =
|
||||
args:
|
||||
callPackage ./build-native-wrapper.nix (
|
||||
args
|
||||
// {
|
||||
inherit version src;
|
||||
sourceRoot = "${src.name}/ThirdParty/${args.depname}";
|
||||
}
|
||||
);
|
||||
nativeWrapperToReplaceFormat =
|
||||
args:
|
||||
let
|
||||
libPrefix = lib.optionalString stdenv.hostPlatform.isLinux "lib";
|
||||
in
|
||||
{
|
||||
package = buildNativeWrapper args;
|
||||
expectedName = "${libPrefix}${args.depname}";
|
||||
ourName = "${libPrefix}${args.depname}";
|
||||
};
|
||||
librariesToReplace =
|
||||
[
|
||||
# Unmodified native libraries that we can fully substitute
|
||||
{
|
||||
package = glfw;
|
||||
expectedName = "libglfw";
|
||||
ourName = "libglfw";
|
||||
}
|
||||
{
|
||||
package = rtmidi;
|
||||
expectedName = "librtmidi";
|
||||
ourName = "librtmidi";
|
||||
}
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
{
|
||||
package = openal;
|
||||
expectedName = "libopenal32";
|
||||
ourName = "libopenal";
|
||||
}
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
{
|
||||
package = portaudio;
|
||||
expectedName = "libportaudio.2";
|
||||
ourName = "libportaudio.2";
|
||||
}
|
||||
]
|
||||
++ [
|
||||
# Native libraries, with extra code for the C# wrapping
|
||||
(nativeWrapperToReplaceFormat { depname = "GifDec"; })
|
||||
(nativeWrapperToReplaceFormat { depname = "NesSndEmu"; })
|
||||
(nativeWrapperToReplaceFormat {
|
||||
depname = "NotSoFatso";
|
||||
extraPostPatch = ''
|
||||
# C++17 does not allow register storage class specifier
|
||||
substituteInPlace build.sh \
|
||||
--replace-fail "$CXX" "$CXX -std=c++14"
|
||||
'';
|
||||
})
|
||||
(nativeWrapperToReplaceFormat { depname = "ShineMp3"; })
|
||||
(nativeWrapperToReplaceFormat { depname = "Stb"; })
|
||||
(nativeWrapperToReplaceFormat {
|
||||
depname = "Vorbis";
|
||||
buildInputs = [
|
||||
libogg
|
||||
libvorbis
|
||||
];
|
||||
})
|
||||
];
|
||||
libraryReplaceArgs = lib.strings.concatMapStringsSep " " (
|
||||
library:
|
||||
"--replace-fail '${libname library.expectedName}' '${lib.getLib library.package}/lib/${libname library.ourName}'"
|
||||
) librariesToReplace;
|
||||
in
|
||||
''
|
||||
# Don't use any prebuilt libraries
|
||||
rm FamiStudio/*.{dll,dylib,so*}
|
||||
|
||||
# Replace copying of vendored prebuilt native libraries with copying of our native libraries
|
||||
substituteInPlace ${projectFile} ${libraryReplaceArgs}
|
||||
|
||||
# Un-hardcode target platform if set
|
||||
sed -i -e '/PlatformTarget/d' ${projectFile}
|
||||
|
||||
# Don't require a special name to be preserved, our OpenAL isn't 32-bit
|
||||
substituteInPlace FamiStudio/Source/AudioStreams/OpenALStream.cs \
|
||||
--replace-fail 'libopenal32' 'libopenal'
|
||||
'';
|
||||
|
||||
projectFile = "FamiStudio/${csprojName}.csproj";
|
||||
nugetDeps = ./deps.nix;
|
||||
dotnet-sdk = dotnetCorePackages.sdk_8_0;
|
||||
dotnet-runtime = dotnetCorePackages.runtime_8_0;
|
||||
dotnetFlags = [ "-p:TargetFramework=net8.0" ];
|
||||
|
||||
runtimeDeps = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
libglvnd
|
||||
];
|
||||
|
||||
executables = [ "FamiStudio" ];
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $out/share/famistudio
|
||||
for datdir in Setup/Demo\ {Instruments,Songs}; do
|
||||
cp -R "$datdir" $out/share/famistudio/
|
||||
done
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
# FFMpeg looked up from PATH
|
||||
wrapProgram $out/bin/FamiStudio \
|
||||
--prefix PATH : ${lib.makeBinPath [ ffmpeg ]}
|
||||
'';
|
||||
|
||||
passthru.updateScript = ./update.sh;
|
||||
|
||||
meta = {
|
||||
homepage = "https://famistudio.org/";
|
||||
description = "NES Music Editor";
|
||||
longDescription = ''
|
||||
FamiStudio is very simple music editor for the Nintendo Entertainment System
|
||||
or Famicom. It is targeted at both chiptune artists and NES homebrewers.
|
||||
'';
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [
|
||||
OPNA2608
|
||||
];
|
||||
platforms = lib.platforms.unix;
|
||||
mainProgram = "FamiStudio";
|
||||
};
|
||||
}
|
@ -13678,8 +13678,6 @@ with pkgs;
|
||||
evolution = callPackage ../applications/networking/mailreaders/evolution/evolution { };
|
||||
evolutionWithPlugins = callPackage ../applications/networking/mailreaders/evolution/evolution/wrapper.nix { plugins = [ evolution evolution-ews ]; };
|
||||
|
||||
famistudio = darwin.apple_sdk_11_0.callPackage ../applications/audio/famistudio { };
|
||||
|
||||
fdr = libsForQt5.callPackage ../applications/science/programming/fdr { };
|
||||
|
||||
fetchmail = callPackage ../applications/misc/fetchmail { };
|
||||
|
Loading…
Reference in New Issue
Block a user