edopro: Fixups

Co-authored-by: Redhawk <77415970+Redhawk18@users.noreply.github.com>
This commit is contained in:
OPNA2608 2024-11-01 16:56:12 +01:00
parent aa8104a645
commit 4b411e35cb
4 changed files with 66 additions and 130 deletions

View File

@ -4,11 +4,8 @@
assets-hash = "sha256-vZhkWJ1ZoNEwdc5kM1S0hyXnWmupiTOanCi9DCuqw/k="; assets-hash = "sha256-vZhkWJ1ZoNEwdc5kM1S0hyXnWmupiTOanCi9DCuqw/k=";
edopro-version = "40.1.4"; edopro-version = "40.1.4";
edopro-rev = "c713e23491a1e55c9d8e91257e5f2b5873696b9b"; edopro-rev = "c713e23491a1e55c9d8e91257e5f2b5873696b9b";
edopro-hash = "sha256-2E1cjG0FONu/fbr67/3qRCKQ1W/wPznClEWsMa1FAzo="; edopro-hash = "sha256-mj0xEJsFcnY//za0uJosAPOPbU/jlduNX0YSNmvduLE=";
irrlicht-version = "1.9.0-unstable-2023-02-18"; irrlicht-version = "1.9.0-unstable-2023-02-18";
irrlicht-rev = "7edde28d4f8c0c3589934c398a3a441286bb7c22"; irrlicht-rev = "7edde28d4f8c0c3589934c398a3a441286bb7c22";
irrlicht-hash = "sha256-Q2tNiYE/enZPqA5YhUe+Tkvmqtmmz2E0OqTRUDnt+UA="; irrlicht-hash = "sha256-Q2tNiYE/enZPqA5YhUe+Tkvmqtmmz2E0OqTRUDnt+UA=";
ocgcore-version = "0-unstable-2022-09-15";
ocgcore-rev = "4a872ad7686e0d00ee4c1c051e90fc07c40613d4";
ocgcore-hash = "sha256-s3DOHrZilRUy6fbXObNiLRinxpdHY99vDOmS/ZfOI78=";
} }

View File

@ -1,29 +0,0 @@
From 41e750142b44465f3af197b7e2f0d6f54fc48c2d Mon Sep 17 00:00:00 2001
From: OPNA2608 <opna2608@protonmail.com>
Date: Mon, 21 Oct 2024 17:42:24 +0200
Subject: [PATCH] Mark Lua symbols as C symbols
Otherwise linking against our Lua built by a C-compiler fails due to the symbols being resolved as C++ symbols.
---
interpreter.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/interpreter.h b/interpreter.h
index 6c405a1..c471ecb 100644
--- a/interpreter.h
+++ b/interpreter.h
@@ -9,9 +9,11 @@
#define INTERPRETER_H_
// Due to longjmp behaviour, we must build Lua as C++ to avoid UB
+extern "C" {
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
+}
#include "common.h"
#include <unordered_map>
--
2.44.1

View File

@ -15,6 +15,7 @@
# Use fmt 10+ after release 40.1.4+ # Use fmt 10+ after release 40.1.4+
fmt_9, fmt_9,
freetype, freetype,
irrlicht,
libevent, libevent,
libgit2, libgit2,
libGL, libGL,
@ -25,7 +26,6 @@
libX11, libX11,
libxkbcommon, libxkbcommon,
libXxf86vm, libXxf86vm,
lua5_3,
mono, mono,
nlohmann_json, nlohmann_json,
openal, openal,
@ -50,6 +50,11 @@ let
.${stdenv.hostPlatform.system} .${stdenv.hostPlatform.system}
or (throw "${stdenv.hostPlatform.system} is an unsupported arch label for edopro"); or (throw "${stdenv.hostPlatform.system} is an unsupported arch label for edopro");
maintainers = with lib.maintainers; [
OPNA2608
redhawk
];
deps = import ./deps.nix; deps = import ./deps.nix;
in in
let let
@ -78,9 +83,7 @@ let
]; ];
enableParallelBuilding = true; enableParallelBuilding = true;
buildFlags = [ buildFlags = [ "NDEBUG=1" ];
"NDEBUG=1"
];
makeFlags = [ makeFlags = [
"-C" "-C"
"source/Irrlicht" "source/Irrlicht"
@ -89,57 +92,18 @@ let
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out/{bin,include} install -Dm644 -t $out/lib lib/Linux/libIrrlicht.a
cp lib/Linux/libIrrlicht.a $out/bin cp -r include $out/include
cp -r include/* $out/include
runHook postInstall runHook postInstall
''; '';
};
ocgcore = stdenv.mkDerivation { meta = {
pname = "ygopro-core"; inherit (irrlicht.meta) description platforms;
version = deps.ocgcore-version; homepage = "https://github.com/edo9300/irrlicht1-8-4";
license = lib.licenses.agpl3Plus;
src = fetchFromGitHub { inherit maintainers;
owner = "edo9300";
repo = "ygopro-core";
rev = deps.ocgcore-rev;
hash = deps.ocgcore-hash;
fetchSubmodules = true;
}; };
patches = [
./ocgcore-lua-symbols.patch
];
nativeBuildInputs = [ premake5 ];
buildInputs = [ lua5_3 ];
preBuild = ''
premake5 gmake2 \
--lua-path="${lua5_3}"
'';
enableParallelBuilding = true;
buildFlags = [
"verbose=true"
"config=release"
"ocgcoreshared"
];
makeFlags = [
"-C"
"build"
];
installPhase = ''
runHook preInstall
install -Dm644 -t $out/lib bin/release/libocgcore${stdenv.hostPlatform.extensions.sharedLibrary}
runHook postInstall
'';
}; };
edopro = stdenv.mkDerivation { edopro = stdenv.mkDerivation {
@ -151,7 +115,6 @@ let
repo = "edopro"; repo = "edopro";
rev = deps.edopro-rev; rev = deps.edopro-rev;
hash = deps.edopro-hash; hash = deps.edopro-hash;
fetchSubmodules = true;
}; };
nativeBuildInputs = [ nativeBuildInputs = [
@ -171,9 +134,7 @@ let
libjpeg libjpeg
libpng libpng
libvorbis libvorbis
lua5_3
nlohmann_json nlohmann_json
ocgcore
openal openal
SDL2 SDL2
sqlite sqlite
@ -183,6 +144,8 @@ let
postPatch = '' postPatch = ''
substituteInPlace premake5.lua \ substituteInPlace premake5.lua \
--replace-fail 'flags "LinkTimeOptimization"' 'removeflags "LinkTimeOptimization"' --replace-fail 'flags "LinkTimeOptimization"' 'removeflags "LinkTimeOptimization"'
touch ocgcore/premake5.lua
''; '';
preBuild = '' preBuild = ''
@ -191,7 +154,7 @@ let
--covers=\"${covers_url}\" \ --covers=\"${covers_url}\" \
--fields=\"${fields_url}\" \ --fields=\"${fields_url}\" \
--pics=\"${pics_url}\" \ --pics=\"${pics_url}\" \
--prebuilt-core="${lib.getLib ocgcore}/lib" \ --no-core \
--sound=sfml --sound=sfml
''; '';
@ -205,7 +168,7 @@ let
buildFlags = [ buildFlags = [
"verbose=true" "verbose=true"
"config=release_${archLabel}" "config=release_${archLabel}"
"ygopro" "ygoprodll"
]; ];
makeFlags = [ makeFlags = [
"-C" "-C"
@ -216,8 +179,8 @@ let
runHook preInstall runHook preInstall
mkdir -p $out/bin mkdir -p $out/bin
cp bin/${archLabel}/release/ygopro $out/bin cp bin/${archLabel}/release/ygoprodll $out/bin
wrapProgram $out/bin/ygopro \ wrapProgram $out/bin/ygoprodll \
--prefix PATH : ${lib.makeBinPath [ mono ]} \ --prefix PATH : ${lib.makeBinPath [ mono ]} \
--prefix LD_LIBRARY_PATH : ${ --prefix LD_LIBRARY_PATH : ${
lib.makeLibraryPath [ lib.makeLibraryPath [
@ -233,12 +196,30 @@ let
runHook postInstall runHook postInstall
''; '';
meta = {
description = "Bleeding-edge automatic duel simulator, a fork of the YGOPro client";
homepage = "https://projectignis.github.io";
changelog = "https://github.com/edo9300/edopro/releases";
license = lib.licenses.agpl3Plus;
mainProgram = "ygoprodll";
# This is likely a very easy app to port if you're interested.
# We just have no way to test on other platforms.
platforms = [
"x86_64-linux"
# Currently offline mode does not work, the problem is that the core is updated whenever it is needed.
# So in our method we would have to update the client if it's statically linked as well.
# It is possible but we have decided against it for now. In theory if we added more logic to the update script it could work.
"aarch64-linux"
];
inherit maintainers;
};
}; };
edopro-script = edopro-script =
let let
assetsToCopy = lib.concatStringsSep "," [ assetsToCopy = lib.concatStringsSep "," [
# Needed if we download files from ProjectIgnis' website or any https only website. # Needed if we download files from ProjectIgnis' website or any https-only website.
"cacert.pem" "cacert.pem"
"config" "config"
"deck" "deck"
@ -267,17 +248,18 @@ let
rm $EDOPRO_DIR/config/io.github.edo9300.EDOPro.desktop.in rm $EDOPRO_DIR/config/io.github.edo9300.EDOPro.desktop.in
fi fi
exec ${edopro}/bin/ygopro -C $EDOPRO_DIR $@ exec ${lib.getExe edopro} -C $EDOPRO_DIR $@
''; '';
edopro-desktop = runCommandLocal "io.github.edo9300.EDOPro.desktop" { } '' edopro-desktop = runCommandLocal "io.github.edo9300.EDOPro.desktop" { } ''
cp ${assets}/config/io.github.edo9300.EDOPro.desktop.in desktop-template mkdir -p $out/share/applications
sed '/Path=/d' -i desktop-template sed ${assets}/config/io.github.edo9300.EDOPro.desktop.in \
sed 's/Exec=.*/Exec=EDOPro/' -i desktop-template -e '/Path=/d' \
sed 's/Icon=.*/Icon=EDOPro/' -i desktop-template -e 's/Exec=.*/Exec=edopro/' \
-e 's/Icon=.*/Icon=edopro/' \
install -D desktop-template $out/share/applications/io.github.edo9300.EDOPro.desktop -e 's/StartupWMClass=.*/StartupWMClass=edopro/' \
>$out/share/applications/io.github.edo9300.EDOPro.desktop
''; '';
in in
symlinkJoin { symlinkJoin {
@ -289,30 +271,28 @@ symlinkJoin {
]; ];
postBuild = '' postBuild = ''
mkdir -p $out/share/icons/hicolor/256x256/apps/ for size in 16 32 48 64 128 256 512 1024; do
${imagemagick}/bin/magick \ res="$size"x"$size"
${assets}/textures/AppIcon.png \ mkdir -p $out/share/icons/hicolor/"$res"/apps/
-resize 256x256 \ ${imagemagick}/bin/magick \
$out/share/icons/hicolor/256x256/apps/EDOPro.png ${assets}/textures/AppIcon.png \
-resize "$res" \
$out/share/icons/hicolor/"$res"/apps/edopro.png
done
''; '';
passthru.updateScript = ./update.py; passthru.updateScript = ./update.py;
meta = { meta = {
description = "Bleeding-edge automatic duel simulator, a fork of the YGOPro client"; inherit (edopro.meta)
homepage = "https://projectignis.github.io"; description
changelog = "https://github.com/edo9300/edopro/releases"; homepage
license = lib.licenses.agpl3Plus; changelog
maintainers = with lib.maintainers; [ license
OPNA2608 platforms
redhawk maintainers
]; ;
# To differenciate it from the original YGOPro
mainProgram = "edopro"; mainProgram = "edopro";
# This is likely a very easy app to port if you're interested.
# We just have no way to test on other platforms.
platforms = [
"x86_64-linux"
"aarch64-linux"
];
}; };
} }

View File

@ -15,14 +15,6 @@ DEPS_PATH: str = "./pkgs/by-name/ed/edopro/deps.nix"
with GitHub(UnauthAuthStrategy()) as github: with GitHub(UnauthAuthStrategy()) as github:
edopro: Tag = github.rest.repos.list_tags("edo9300", "edopro").parsed_data[0] edopro: Tag = github.rest.repos.list_tags("edo9300", "edopro").parsed_data[0]
ocgcore_submodule: ContentSubmodule = github.rest.repos.get_content(
"edo9300", "edopro", "ocgcore"
).parsed_data
ocgcore: Commit = github.rest.repos.get_commit(
"edo9300", "ygopro-core", ocgcore_submodule.sha
).parsed_data
# This dep is not versioned in anyway and is why we check below to see if this is a new version. # This dep is not versioned in anyway and is why we check below to see if this is a new version.
irrlicht: Commit = github.rest.repos.list_commits( irrlicht: Commit = github.rest.repos.list_commits(
"edo9300", "irrlicht1-8-4" "edo9300", "irrlicht1-8-4"
@ -64,8 +56,7 @@ def get_hash(owner: str, repo: str, rev: str, submodule: bool = False) -> str:
return out_json["hash"] return out_json["hash"]
edopro_hash = get_hash("edo9300", "edopro", edopro.commit.sha, submodule=True) edopro_hash = get_hash("edo9300", "edopro", edopro.commit.sha)
ocgcore_hash = get_hash("edo9300", "ygopro-core", ocgcore.sha)
irrlicht_hash = get_hash("edo9300", "irrlicht1-8-4", irrlicht.sha) irrlicht_hash = get_hash("edo9300", "irrlicht1-8-4", irrlicht.sha)
asset_legacy_hash: str = ( asset_legacy_hash: str = (
@ -110,9 +101,6 @@ with open(DEPS_PATH, "w") as file:
irrlicht-version = "{"1.9.0-unstable-" + irrlicht.commit.committer.date.split("T")[0]}"; irrlicht-version = "{"1.9.0-unstable-" + irrlicht.commit.committer.date.split("T")[0]}";
irrlicht-rev = "{irrlicht.sha}"; irrlicht-rev = "{irrlicht.sha}";
irrlicht-hash = "{irrlicht_hash}"; irrlicht-hash = "{irrlicht_hash}";
ocgcore-version = "{"0-unstable-" + ocgcore.commit.committer.date.split("T")[0]}";
ocgcore-rev = "{ocgcore.sha}";
ocgcore-hash = "{ocgcore_hash}";
}} }}
""" """