Unverified Commit b2c036cd authored by Cosima Neidahl's avatar Cosima Neidahl Committed by GitHub
Browse files

edopro: Fixups (#350820)

parents e774f2d7 4b411e35
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -4,11 +4,8 @@
  assets-hash = "sha256-vZhkWJ1ZoNEwdc5kM1S0hyXnWmupiTOanCi9DCuqw/k=";
  edopro-version = "40.1.4";
  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-rev = "7edde28d4f8c0c3589934c398a3a441286bb7c22";
  irrlicht-hash = "sha256-Q2tNiYE/enZPqA5YhUe+Tkvmqtmmz2E0OqTRUDnt+UA=";
  ocgcore-version = "0-unstable-2022-09-15";
  ocgcore-rev = "4a872ad7686e0d00ee4c1c051e90fc07c40613d4";
  ocgcore-hash = "sha256-s3DOHrZilRUy6fbXObNiLRinxpdHY99vDOmS/ZfOI78=";
}
+0 −29
Original line number Diff line number Diff line
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
+65 −85
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
  # Use fmt 10+ after release 40.1.4+
  fmt_9,
  freetype,
  irrlicht,
  libevent,
  libgit2,
  libGL,
@@ -25,7 +26,6 @@
  libX11,
  libxkbcommon,
  libXxf86vm,
  lua5_3,
  mono,
  nlohmann_json,
  openal,
@@ -50,6 +50,11 @@ let
    .${stdenv.hostPlatform.system}
      or (throw "${stdenv.hostPlatform.system} is an unsupported arch label for edopro");

  maintainers = with lib.maintainers; [
    OPNA2608
    redhawk
  ];

  deps = import ./deps.nix;
in
let
@@ -78,9 +83,7 @@ let
    ];

    enableParallelBuilding = true;
    buildFlags = [
      "NDEBUG=1"
    ];
    buildFlags = [ "NDEBUG=1" ];
    makeFlags = [
      "-C"
      "source/Irrlicht"
@@ -89,57 +92,18 @@ let
    installPhase = ''
      runHook preInstall

      mkdir -p $out/{bin,include}
      cp lib/Linux/libIrrlicht.a $out/bin
      cp -r include/* $out/include
      install -Dm644 -t $out/lib lib/Linux/libIrrlicht.a
      cp -r include $out/include

      runHook postInstall
    '';
  };

  ocgcore = stdenv.mkDerivation {
    pname = "ygopro-core";
    version = deps.ocgcore-version;

    src = fetchFromGitHub {
      owner = "edo9300";
      repo = "ygopro-core";
      rev = deps.ocgcore-rev;
      hash = deps.ocgcore-hash;
      fetchSubmodules = true;
    meta = {
      inherit (irrlicht.meta) description platforms;
      homepage = "https://github.com/edo9300/irrlicht1-8-4";
      license = lib.licenses.agpl3Plus;
      inherit maintainers;
    };

    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 {
@@ -151,7 +115,6 @@ let
      repo = "edopro";
      rev = deps.edopro-rev;
      hash = deps.edopro-hash;
      fetchSubmodules = true;
    };

    nativeBuildInputs = [
@@ -171,9 +134,7 @@ let
      libjpeg
      libpng
      libvorbis
      lua5_3
      nlohmann_json
      ocgcore
      openal
      SDL2
      sqlite
@@ -183,6 +144,8 @@ let
    postPatch = ''
      substituteInPlace premake5.lua \
        --replace-fail 'flags "LinkTimeOptimization"' 'removeflags "LinkTimeOptimization"'

      touch ocgcore/premake5.lua
    '';

    preBuild = ''
@@ -191,7 +154,7 @@ let
        --covers=\"${covers_url}\" \
        --fields=\"${fields_url}\" \
        --pics=\"${pics_url}\" \
        --prebuilt-core="${lib.getLib ocgcore}/lib" \
        --no-core \
        --sound=sfml
    '';

@@ -205,7 +168,7 @@ let
    buildFlags = [
      "verbose=true"
      "config=release_${archLabel}"
      "ygopro"
      "ygoprodll"
    ];
    makeFlags = [
      "-C"
@@ -216,8 +179,8 @@ let
      runHook preInstall

      mkdir -p $out/bin
      cp bin/${archLabel}/release/ygopro $out/bin
      wrapProgram $out/bin/ygopro \
      cp bin/${archLabel}/release/ygoprodll $out/bin
      wrapProgram $out/bin/ygoprodll \
        --prefix PATH : ${lib.makeBinPath [ mono ]} \
        --prefix LD_LIBRARY_PATH : ${
          lib.makeLibraryPath [
@@ -233,12 +196,30 @@ let

      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 =
    let
      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"
        "config"
        "deck"
@@ -267,17 +248,18 @@ let
          rm $EDOPRO_DIR/config/io.github.edo9300.EDOPro.desktop.in
      fi

      exec ${edopro}/bin/ygopro -C $EDOPRO_DIR $@
      exec ${lib.getExe edopro} -C $EDOPRO_DIR $@
    '';

  edopro-desktop = runCommandLocal "io.github.edo9300.EDOPro.desktop" { } ''
    cp ${assets}/config/io.github.edo9300.EDOPro.desktop.in desktop-template

    sed '/Path=/d' -i desktop-template
    sed 's/Exec=.*/Exec=EDOPro/' -i desktop-template
    sed 's/Icon=.*/Icon=EDOPro/' -i desktop-template

    install -D desktop-template $out/share/applications/io.github.edo9300.EDOPro.desktop
    mkdir -p $out/share/applications

    sed ${assets}/config/io.github.edo9300.EDOPro.desktop.in \
      -e '/Path=/d' \
      -e 's/Exec=.*/Exec=edopro/' \
      -e 's/Icon=.*/Icon=edopro/' \
      -e 's/StartupWMClass=.*/StartupWMClass=edopro/' \
      >$out/share/applications/io.github.edo9300.EDOPro.desktop
  '';
in
symlinkJoin {
@@ -289,30 +271,28 @@ symlinkJoin {
  ];

  postBuild = ''
    mkdir -p $out/share/icons/hicolor/256x256/apps/
    for size in 16 32 48 64 128 256 512 1024; do
      res="$size"x"$size"
      mkdir -p $out/share/icons/hicolor/"$res"/apps/
      ${imagemagick}/bin/magick \
          ${assets}/textures/AppIcon.png \
        -resize 256x256 \
        $out/share/icons/hicolor/256x256/apps/EDOPro.png
          -resize "$res" \
          $out/share/icons/hicolor/"$res"/apps/edopro.png
    done
  '';

  passthru.updateScript = ./update.py;

  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;
    maintainers = with lib.maintainers; [
      OPNA2608
      redhawk
    ];
    inherit (edopro.meta)
      description
      homepage
      changelog
      license
      platforms
      maintainers
      ;
    # To differenciate it from the original YGOPro
    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"
    ];
  };
}
+1 −13
Original line number Diff line number Diff line
@@ -15,14 +15,6 @@ DEPS_PATH: str = "./pkgs/by-name/ed/edopro/deps.nix"
with GitHub(UnauthAuthStrategy()) as github:
    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.
    irrlicht: Commit = github.rest.repos.list_commits(
        "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"]


edopro_hash = get_hash("edo9300", "edopro", edopro.commit.sha, submodule=True)
ocgcore_hash = get_hash("edo9300", "ygopro-core", ocgcore.sha)
edopro_hash = get_hash("edo9300", "edopro", edopro.commit.sha)
irrlicht_hash = get_hash("edo9300", "irrlicht1-8-4", irrlicht.sha)

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-rev = "{irrlicht.sha}";
  irrlicht-hash = "{irrlicht_hash}";
  ocgcore-version = "{"0-unstable-" + ocgcore.commit.committer.date.split("T")[0]}";
  ocgcore-rev = "{ocgcore.sha}";
  ocgcore-hash = "{ocgcore_hash}";
}}
"""