Skip to content

Commit cb1697b

Browse files
authored
SDL_compat: set rpath during installation; add tests (#405305)
2 parents b3645c4 + 69948e3 commit cb1697b

File tree

1 file changed

+46
-18
lines changed

1 file changed

+46
-18
lines changed

pkgs/by-name/sd/SDL_compat/package.nix

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
pkg-config,
1212
pkg-config-unwrapped,
1313
stdenv,
14+
testers,
15+
dosbox,
16+
SDL_image,
17+
SDL_ttf,
18+
SDL_mixer,
19+
SDL_sound,
1420
# Boolean flags
1521
libGLSupported ? lib.elem stdenv.hostPlatform.system mesa.meta.platforms,
1622
openglSupport ? libGLSupported,
@@ -52,8 +58,33 @@ stdenv.mkDerivation (finalAttrs: {
5258
]
5359
++ lib.optionals openglSupport [ libGLU ];
5460

61+
postPatch = ''
62+
substituteInPlace CMakeLists.txt \
63+
--replace-fail 'set(CMAKE_SKIP_RPATH TRUE)' 'set(CMAKE_SKIP_RPATH FALSE)'
64+
'';
65+
66+
dontPatchELF = true; # don't strip rpath
67+
68+
cmakeFlags =
69+
let
70+
rpath = lib.makeLibraryPath [ sdl2-compat ];
71+
in
72+
[
73+
(lib.cmakeFeature "CMAKE_INSTALL_RPATH" rpath)
74+
(lib.cmakeFeature "CMAKE_BUILD_RPATH" rpath)
75+
(lib.cmakeBool "SDL12TESTS" finalAttrs.finalPackage.doCheck)
76+
];
77+
5578
enableParallelBuilding = true;
5679

80+
# Darwin fails with "Critical error: required built-in appearance SystemAppearance not found"
81+
doCheck = !stdenv.hostPlatform.isDarwin;
82+
checkPhase = ''
83+
runHook preCheck
84+
./testver
85+
runHook postCheck
86+
'';
87+
5788
postInstall = ''
5889
# allow as a drop in replacement for SDL
5990
# Can be removed after treewide switch from pkg-config to pkgconf
@@ -66,24 +97,17 @@ stdenv.mkDerivation (finalAttrs: {
6697
patches = [ ./find-headers.patch ];
6798
setupHook = ./setup-hook.sh;
6899

69-
postFixup = ''
70-
for lib in $out/lib/*${stdenv.hostPlatform.extensions.sharedLibrary}* ; do
71-
if [[ -L "$lib" ]]; then
72-
${
73-
if stdenv.hostPlatform.isDarwin then
74-
''
75-
install_name_tool ${
76-
lib.strings.concatMapStrings (x: " -add_rpath ${lib.makeLibraryPath [ x ]} ") finalAttrs.buildInputs
77-
} "$lib"
78-
''
79-
else
80-
''
81-
patchelf --set-rpath "$(patchelf --print-rpath $lib):${lib.makeLibraryPath finalAttrs.buildInputs}" "$lib"
82-
''
83-
}
84-
fi
85-
done
86-
'';
100+
passthru.tests = {
101+
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
102+
103+
inherit
104+
SDL_image
105+
SDL_ttf
106+
SDL_mixer
107+
SDL_sound
108+
dosbox
109+
;
110+
};
87111

88112
meta = {
89113
homepage = "https://www.libsdl.org/";
@@ -93,5 +117,9 @@ stdenv.mkDerivation (finalAttrs: {
93117
maintainers = with lib.maintainers; [ peterhoeg ];
94118
teams = [ lib.teams.sdl ];
95119
platforms = lib.platforms.all;
120+
pkgConfigModules = [
121+
"sdl"
122+
"sdl12_compat"
123+
];
96124
};
97125
})

0 commit comments

Comments
 (0)