Merge pull request #292925 from qubitnano/origin-eduke32

eduke32: 20230926 -> 0-unstable-2024-02-17, refactor, build with voidsw
This commit is contained in:
Weijia Wang 2024-03-10 00:58:50 +01:00 committed by GitHub
commit 584db0ff31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,16 +1,16 @@
{ lib { lib
, stdenv , stdenv
, fetchurl , fetchFromGitLab
, makeWrapper , makeWrapper
, pkg-config , pkg-config
, nasm , nasm
, makeDesktopItem , makeDesktopItem
, copyDesktopItems
, alsa-lib , alsa-lib
, flac , flac
, gtk2 , gtk2
, libvorbis , libvorbis
, libvpx , libvpx
, libGLU
, libGL , libGL
, SDL2 , SDL2
, SDL2_mixer , SDL2_mixer
@ -18,29 +18,23 @@
, Cocoa , Cocoa
, GLUT , GLUT
, OpenGL , OpenGL
, graphicsmagick
}: }:
let let
desktopItem = makeDesktopItem {
name = "eduke32";
exec = "@out@/bin/${wrapper}";
comment = "Duke Nukem 3D port";
desktopName = "Enhanced Duke Nukem 3D";
genericName = "Duke Nukem 3D port";
categories = [ "Game" ];
};
wrapper = "eduke32-wrapper"; wrapper = "eduke32-wrapper";
swWrapper = "voidsw-wrapper";
in stdenv.mkDerivation rec { in stdenv.mkDerivation (finalAttrs: {
pname = "eduke32"; pname = "eduke32";
version = "20230926"; version = "0-unstable-2024-02-17";
rev = "10459";
revExtra = "8feaf6c25";
src = fetchurl { src = fetchFromGitLab {
url = "https://dukeworld.com/eduke32/synthesis/${version}-${rev}-${revExtra}/eduke32_src_${version}-${rev}-${revExtra}.tar.xz"; domain = "voidpoint.io";
hash = "sha256-GQOpDQm2FeaOMyYu9L5zhrM6XFvZAHMAwn1tSK7RCB8="; owner = "terminx";
repo = "eduke32";
rev = "8afa42e388e0434b38979fdddc763363717a2727";
hash = "sha256-dyZ4JtDBxsTDe9uQDWxJe7M74X7m+5wpEHm+i+s9hwo=";
}; };
buildInputs = [ buildInputs = [
@ -53,7 +47,6 @@ in stdenv.mkDerivation rec {
alsa-lib alsa-lib
gtk2 gtk2
libGL libGL
libGLU
] ++ lib.optionals stdenv.isDarwin [ ] ++ lib.optionals stdenv.isDarwin [
AGL AGL
Cocoa Cocoa
@ -61,21 +54,24 @@ in stdenv.mkDerivation rec {
OpenGL OpenGL
]; ];
nativeBuildInputs = [ makeWrapper pkg-config ] nativeBuildInputs = [
++ lib.optional (stdenv.hostPlatform.system == "i686-linux") nasm; makeWrapper
pkg-config
copyDesktopItems
graphicsmagick
] ++ lib.optionals (stdenv.hostPlatform.system == "i686-linux") [
nasm
];
postPatch = '' postPatch = ''
substituteInPlace source/imgui/src/imgui_impl_sdl2.cpp \ substituteInPlace source/imgui/src/imgui_impl_sdl2.cpp \
--replace '#include <SDL.h>' '#include <SDL2/SDL.h>' \ --replace-fail '#include <SDL.h>' '#include <SDL2/SDL.h>' \
--replace '#include <SDL_syswm.h>' '#include <SDL2/SDL_syswm.h>' \ --replace-fail '#include <SDL_syswm.h>' '#include <SDL2/SDL_syswm.h>' \
--replace '#include <SDL_vulkan.h>' '#include <SDL2/SDL_vulkan.h>' --replace-fail '#include <SDL_vulkan.h>' '#include <SDL2/SDL_vulkan.h>'
'' + lib.optionalString stdenv.isLinux '' '' + lib.optionalString stdenv.isLinux ''
substituteInPlace source/build/src/glbuild.cpp \
--replace libGLU.so ${libGLU}/lib/libGLU.so
for f in glad.c glad_wgl.c ; do for f in glad.c glad_wgl.c ; do
substituteInPlace source/glad/src/$f \ substituteInPlace source/glad/src/$f \
--replace libGL.so ${libGL}/lib/libGL.so --replace-fail libGL.so ${libGL}/lib/libGL.so
done done
''; '';
@ -86,38 +82,72 @@ in stdenv.mkDerivation rec {
"LTO=0" "LTO=0"
]; ];
buildFlags = [
"duke3d"
"sw"
];
desktopItems = [
(makeDesktopItem {
name = "eduke32";
icon = "eduke32";
exec = "${wrapper}";
comment = "Duke Nukem 3D port";
desktopName = "Enhanced Duke Nukem 3D";
genericName = "Duke Nukem 3D port";
categories = [ "Game" ];
})
(makeDesktopItem {
name = "voidsw";
icon = "voidsw";
exec = "${swWrapper}";
comment = "Shadow Warrior eduke32 source port";
desktopName = "VoidSW";
genericName = "Shadow Warrior source port";
categories = [ "Game" ];
})
];
enableParallelBuilding = true; enableParallelBuilding = true;
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
install -Dm755 -t $out/bin eduke32 mapster32 install -Dm755 -t $out/bin eduke32 mapster32 voidsw wangulator
'' + lib.optionalString stdenv.isLinux '' '' + lib.optionalString stdenv.isLinux ''
makeWrapper $out/bin/eduke32 $out/bin/${wrapper} \ makeWrapper $out/bin/eduke32 $out/bin/${wrapper} \
--set-default EDUKE32_DATA_DIR /var/lib/games/eduke32 \ --set-default EDUKE32_DATA_DIR /var/lib/games/eduke32 \
--add-flags '-g "$EDUKE32_DATA_DIR/DUKE3D.GRP"' --add-flags '-g "$EDUKE32_DATA_DIR/DUKE3D.GRP"'
makeWrapper $out/bin/voidsw $out/bin/${swWrapper} \
cp -rv ${desktopItem}/share $out --set-default EDUKE32_DATA_DIR /var/lib/games/eduke32 \
substituteInPlace $out/share/applications/eduke32.desktop \ --add-flags '-g"$EDUKE32_DATA_DIR/SW.GRP"'
--subst-var out mkdir -p $out/share/icons/hicolor/scalable/apps
gm convert "./source/duke3d/rsrc/game_icon.ico[10]" $out/share/icons/hicolor/scalable/apps/eduke32.png
install -Dm644 ./source/sw/rsrc/game_icon.svg $out/share/icons/hicolor/scalable/apps/voidsw.svg
'' + lib.optionalString stdenv.isDarwin '' '' + lib.optionalString stdenv.isDarwin ''
mkdir -p $out/Applications/EDuke32.app/Contents/MacOS mkdir -p $out/Applications/EDuke32.app/Contents/MacOS
mkdir -p $out/Applications/Mapster32.app/Contents/MacOS mkdir -p $out/Applications/Mapster32.app/Contents/MacOS
mkdir -p $out/Applications/VoidSW.app/Contents/MacOS
mkdir -p $out/Applications/Wangulator.app/Contents/MacOS
cp -r platform/Apple/bundles/EDuke32.app/* $out/Applications/EDuke32.app/ cp -r platform/Apple/bundles/EDuke32.app/* $out/Applications/EDuke32.app/
cp -r platform/Apple/bundles/Mapster32.app/* $out/Applications/Mapster32.app/ cp -r platform/Apple/bundles/Mapster32.app/* $out/Applications/Mapster32.app/
cp -r platform/Apple/bundles/VoidSW.app/* $out/Applications/VoidSW.app/
cp -r platform/Apple/bundles/Wangulator.app/* $out/Applications/Wangulator.app/
ln -sf $out/bin/eduke32 $out/Applications/EDuke32.app/Contents/MacOS/eduke32 ln -sf $out/bin/eduke32 $out/Applications/EDuke32.app/Contents/MacOS/eduke32
ln -sf $out/bin/mapster32 $out/Applications/Mapster32.app/Contents/MacOS/mapster32 ln -sf $out/bin/mapster32 $out/Applications/Mapster32.app/Contents/MacOS/mapster32
ln -sf $out/bin/voidsw $out/Applications/VoidSW.app/Contents/MacOS/voidsw
ln -sf $out/bin/wangulator $out/Applications/Wangulator.app/Contents/MacOS/wangulator
'' + '' '' + ''
runHook postInstall runHook postInstall
''; '';
meta = with lib; { meta = {
description = "Enhanched port of Duke Nukem 3D for various platforms"; description = "Enhanched port of Duke Nukem 3D for various platforms";
homepage = "http://eduke32.com"; homepage = "http://eduke32.com";
license = licenses.gpl2Plus; license = with lib.licenses; [ gpl2Plus ];
maintainers = with maintainers; [ mikroskeem sander ]; maintainers = with lib.maintainers; [ mikroskeem sander ];
platforms = platforms.all; platforms = lib.platforms.all;
}; };
} })