From f2f275b9e70ca6691c5826e196f3565e5fedcee3 Mon Sep 17 00:00:00 2001 From: liberodark Date: Tue, 31 Dec 2024 18:28:26 +0100 Subject: [PATCH] orca-slicer: fix gcc14 --- pkgs/by-name/or/orca-slicer/package.nix | 262 ++++++++++++++---- .../or/orca-slicer/patches/fix-boost.patch | 60 ++++ 2 files changed, 275 insertions(+), 47 deletions(-) create mode 100644 pkgs/by-name/or/orca-slicer/patches/fix-boost.patch diff --git a/pkgs/by-name/or/orca-slicer/package.nix b/pkgs/by-name/or/orca-slicer/package.nix index d6d8c4a93847d9..559e81ddd626d6 100644 --- a/pkgs/by-name/or/orca-slicer/package.nix +++ b/pkgs/by-name/or/orca-slicer/package.nix @@ -1,52 +1,220 @@ { + stdenv, lib, + binutils, fetchFromGitHub, - bambu-studio, + cmake, + pkg-config, + wrapGAppsHook3, + boost, + cereal, + cgal, + curl, + dbus, + eigen, + expat, + ffmpeg, + gcc-unwrapped, + glew, + glfw, + glib, + glib-networking, + gmp, + gst_all_1, + gtest, + gtk3, + hicolor-icon-theme, + ilmbase, + libpng, + mesa, + mpfr, + nlopt, + opencascade-occt_7_6, + openvdb, + opencv, + pcre, + systemd, + tbb_2021_11, + webkitgtk_4_0, + wxGTK31, + xorg, + withSystemd ? stdenv.hostPlatform.isLinux, }: -bambu-studio.overrideAttrs ( - finalAttrs: previousAttrs: { - version = "2.2.0"; - pname = "orca-slicer"; - - src = fetchFromGitHub { - owner = "SoftFever"; - repo = "OrcaSlicer"; - rev = "v${finalAttrs.version}"; - hash = "sha256-h+cHWhrp894KEbb3ic2N4fNTn13WlOSYoMsaof0RvRI="; - }; - - patches = [ - # Fix for webkitgtk linking - ./patches/0001-not-for-upstream-CMakeLists-Link-against-webkit2gtk-.patch - ./patches/dont-link-opencv-world-orca.patch - ]; +let + wxGTK' = + (wxGTK31.override { + withCurl = true; + withPrivateFonts = true; + withWebKit = true; + }).overrideAttrs + (old: { + configureFlags = old.configureFlags ++ [ + # Disable noisy debug dialogs + "--enable-debug=no" + ]; + }); +in +stdenv.mkDerivation rec { + pname = "orca-slicer"; + version = "2f55dd7cfe3e3d2c41fdd73dddc31f1c5dcbdf83"; + + src = fetchFromGitHub { + owner = "SoftFever"; + repo = "OrcaSlicer"; + tag = version; + hash = "sha256-2JHGNVKLJ5aJlcS0KCdegrTmj80utT5sfKO6XlG9blg="; + }; + + nativeBuildInputs = [ + cmake + pkg-config + wrapGAppsHook3 + wxGTK' + ]; + + buildInputs = + [ + binutils + (boost.override { + enableShared = true; + enableStatic = false; + extraFeatures = [ + "log" + "thread" + "filesystem" + ]; + }) + boost.dev + cereal + cgal + curl + dbus + eigen + expat + ffmpeg + gcc-unwrapped + glew + glfw + glib + glib-networking + gmp + gst_all_1.gstreamer + gst_all_1.gst-plugins-base + gst_all_1.gst-plugins-bad + gst_all_1.gst-plugins-good + gtk3 + hicolor-icon-theme + ilmbase + libpng + mesa + mesa.osmesa + mesa.drivers + mpfr + nlopt + opencascade-occt_7_6 + openvdb + pcre + tbb_2021_11 + webkitgtk_4_0 + wxGTK' + xorg.libX11 + opencv + ] + ++ lib.optionals withSystemd [ systemd ] + ++ checkInputs; + + patches = [ + # Fix for webkitgtk linking + ./patches/0001-not-for-upstream-CMakeLists-Link-against-webkit2gtk-.patch + ./patches/dont-link-opencv-world-orca.patch + ./patches/fix-boost.patch + ]; + + doCheck = true; + checkInputs = [ gtest ]; + + separateDebugInfo = true; - preFixup = '' - gappsWrapperArgs+=( - # Fixes blackscreen dialogs - --set WEBKIT_DISABLE_COMPOSITING_MODE 1 - ) - ''; - - cmakeFlags = lib.remove "-DFLATPAK=1" previousAttrs.cmakeFlags or [ ]; - - # needed to prevent collisions between the LICENSE.txt files of - # bambu-studio and orca-slicer. - postInstall = '' - mv $out/LICENSE.txt $out/share/OrcaSlicer/LICENSE.txt - ''; - - meta = with lib; { - description = "G-code generator for 3D printers (Bambu, Prusa, Voron, VzBot, RatRig, Creality, etc.)"; - homepage = "https://github.com/SoftFever/OrcaSlicer"; - license = licenses.agpl3Only; - maintainers = with maintainers; [ - zhaofengli - ovlach - pinpox - ]; - mainProgram = "orca-slicer"; - platforms = platforms.linux; - }; - } -) + NLOPT = nlopt; + + NIX_CFLAGS_COMPILE = toString [ + "-Wno-ignored-attributes" + "-I${opencv.out}/include/opencv4" + "-Wno-error=template-id-cdtor" + "-Wno-error=incompatible-pointer-types" + "-Wno-template-id-cdtor" + "-Wno-uninitialized" + "-Wno-unused-result" + "-Wno-deprecated-declarations" + "-Wno-use-after-free" + "-Wno-format-overflow" + "-Wno-stringop-overflow" + "-DBOOST_ALLOW_DEPRECATED_HEADERS" + "-DBOOST_MATH_DISABLE_STD_FPCLASSIFY" + "-DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS" + "-DBOOST_MATH_DISABLE_FLOAT128" + "-DBOOST_MATH_NO_QUAD_SUPPORT" + "-DBOOST_MATH_MAX_FLOAT128_DIGITS=0" + "-DBOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT" + "-DBOOST_MATH_DISABLE_FLOAT128_BUILTIN_FPCLASSIFY" + ]; + + NIX_LDFLAGS = toString [ + (lib.optionalString withSystemd "-ludev") + "-L${mesa.osmesa}/lib" + "-L${mesa.drivers}/lib" + "-L${boost}/lib" + "-lboost_log" + "-lboost_log_setup" + ]; + + prePatch = '' + sed -i 's|nlopt_cxx|nlopt|g' cmake/modules/FindNLopt.cmake + ''; + + cmakeFlags = [ + "-DSLIC3R_STATIC=0" + "-DSLIC3R_FHS=1" + "-DSLIC3R_GTK=3" + "-DBBL_RELEASE_TO_PUBLIC=1" + "-DBBL_INTERNAL_TESTING=0" + "-DDEP_WX_GTK3=ON" + "-DSLIC3R_BUILD_TESTS=0" + "-DCMAKE_CXX_FLAGS=-DBOOST_LOG_DYN_LINK" + "-DBOOST_LOG_DYN_LINK=1" + "-DBOOST_ALL_DYN_LINK=1" + "-DBOOST_LOG_NO_LIB=OFF" + "-DCMAKE_CXX_FLAGS=-DGL_SILENCE_DEPRECATION" + "-DCMAKE_EXE_LINKER_FLAGS=-Wl,--no-as-needed" + "-DCMAKE_EXE_LINKER_FLAGS=-Wl,-rpath,${mesa.drivers}/lib -Wl,-rpath,${mesa.osmesa}/lib" + ]; + + preFixup = '' + gappsWrapperArgs+=( + --prefix LD_LIBRARY_PATH : "$out/lib:${ + lib.makeLibraryPath [ + mesa.drivers + mesa.osmesa + glew + ] + }" + --prefix LIBGL_DRIVERS_PATH : "${mesa.drivers}/lib/dri" + --set WEBKIT_DISABLE_COMPOSITING_MODE 1 + ) + ''; + + meta = { + description = "G-code generator for 3D printers (Bambu, Prusa, Voron, VzBot, RatRig, Creality, etc.)"; + homepage = "https://github.com/SoftFever/OrcaSlicer"; + changelog = "https://github.com/SoftFever/OrcaSlicer/releases/tag/v${version}"; + license = lib.licenses.agpl3Only; + maintainers = with lib.maintainers; [ + zhaofengli + ovlach + pinpox + liberodark + ]; + mainProgram = "orca-slicer"; + platforms = lib.platforms.linux; + }; +} diff --git a/pkgs/by-name/or/orca-slicer/patches/fix-boost.patch b/pkgs/by-name/or/orca-slicer/patches/fix-boost.patch new file mode 100644 index 00000000000000..aaced2fe79e58b --- /dev/null +++ b/pkgs/by-name/or/orca-slicer/patches/fix-boost.patch @@ -0,0 +1,60 @@ +diff --git a/src/libslic3r/PrintBase.cpp b/src/libslic3r/PrintBase.cpp +index 25b282c7b..81ee858c2 100644 +--- a/src/libslic3r/PrintBase.cpp ++++ b/src/libslic3r/PrintBase.cpp +@@ -79,7 +79,7 @@ std::string PrintBase::output_filename(const std::string &format, const std::str + cfg.opt_string("input_filename_base") + default_ext : + this->placeholder_parser().process(format, 0, &cfg); + if (filename.extension().empty()) +- filename = boost::filesystem::change_extension(filename, default_ext); ++ filename.replace_extension(default_ext); + return filename.string(); + } catch (std::runtime_error &err) { + throw Slic3r::PlaceholderParserError(L("Failed processing of the filename_format template.") + "\n" + err.what()); +diff --git a/src/slic3r/GUI/AuxiliaryDataViewModel.cpp b/src/slic3r/GUI/AuxiliaryDataViewModel.cpp +index 50368b854..cad5cf545 100644 +--- a/src/slic3r/GUI/AuxiliaryDataViewModel.cpp ++++ b/src/slic3r/GUI/AuxiliaryDataViewModel.cpp +@@ -337,7 +337,7 @@ wxDataViewItemArray AuxiliaryModel::ImportFile(AuxiliaryModelNode* sel, wxArrayS + dir_path += "\\" + src_bfs_path.filename().generic_wstring(); + + boost::system::error_code ec; +- if (!fs::copy_file(src_bfs_path, fs::path(dir_path.ToStdWstring()), fs::copy_option::overwrite_if_exists, ec)) ++ if (!fs::copy_file(src_bfs_path, fs::path(dir_path.ToStdWstring()), fs::copy_options::overwrite_existing, ec)) + continue; + + // Update model data +diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp +index f3782be14..e12f0c321 100644 +--- a/src/slic3r/GUI/Plater.cpp ++++ b/src/slic3r/GUI/Plater.cpp +@@ -10265,7 +10265,7 @@ bool Plater::preview_zip_archive(const boost::filesystem::path& archive_path) + std::replace(name.begin(), name.end(), '\\', '/'); + // rename if file exists + std::string filename = path.filename().string(); +- std::string extension = boost::filesystem::extension(path); ++ std::string extension = path.extension().string(); + std::string just_filename = filename.substr(0, filename.size() - extension.size()); + std::string final_filename = just_filename; + +diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp +index a26e13448..83ec4695c 100644 +--- a/src/slic3r/GUI/RemovableDriveManager.cpp ++++ b/src/slic3r/GUI/RemovableDriveManager.cpp +@@ -22,7 +22,6 @@ + #include + #include + #include +-#include + #include + #endif + +@@ -202,7 +201,7 @@ namespace search_for_drives_internal + stat(path.c_str(), &buf); + uid_t uid = buf.st_uid; + if (getuid() == uid) +- out.emplace_back(DriveData{ boost::filesystem::basename(boost::filesystem::path(path)), path }); ++ out.emplace_back(DriveData{ boost::filesystem::path(path).stem().string(), path }); + } + } + }