Skip to content

Commit

Permalink
mesen: init at 2.0.0-unstable-2024-09-15
Browse files Browse the repository at this point in the history
  • Loading branch information
TomaSajt committed Oct 17, 2024
1 parent f0668c1 commit 5b0562f
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 0 deletions.
59 changes: 59 additions & 0 deletions pkgs/by-name/me/mesen/deps.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions pkgs/by-name/me/mesen/dont-zip-libraries.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
diff --git a/UI/Config/ConfigManager.cs b/UI/Config/ConfigManager.cs
index 56c1ff1..ed5fe8a 100644
--- a/UI/Config/ConfigManager.cs
+++ b/UI/Config/ConfigManager.cs
@@ -51,7 +51,6 @@ namespace Mesen.Config
} else {
homeFolder = DefaultDocumentsFolder;
}
- Program.ExtractNativeDependencies(homeFolder);
_homeFolder = homeFolder;
Config.Save();
}
diff --git a/UI/Program.cs b/UI/Program.cs
index dfc4ba3..632cef2 100644
--- a/UI/Program.cs
+++ b/UI/Program.cs
@@ -54,8 +54,6 @@ namespace Mesen
Environment.CurrentDirectory = ConfigManager.HomeFolder;

if(!File.Exists(ConfigManager.GetConfigFile())) {
- //Could not find configuration file, show wizard
- ExtractNativeDependencies(ConfigManager.HomeFolder);
App.ShowConfigWindow = true;
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args, ShutdownMode.OnMainWindowClose);
if(File.Exists(ConfigManager.GetConfigFile())) {
@@ -68,9 +66,6 @@ namespace Mesen
//Start loading config file in a separate thread
Task.Run(() => ConfigManager.LoadConfig());

- //Extract core dll & other native dependencies
- ExtractNativeDependencies(ConfigManager.HomeFolder);
-
if(CommandLineHelper.IsTestRunner(args)) {
return TestRunner.Run(args);
}
@@ -147,7 +142,7 @@ namespace Mesen
libraryName = libraryName + ".dylib";
}
}
- return NativeLibrary.Load(Path.Combine(ConfigManager.HomeFolder, libraryName));
+ return NativeLibrary.Load(Path.Combine(AppContext.BaseDirectory, libraryName));
}
return IntPtr.Zero;
}
diff --git a/UI/UI.csproj b/UI/UI.csproj
index 7ced93d..81e216b 100644
--- a/UI/UI.csproj
+++ b/UI/UI.csproj
@@ -591,21 +591,7 @@
<EmbeddedResource Include="Debugger\Utilities\LuaScripts\NtscSafeArea.lua" />
<EmbeddedResource Include="Debugger\Utilities\LuaScripts\NesPianoRoll.lua" />
<EmbeddedResource Include="Debugger\Utilities\LuaScripts\ReverseMode.lua" />
- <EmbeddedResource Include="Dependencies.zip" />
<EmbeddedResource Include="Localization\resources.en.xml" WithCulture="false" Type="Non-Resx" />
<EmbeddedResource Include="Utilities\DipSwitchDefinitions.xml" />
</ItemGroup>
-
- <Target Name="PreBuildWindows" BeforeTargets="PreBuildEvent" Condition="'$(RuntimeIdentifier)'=='win-x64'">
- <Exec Command="cd $(OutDir)&#xD;&#xA;rd Dependencies /s /q&#xD;&#xA;md Dependencies&#xD;&#xA;xcopy /s $(ProjectDir)Dependencies\* Dependencies&#xD;&#xA;copy libHarfBuzzSharp.dll Dependencies&#xD;&#xA;copy libSkiaSharp.dll Dependencies&#xD;&#xA;copy MesenCore.dll Dependencies&#xD;&#xA;cd Dependencies&#xD;&#xA;del ..\Dependencies.zip&#xD;&#xA;powershell Compress-Archive -Path * -DestinationPath '..\Dependencies.zip' -Force&#xD;&#xA;copy ..\Dependencies.zip $(ProjectDir)" />
- </Target>
-
- <Target Name="PreBuildLinux" BeforeTargets="PreBuildEvent" Condition="'$(RuntimeIdentifier)'=='linux-x64'">
- <Exec Command="cd $(OutDir)&#xD;&#xA;rm -rf Dependencies&#xD;&#xA;mkdir Dependencies&#xD;&#xA;cp -R $(ProjectDir)/Dependencies/* Dependencies&#xD;&#xA;cp libHarfBuzzSharp.so Dependencies&#xD;&#xA;cp libSkiaSharp.so Dependencies&#xD;&#xA;cp MesenCore.so Dependencies&#xD;&#xA;cd Dependencies&#xD;&#xA;rm ../Dependencies.zip&#xD;&#xA;zip -r ../Dependencies.zip *&#xD;&#xA;cp ../Dependencies.zip $(ProjectDir)" />
- </Target>
-
- <Target Name="PreBuildOsx" BeforeTargets="PreBuildEvent" Condition="'$(RuntimeIdentifier)'=='osx-x64' Or '$(RuntimeIdentifier)'=='osx-arm64'">
- <Exec Command="cp ./Assets/MesenIcon.icns $(OutDir)&#xD;&#xA;cd $(OutDir)&#xD;&#xA;rm -R Dependencies&#xD;&#xA;mkdir Dependencies&#xD;&#xA;cp -R $(ProjectDir)/Dependencies/* Dependencies&#xD;&#xA;cp libHarfBuzzSharp.dylib Dependencies&#xD;&#xA;cp libSkiaSharp.dylib Dependencies&#xD;&#xA;cp MesenCore.dylib Dependencies&#xD;&#xA;cd Dependencies&#xD;&#xA;rm ../Dependencies.zip&#xD;&#xA;zip -r ../Dependencies.zip *&#xD;&#xA;cp ../Dependencies.zip $(ProjectDir)" />
- </Target>
-
</Project>
86 changes: 86 additions & 0 deletions pkgs/by-name/me/mesen/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
lib,
clangStdenv,
buildDotnetModule,
dotnetCorePackages,
fetchFromGitHub,
fetchpatch,
wrapGAppsHook3,
gtk3,
SDL2,
darwin,
}:

buildDotnetModule rec {
pname = "mesen";
version = "2.0.0-unstable-2024-09-15";

src = fetchFromGitHub {
owner = "SourMesen";
repo = "Mesen2";
rev = "aa1c20afe578aa2b0cceaf13e3168ac1309d46f6";
hash = "sha256-hioW2bdra/XgFhRLbOxLwMEJbQiaijo0Rx8E0f/pDhQ=";
};

patches = [
(fetchpatch {
name = "dont-use-nightly-avalonia.patch";
url = "https:/SourMesen/Mesen2/commit/d4501b7954af97039211367e9a6c2dacf3d93c6b.patch";
revert = true;
hash = "sha256-9sCQbqxDsqC89RZg0lfoZ/gtSTjVv/xKFwaVghjvvE0=";
})
./dont-zip-libraries.patch
];

dotnet-sdk = dotnetCorePackages.sdk_8_0;
dotnet-runtime = dotnetCorePackages.runtime_8_0;

projectFile = [ "UI/UI.csproj" ];

dotnetFlags = [
"-p:RuntimeIdentifier=${dotnetCorePackages.systemToDotnetRid clangStdenv.hostPlatform.system}"
];

executables = [ "Mesen" ];

nugetDeps = ./deps.nix;

nativeBuildInputs = [ wrapGAppsHook3 ];

runtimeDeps = [ gtk3 ];

postInstall = ''
ln -s ${passthru.core}/lib/MesenCore.* $out/lib/mesen
'';

# according to upstream, compiling with clang creates a faster binary
passthru.core = clangStdenv.mkDerivation {
pname = "mesen-core";
inherit version src;

enableParallelBuilding = true;

buildInputs =
[ SDL2 ]
++ lib.optionals clangStdenv.isDarwin [
darwin.apple_sdk.frameworks.Cocoa
darwin.apple_sdk.frameworks.Foundation
];

makeFlags = [ "core" ];

installPhase = ''
runHook preInstall
install -Dm755 InteropDLL/obj.*/MesenCore.* -t $out/lib
runHook postInstall
'';
};

meta = {
description = "Multi-system emulator that supports NES, SNES, Game Boy (Color) and PC Engine games";
homepage = "https://www.mesen.ca";
license = lib.licenses.gpl3Plus;
mainProgram = "Mesen";
maintainers = with lib.maintainers; [ tomasajt ];
};
}

0 comments on commit 5b0562f

Please sign in to comment.