Message ID | 20210723210801.9458-1-i.gankevich@spbu.ru |
---|---|
State | Accepted |
Headers | show |
Series | [bug#49713,1/3] gnu: cereal: Use cmake to build and install the library. | expand |
Context | Check | Description |
---|---|---|
cbaines/applying patch | fail | View Laminar job |
cbaines/issue | success | View issue |
Hi, Am Samstag, den 24.07.2021, 00:08 +0300 schrieb Ivan Gankevich: > * gnu/packages/engineering.scm (prusa-slicer): New variable. > --- > gnu/packages/engineering.scm | 97 > ++++++++++++++++++++++++++++++++++++ > 1 file changed, 97 insertions(+) > > diff --git a/gnu/packages/engineering.scm > b/gnu/packages/engineering.scm > index eec12814ff..d88520a306 100644 > --- a/gnu/packages/engineering.scm > +++ b/gnu/packages/engineering.scm > @@ -24,6 +24,7 @@ > ;;; Copyright © 2021 qblade <qblade@protonmail.com> > ;;; Copyright © 2021 Gerd Heber <gerd.heber@gmail.com> > ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net> > +;;; Copyright © 2021 Ivan Gankevich <i.gankevich@spbu.ru> > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -95,6 +96,7 @@ > #:use-module (gnu packages image-processing) > #:use-module (gnu packages imagemagick) > #:use-module (gnu packages libevent) > + #:use-module (gnu packages libusb) > #:use-module (gnu packages linux) ;FIXME: for pcb > #:use-module (gnu packages lisp) > #:use-module (gnu packages m4) > @@ -2924,3 +2926,98 @@ a process.") > (description "The library provides functionality for shape > modelling, > visualization, matrix manipulation.") > (license (list license:gpl3 license:mpl2.0)))) > + > +(define-public prusa-slicer > + (package > + (name "prusa-slicer") > + (version "2.3.3") > + (source > + (origin > + (method git-fetch) > + (uri > + (git-reference > + (url "https://github.com/prusa3d/PrusaSlicer") > + (commit (string-append "version_" version)))) > + (file-name (git-file-name name version)) > + (sha256 (base32 > "0w0synqi3iz9aigsgv6x1c6sg123fasbx19h4w3ic1l48r8qmpwm")))) > + (build-system cmake-build-system) > + (arguments > + `(#:configure-flags > + '("-DSLIC3R_FHS=1" ;; Use The Filesystem Hierarchy Standard. > + "-DSLIC3R_WX_STABLE=1") ;; Use wxWidgets 3.0.x.x to > prevent GUI crashes. > + #:phases > + (modify-phases %standard-phases > + ;; CMake is unable to find headers from glib, pango and > gtk+ > + ;; when compiling src/slic3r. Here we add them via > environment variables. > + (add-before 'configure 'add-glib-pango-gtk+ > + (lambda _ > + (use-modules > + (ice-9 popen) > + (ice-9 textual-ports)) > + (define (append-flags name flags) > + (define old-value (getenv name)) > + (setenv name (if old-value (string-append old-value > " " flags) flags))) > + (define (pkg-config args) > + (let* ((port (open-input-pipe (string-join (cons > "pkg-config" args) " "))) > + (content (string-trim-both (get-string-all > port)))) > + (close-pipe port) > + content)) > + (define deps '("glib-2.0" "pango" "gtk+-2.0" "hidapi- > hidraw")) > + (define cflags (pkg-config (cons "--cflags" deps))) > + (define ld-flags (pkg-config (cons "--libs" deps))) > + (define libigl (assoc-ref %build-inputs "libigl")) > + (append-flags "CXXFLAGS" cflags) > + (append-flags "CFLAGS" cflags) > + (append-flags "LDFLAGS" ld-flags) > + (append-flags "CFLAGS" (string-append "-I" libigl > "/include")) > + (append-flags "LDFLAGS" (string-append "-L" libigl > "/lib")))) Upstream already appears to search for GTK+3 with their CMake setup. Perhaps that's why it doesn't find GTK+2? > + (add-before 'configure 'unbundle-3d-party-libraries > + ;; Prusa slicer bundles a lot of dependencies in src/ > directory. > + ;; Most of them contain prusa-specific modifications > (e.g. avrdude), > + ;; but others do not. Here we replace the latter with > Guix packages. > + (lambda _ > + (delete-file-recursively "src/hidapi") > + (delete-file-recursively "src/eigen") > + (delete-file-recursively "src/libigl/igl") > + (substitute* "src/CMakeLists.txt" > + (("add_subdirectory\\(libigl\\)" all) > + (string-append > + all "\ninclude_directories(libigl INTERFACE > libigl::core)")) > + (("add_subdirectory\\(hidapi\\)") "") > + (("include_directories\\(hidapi/include\\)") "")) > + ;; Do not link with bundled hidapi library. > + (substitute* "src/slic3r/CMakeLists.txt" > + (("\\bhidapi\\b") ""))))))) Unbundling should be done in the snippet rather than at build time. > + (native-inputs > + `(("pkg-config" ,pkg-config))) > + (inputs > + `(("boost" ,boost) > + ("libigl" ,libigl) > + ("tbb" ,tbb) > + ("curl" ,curl) > + ("zlib" ,zlib) > + ("eigen" ,eigen) > + ("expat" ,expat) > + ("mesa" ,mesa) > + ("cereal" ,cereal) > + ("nlopt" ,nlopt) > + ("openvdb" ,openvdb) > + ("ilmbase" ,ilmbase) > + ("cgal" ,cgal) > + ("hidapi" ,hidapi) > + ;;("wxwidgets" ,wxwidgets-gtk2-3.1) ;; crashes when adding > support enforcers > + ("wxwidgets" ,wxwidgets-gtk2) > + ("glew" ,glew) > + ("udev" ,eudev) > + ("gmp" ,gmp) > + ("mpfr" ,mpfr) > + ("libpng" ,libpng) > + ("dbus" ,dbus) > + ("glib" ,glib) > + ("pango" ,pango) > + ("gtk" ,gtk+-2))) Try sorting the inputs alphabetically, also w.r.t. gtk+-2, see above. > + (home-page "https://www.prusa3d.com/prusaslicer/") > + (synopsis "G-code generator for 3D printers (RepRap, Makerbot, > Ultimaker etc.)") > + (description "PrusaSlicer takes 3D models (STL, OBJ, AMF) and > converts them into > +G-code instructions for FFF printers or PNG layers for mSLA 3D > printers.") > + (license license:agpl3))) Regards
>> + ;; CMake is unable to find headers from glib, pango and >> gtk+ >> + ;; when compiling src/slic3r. Here we add them via >> environment variables. >> + (add-before 'configure 'add-glib-pango-gtk+ >Upstream already appears to search for GTK+3 with their CMake setup. >Perhaps that's why it doesn't find GTK+2? I changed GTK+2 to GTK+3 and removed the whole “add-glib-pango-gtk+” phase. >> + (add-before 'configure 'unbundle-3d-party-libraries >> + ;; Prusa slicer bundles a lot of dependencies in src/ >> directory. >> + ;; Most of them contain prusa-specific modifications >> (e.g. avrdude), >> + ;; but others do not. Here we replace the latter with >> Guix packages. >> + (lambda _ >> + (delete-file-recursively "src/hidapi") >> + (delete-file-recursively "src/eigen") >> + (delete-file-recursively "src/libigl/igl") >> + (substitute* "src/CMakeLists.txt" >> + (("add_subdirectory\\(libigl\\)" all) >> + (string-append >> + all "\ninclude_directories(libigl INTERFACE >> libigl::core)")) >> + (("add_subdirectory\\(hidapi\\)") "") >> + (("include_directories\\(hidapi/include\\)") "")) >> + ;; Do not link with bundled hidapi library. >> + (substitute* "src/slic3r/CMakeLists.txt" >> + (("\\bhidapi\\b") ""))))))) >Unbundling should be done in the snippet rather than at build time. Moved deletion of directories to the snippet. >Try sorting the inputs alphabetically, also w.r.t. gtk+-2, see above. Now its is sorted and no more GTK+2. Thanks for your corrections. I’ve sent the updated version of this patch via “git send-email”. Regards, Ivan
Am Montag, den 20.09.2021, 00:39 +0300 schrieb Ivan Gankevich: > > Unbundling should be done in the snippet rather than at build time. > > Moved deletion of directories to the snippet. I'd argue that fixing the CMakeLists also falls into snippet territory, as it's directly related to unbundling. Am Sonntag, den 19.09.2021, 23:18 +0300 schrieb Ivan Gankevich: > This library is header-only. All the dependencies from this list are > used in the tests. Headers that use these dependencies are installed > no matter which dependenies are “ON” in this list. I’ve added XML. > Adding other dependencies would require rewriting most of > “cmake/libigl.cmake” file, because the authors of the package like to > download and build all the dependencies manually. Could this be done with substitute* as for the other packages? If not, we should group those options under a sufficiently explanatory comment. Also, there's little need to explicitly enable things that would already be enabled by default, let's keep the list of flags small and understandable :) When you send v3, please do all patches in one go and also specify -- reroll-count, as that's easier on mumi. Thanks
>I'd argue that fixing the CMakeLists also falls into snippet territory, >as it's directly related to unbundling. Agreed. Moved the code to the snippet. >Could this be done with substitute* as for the other packages? If not, >we should group those options under a sufficiently explanatory comment. >Also, there's little need to explicitly enable things that would >already be enabled by default, let's keep the list of flags small and >understandable :) Enabled all “low-hanging fruits” and added the comment explaning that these are tests depedencies. >When you send v3, please do all patches in one go and also specify -- >reroll-count, as that's easier on mumi. I hope I did it right :-) Regards, Ivan
Hi,
Am Dienstag, den 21.09.2021, 01:17 +0300 schrieb Ivan Gankevich:
> I hope I did it right :-)
I've pushed this now with some changes. Apart from trivial indentation
changes and (list ...) -> '(...), I made all inputs to libigl regular
and fixed up the phases as follows:
- do-not-download-dependencies split into unpack-external and
patch-cmake
- install-all-subdirs dropped, instead patched cmake to install
relevant headers.
Regards
diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm index eec12814ff..d88520a306 100644 --- a/gnu/packages/engineering.scm +++ b/gnu/packages/engineering.scm @@ -24,6 +24,7 @@ ;;; Copyright © 2021 qblade <qblade@protonmail.com> ;;; Copyright © 2021 Gerd Heber <gerd.heber@gmail.com> ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net> +;;; Copyright © 2021 Ivan Gankevich <i.gankevich@spbu.ru> ;;; ;;; This file is part of GNU Guix. ;;; @@ -95,6 +96,7 @@ #:use-module (gnu packages image-processing) #:use-module (gnu packages imagemagick) #:use-module (gnu packages libevent) + #:use-module (gnu packages libusb) #:use-module (gnu packages linux) ;FIXME: for pcb #:use-module (gnu packages lisp) #:use-module (gnu packages m4) @@ -2924,3 +2926,98 @@ a process.") (description "The library provides functionality for shape modelling, visualization, matrix manipulation.") (license (list license:gpl3 license:mpl2.0)))) + +(define-public prusa-slicer + (package + (name "prusa-slicer") + (version "2.3.3") + (source + (origin + (method git-fetch) + (uri + (git-reference + (url "https://github.com/prusa3d/PrusaSlicer") + (commit (string-append "version_" version)))) + (file-name (git-file-name name version)) + (sha256 (base32 "0w0synqi3iz9aigsgv6x1c6sg123fasbx19h4w3ic1l48r8qmpwm")))) + (build-system cmake-build-system) + (arguments + `(#:configure-flags + '("-DSLIC3R_FHS=1" ;; Use The Filesystem Hierarchy Standard. + "-DSLIC3R_WX_STABLE=1") ;; Use wxWidgets 3.0.x.x to prevent GUI crashes. + #:phases + (modify-phases %standard-phases + ;; CMake is unable to find headers from glib, pango and gtk+ + ;; when compiling src/slic3r. Here we add them via environment variables. + (add-before 'configure 'add-glib-pango-gtk+ + (lambda _ + (use-modules + (ice-9 popen) + (ice-9 textual-ports)) + (define (append-flags name flags) + (define old-value (getenv name)) + (setenv name (if old-value (string-append old-value " " flags) flags))) + (define (pkg-config args) + (let* ((port (open-input-pipe (string-join (cons "pkg-config" args) " "))) + (content (string-trim-both (get-string-all port)))) + (close-pipe port) + content)) + (define deps '("glib-2.0" "pango" "gtk+-2.0" "hidapi-hidraw")) + (define cflags (pkg-config (cons "--cflags" deps))) + (define ld-flags (pkg-config (cons "--libs" deps))) + (define libigl (assoc-ref %build-inputs "libigl")) + (append-flags "CXXFLAGS" cflags) + (append-flags "CFLAGS" cflags) + (append-flags "LDFLAGS" ld-flags) + (append-flags "CFLAGS" (string-append "-I" libigl "/include")) + (append-flags "LDFLAGS" (string-append "-L" libigl "/lib")))) + (add-before 'configure 'unbundle-3d-party-libraries + ;; Prusa slicer bundles a lot of dependencies in src/ directory. + ;; Most of them contain prusa-specific modifications (e.g. avrdude), + ;; but others do not. Here we replace the latter with Guix packages. + (lambda _ + (delete-file-recursively "src/hidapi") + (delete-file-recursively "src/eigen") + (delete-file-recursively "src/libigl/igl") + (substitute* "src/CMakeLists.txt" + (("add_subdirectory\\(libigl\\)" all) + (string-append + all "\ninclude_directories(libigl INTERFACE libigl::core)")) + (("add_subdirectory\\(hidapi\\)") "") + (("include_directories\\(hidapi/include\\)") "")) + ;; Do not link with bundled hidapi library. + (substitute* "src/slic3r/CMakeLists.txt" + (("\\bhidapi\\b") ""))))))) + (native-inputs + `(("pkg-config" ,pkg-config))) + (inputs + `(("boost" ,boost) + ("libigl" ,libigl) + ("tbb" ,tbb) + ("curl" ,curl) + ("zlib" ,zlib) + ("eigen" ,eigen) + ("expat" ,expat) + ("mesa" ,mesa) + ("cereal" ,cereal) + ("nlopt" ,nlopt) + ("openvdb" ,openvdb) + ("ilmbase" ,ilmbase) + ("cgal" ,cgal) + ("hidapi" ,hidapi) + ;;("wxwidgets" ,wxwidgets-gtk2-3.1) ;; crashes when adding support enforcers + ("wxwidgets" ,wxwidgets-gtk2) + ("glew" ,glew) + ("udev" ,eudev) + ("gmp" ,gmp) + ("mpfr" ,mpfr) + ("libpng" ,libpng) + ("dbus" ,dbus) + ("glib" ,glib) + ("pango" ,pango) + ("gtk" ,gtk+-2))) + (home-page "https://www.prusa3d.com/prusaslicer/") + (synopsis "G-code generator for 3D printers (RepRap, Makerbot, Ultimaker etc.)") + (description "PrusaSlicer takes 3D models (STL, OBJ, AMF) and converts them into +G-code instructions for FFF printers or PNG layers for mSLA 3D printers.") + (license license:agpl3)))