prusa-slicer: Fix STEP format support

We move the OCCTWrapper dynamic library /bin to /lib and patch the
loading code to find its location dynamically.

Previously the library load would fail on STEP imports like this:

> /nix/store/4j1rm3sqjvfii68kb51ccvynzvll0jna-prusa-slicer-2.5.0/bin/OCCTWrapper.so: cannot dynamically load executable

because when wrapped it is not a library any more.

> OCCTWrapper.so: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/bzd91shky9j9d43girrrj6vmqlw7x9m8-glibc-2.35-163/lib/ld-linux-x86-64.so.2, BuildID\[sha1\]=28396fb28c32d0ec7bb75ea5c550760186b86c20, for GNU/Linux 2.6.32, not stripped

Co-authored-by: André-Patrick Bubel <code@apb.name>
This commit is contained in:
Martin Weinelt 2022-09-18 19:53:14 +02:00
parent b1bc570518
commit bcca922de5

View File

@ -130,6 +130,15 @@ stdenv.mkDerivation rec {
# likely due to commit e682dd84cff5d2420fcc0a40508557477f6cc9d3
# See issue #185808 for details.
sed -i 's|test_voronoi.cpp||g' tests/libslic3r/CMakeLists.txt
# prusa-slicer expects the OCCTWrapper shared library in the same folder as
# the executable when loading STEP files. We force the loader to find it in
# the usual locations (i.e. LD_LIBRARY_PATH) instead. See the manpage
# dlopen(3) for context.
if [ -f "src/libslic3r/Format/STEP.cpp" ]; then
substituteInPlace src/libslic3r/Format/STEP.cpp \
--replace 'libpath /= "OCCTWrapper.so";' 'libpath = "OCCTWrapper.so";'
fi
'';
src = fetchFromGitHub {
@ -147,11 +156,20 @@ stdenv.mkDerivation rec {
postInstall = ''
ln -s "$out/bin/prusa-slicer" "$out/bin/prusa-gcodeviewer"
mkdir -p "$out/lib"
mv -v $out/bin/*.so $out/lib/
mkdir -p "$out/share/pixmaps/"
ln -s "$out/share/PrusaSlicer/icons/PrusaSlicer.png" "$out/share/pixmaps/PrusaSlicer.png"
ln -s "$out/share/PrusaSlicer/icons/PrusaSlicer-gcodeviewer_192px.png" "$out/share/pixmaps/PrusaSlicer-gcodeviewer.png"
'';
preFixup = ''
gappsWrapperArgs+=(
--prefix LD_LIBRARY_PATH : "$out/lib"
)
'';
meta = with lib; {
description = "G-code generator for 3D printer";
homepage = "https://github.com/prusa3d/PrusaSlicer";