diff mbox series

[bug#57361] Solvespace package re-done

Message ID CAAGQtHyLKjDmcVHVFyqoGE4-0KiHF7TnE5joagEWnV7T2hdXnA@mail.gmail.com
State Accepted
Headers show
Series [bug#57361] Solvespace package re-done | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Kristian Lein-Mathisen Aug. 31, 2022, 6:51 p.m. UTC
Based off feedback from lilyp and rekado_ on #guix, I've made some
improvements:

- Remove the recursive checkout
- Extract mimalloc as a (nonpublic) package
- Fix commit hash value
- Enabled tests

I've made an amend commit, so the new patch replaces the original one above.

Note that the previous commit hash of solvespace of was off. The correct
hash for solvespace 3.1 is 70bde63cb32a7f049fa56cbdf924e2695fcb2916, as
shown in the new patch.

Thanks for all help this far, and hoping to see SolveSpace included in GNU
Guix.
- Kris

Comments

Liliana Marie Prikler Sept. 1, 2022, 5:18 p.m. UTC | #1
Am Mittwoch, dem 31.08.2022 um 20:51 +0200 schrieb Kristian Lein-
Mathisen:

> ;; There is another mimalloc, used in rust-mimalloc. But it's on
> mimalloc
> +;; version 1.6.4. TODO: See if it's possible to re-use this package
> by both.
> +(define mimalloc-for-solvespace
Given that this is the upstream mimalloc, there's no reason to make
this private or only for solvespace.  Note that you should separate
this into one patch per package.

> +  (let ((commit "f2712f4a8f038a7fb4df2790f4c3b7e3ed9e219b")
> +        (version "2.0.6"))
This is the release commit, no reason to use git-version etc. here
> +    (package
> +      (name "mimalloc-for-solvespace")
> +      (version (git-version version "1" commit))
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url "https://github.com/microsoft/mimalloc")
> +                      (commit commit)))
You can use (string-append "v" version) to check out the tag.
> +                (file-name (git-file-name name version))
> +                (sha256
> +                 (base32
> +                 
> "05x2dl3zimflfj91ns3vrphmzpdlyyr230p9adqgfds101f16qmv"))))
> +      (build-system cmake-build-system)
> +      (arguments
> +       `(#:build-type "Release"))
> +      (synopsis "Compact general purpose allocator with excellent
> performance")
Don't bloat the synopsis with marketing terms; "General purpose
allocator" should probably suffice.
> +      (description "@code{mimalloc} is a drop-in replacement for
> @code{malloc}
.")

The rest appears somewhat superfluous :)
> +      (home-page "https://microsoft.github.io/mimalloc/")
> +      (license license:expat))))


> +(define-public solvespace
> +  (let ((commit "70bde63cb32a7f049fa56cbdf924e2695fcb2916")
> +        (version "3.1")
I haven't checked, but is this the release commit?  If so, no need for
all this verbosity.

> +        ;; libdxfrw has no readme, no version release, no tags. 
> Initial
> +        ;; commit says "libdxfrw-0.6.3 import", but it shares no git
> history
> +        ;; with "upstream" https://github.com/codelibs/libdxfrw. 
> Both are
> +        ;; difficult to package separately as they don't install
> properly.
> +        ;; Copying in-tree instead of #:recursive #t to avoid
> downloading the
> +        ;; other bigger dependencies which aren't needed.
> +        (libdxfrw-sources (origin
> +                            (method git-fetch)
> +                            (uri (git-reference (url
> +                                                
> "https://github.com/solvespace/libdxfrw")
> +                                                (commit
> +                                                
> "0b7b7b709d9299565db603f878214656ef5e9ddf")))
> +                            (sha256 (base32
> +                                    
> "0d2wjq81466m3hb5cffiy99vhx0irwwy47yfxp318k2q4cvd5z2a")))))
This should be its own variable.  Unlike with mimalloc, since it's just
an origin, you can use the same patch as solvespace.
> +    (package
> +      (name "solvespace")
> +      (version (git-version version "1" commit))
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url
> "https://github.com/solvespace/solvespace")
> +                      (commit commit)))
> +                (file-name (git-file-name name version))
> +                (sha256
> +                 (base32
> +                 
> "1hbdln44k00a6vlklv2mq2c9zda3i9d5x0f7ks85w4v6zskhqnra"))))
> +      (build-system cmake-build-system)
> +      (native-inputs (list pkg-config gettext-minimal))
> +      (arguments
> +       (list #:build-type "Release"
> +             #:phases #~(modify-phases %standard-phases
`guix style' is not yet perfect when it comes to trade-offs between
horizontal and vertical space.  Prefer 
  (list 
   #:build-type "Release"
   #:phases
   #~(modify-phases ...
> +                          (add-after 'unpack 'unpack-libdxfrw
> +                            (lambda _
> +                              (copy-recursively #$libdxfrw-sources
> +                                                "extlib/libdxfrw")))
> +                          (add-before 'configure 'embed-git-commit-
> hash
> +                            (lambda _
> +                              ;; `git describe` doesn't work here,
> so embed
> +                              ;; the commit hash directly in
> CMakeLists.txt as
> +                              ;; described instead.
> +                              (substitute* "CMakeLists.txt"
> +                                (("include\\(GetGitCommitHash\\)")
> +                                 (string-append "set(GIT_COMMIT_HASH
> "
> +                                                #$commit ")")))))
> +                          (add-before 'configure 'use-packaged-
> mimalloc
> +                            (lambda _
> +                              (substitute* "CMakeLists.txt"
> +                                (("message\\(STATUS \"Using in-tree
> mimalloc\"\\)")
> +                                 "message(STATUS \"Using guix
> packaged mimalloc\")")
> +                               
> (("add_subdirectory\\(extlib/mimalloc EXCLUDE_FROM_ALL\\)")
> +                                 "find_package(mimalloc
> REQUIRED)")))))))
> +      (inputs (list cairo
> +                    eigen
> +                    freetype
> +                    gtkmm-3
> +                    json-c
> +                    libpng
> +                    libspnav            ;spaceware
> +                    mimalloc-for-solvespace
> +                    mesa
> +                    zlib))
> +      (synopsis "Parametric 2D/3D CAD")
> +      (description
> +       "SOLVESPACE is a parametric 3D @acronym{CAD,
> +Computer Aided Design} tool.  Applications include:
> +
> +@itemize
> +@item modeling 3d parts — draw with extrudes, revolves, helixes and
> +      Boolean (union / difference / intersection) operations
> +@item modeling 2d parts — draw the part as a single section,
> +      and export DXF, PDF, SVG; use 3d assembly to verify fit
> +@item 3d-printed parts — export the STL or other triangle mesh
> +      expected by most 3d printers
> +@item preparing CAM data — export 2d vector art for a waterjet
> +      machine or laser cutter; or generate STEP or STL, for import
> into
> +      third-party CAM software for machining
> +@item mechanism design — use the constraint solver to simulate
> planar
> +      or spatial linkages, with pin, ball, or slide joints
> +@item plane and solid geometry — replace hand-solved trigonometry
> and spreadsheets
> +      with a live dimensioned drawing
> +@end itemize")
> +      (home-page "https://solvespace.com/")
> +      (license license:gpl3+))))
> +

Cheers
Liliana Marie Prikler Sept. 1, 2022, 5:20 p.m. UTC | #2
Am Donnerstag, dem 01.09.2022 um 19:18 +0200 schrieb Liliana Marie
Prikler:
> Am Mittwoch, dem 31.08.2022 um 20:51 +0200 schrieb Kristian Lein-
> Mathisen:
> 
> > ;; There is another mimalloc, used in rust-mimalloc. But it's on
> > mimalloc
> > +;; version 1.6.4. TODO: See if it's possible to re-use this
> > package
> > by both.
> > +(define mimalloc-for-solvespace
> Given that this is the upstream mimalloc, there's no reason to make
> this private or only for solvespace.  Note that you should separate
> this into one patch per package.
Oh, and there's no conflict with rust-mimalloc, since that bundles
mimalloc as rust stuff does.  *sigh*

IOW you can name it mimalloc, no need for version suffixes or anything
else.  If at any point you need an old mimalloc as well, you can add it
as mimalloc-1.6 or whatever.

Cheers
diff mbox series

Patch

From 29879ec9bd80f4f24a391b2222efc20a6ab2139a Mon Sep 17 00:00:00 2001
From: Kristian Lein-Mathisen <kristianlein@gmail.com>
Date: Tue, 23 Aug 2022 12:45:49 +0200
Subject: [PATCH] gnu: Add solvespace.

* gnu/packages/engineering.scm (solvespace): New variable.
---
 gnu/packages/engineering.scm | 120 +++++++++++++++++++++++++++++++++++
 1 file changed, 120 insertions(+)

diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index f195179413..68d0e55242 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -2895,6 +2895,126 @@  (define-public pcb2gcode
 dynamic calibration of the milling depth.")
      (license license:gpl3+))))
 
+;; There is another mimalloc, used in rust-mimalloc. But it's on mimalloc
+;; version 1.6.4. TODO: See if it's possible to re-use this package by both.
+(define mimalloc-for-solvespace
+  (let ((commit "f2712f4a8f038a7fb4df2790f4c3b7e3ed9e219b")
+        (version "2.0.6"))
+    (package
+      (name "mimalloc-for-solvespace")
+      (version (git-version version "1" commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/microsoft/mimalloc")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "05x2dl3zimflfj91ns3vrphmzpdlyyr230p9adqgfds101f16qmv"))))
+      (build-system cmake-build-system)
+      (arguments
+       `(#:build-type "Release"))
+      (synopsis "Compact general purpose allocator with excellent performance")
+      (description "@code{mimalloc} is a drop-in replacement for @code{malloc}
+and can be used in other programs without code changes, for example, on dynamically
+linked ELF-based systems (Linux, BSD, etc.) you can use it as:
+
+LD_PRELOAD=/usr/lib/libmimalloc.so myprogram
+
+Initially developed by Daan Leijen for the run-time systems of the Koka and
+Lean languages.")
+      (home-page "https://microsoft.github.io/mimalloc/")
+      (license license:expat))))
+
+
+(define-public solvespace
+  (let ((commit "70bde63cb32a7f049fa56cbdf924e2695fcb2916")
+        (version "3.1")
+        ;; libdxfrw has no readme, no version release, no tags.  Initial
+        ;; commit says "libdxfrw-0.6.3 import", but it shares no git history
+        ;; with "upstream" https://github.com/codelibs/libdxfrw.  Both are
+        ;; difficult to package separately as they don't install properly.
+        ;; Copying in-tree instead of #:recursive #t to avoid downloading the
+        ;; other bigger dependencies which aren't needed.
+        (libdxfrw-sources (origin
+                            (method git-fetch)
+                            (uri (git-reference (url
+                                                 "https://github.com/solvespace/libdxfrw")
+                                                (commit
+                                                 "0b7b7b709d9299565db603f878214656ef5e9ddf")))
+                            (sha256 (base32
+                                     "0d2wjq81466m3hb5cffiy99vhx0irwwy47yfxp318k2q4cvd5z2a")))))
+    (package
+      (name "solvespace")
+      (version (git-version version "1" commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/solvespace/solvespace")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1hbdln44k00a6vlklv2mq2c9zda3i9d5x0f7ks85w4v6zskhqnra"))))
+      (build-system cmake-build-system)
+      (native-inputs (list pkg-config gettext-minimal))
+      (arguments
+       (list #:build-type "Release"
+             #:phases #~(modify-phases %standard-phases
+                          (add-after 'unpack 'unpack-libdxfrw
+                            (lambda _
+                              (copy-recursively #$libdxfrw-sources
+                                                "extlib/libdxfrw")))
+                          (add-before 'configure 'embed-git-commit-hash
+                            (lambda _
+                              ;; `git describe` doesn't work here, so embed
+                              ;; the commit hash directly in CMakeLists.txt as
+                              ;; described instead.
+                              (substitute* "CMakeLists.txt"
+                                (("include\\(GetGitCommitHash\\)")
+                                 (string-append "set(GIT_COMMIT_HASH "
+                                                #$commit ")")))))
+                          (add-before 'configure 'use-packaged-mimalloc
+                            (lambda _
+                              (substitute* "CMakeLists.txt"
+                                (("message\\(STATUS \"Using in-tree mimalloc\"\\)")
+                                 "message(STATUS \"Using guix packaged mimalloc\")")
+                                (("add_subdirectory\\(extlib/mimalloc EXCLUDE_FROM_ALL\\)")
+                                 "find_package(mimalloc REQUIRED)")))))))
+      (inputs (list cairo
+                    eigen
+                    freetype
+                    gtkmm-3
+                    json-c
+                    libpng
+                    libspnav            ;spaceware
+                    mimalloc-for-solvespace
+                    mesa
+                    zlib))
+      (synopsis "Parametric 2D/3D CAD")
+      (description
+       "SOLVESPACE is a parametric 3D @acronym{CAD,
+Computer Aided Design} tool.  Applications include:
+
+@itemize
+@item modeling 3d parts — draw with extrudes, revolves, helixes and
+      Boolean (union / difference / intersection) operations
+@item modeling 2d parts — draw the part as a single section,
+      and export DXF, PDF, SVG; use 3d assembly to verify fit
+@item 3d-printed parts — export the STL or other triangle mesh
+      expected by most 3d printers
+@item preparing CAM data — export 2d vector art for a waterjet
+      machine or laser cutter; or generate STEP or STL, for import into
+      third-party CAM software for machining
+@item mechanism design — use the constraint solver to simulate planar
+      or spatial linkages, with pin, ball, or slide joints
+@item plane and solid geometry — replace hand-solved trigonometry and spreadsheets
+      with a live dimensioned drawing
+@end itemize")
+      (home-page "https://solvespace.com/")
+      (license license:gpl3+))))
+
 (define-public syscall-intercept
   ;; Upstream provides no tag. Also, last version update is 4 years old.
   (let ((commit "304404581c57d43478438d175099d20260bae74e")

base-commit: 7c47fa25134a2111e596e96198d02644aedae459
-- 
2.37.2