GNU bug report logs - #77114
[PATCH] gnu: nextpnr: split devices.

Previous Next

Package: guix-patches;

Reported by: Cayetano Santos <csantosb <at> inventati.org>

Date: Wed, 19 Mar 2025 10:25:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 77114 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#77114; Package guix-patches. (Wed, 19 Mar 2025 10:25:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Cayetano Santos <csantosb <at> inventati.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 19 Mar 2025 10:25:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Cayetano Santos <csantosb <at> inventati.org>
To: guix-patches <at> gnu.org
Cc: Cayetano Santos <csantosb <at> inventati.org>
Subject: [PATCH] gnu: nextpnr: split devices.
Date: Wed, 19 Mar 2025 11:21:35 +0100
* gnu/packages/fpga.scm (nextpnr): split-devices.

Change-Id: I681dfa90a0ace3b507f3b56f3ac7d90227345606
---

- update package definitions to current guix standards
- prepare for new devices
 - split common package for all devices, from ice40 device package

 gnu/packages/fpga.scm | 183 ++++++++++++++++++++++--------------------
 1 file changed, 96 insertions(+), 87 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index c09fe9bc76..88a7a58aa2 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -313,102 +313,111 @@ (define-public icestorm
 Includes the actual FTDI connector.")
     (license license:isc))))
 
-(define-public nextpnr-ice40
-  (let* ((version "0.7")
-         (tag (string-append "nextpnr-" version)))
-    (package
-      (name "nextpnr-ice40")
-      (version version)
-      (source
-       (origin
-         (method git-fetch)
-         (uri (git-reference
-               (url "https://github.com/YosysHQ/nextpnr")
-               (commit tag)
-               (recursive? #t)))
-         (file-name (git-file-name name version))
-         (sha256
-          (base32
-           "0sbhqscgmlk4q2207rsqsw99qx4fyrxx1hsd669lrk42gmk3s9lm"))
-         (modules '((guix build utils)))
-         (snippet
-          #~(begin
-              ;; Remove bundled source code for which Guix has packages.
-              ;; Note the bundled copies of json11 and python-console contain
-              ;; modifications, while QtPropertyBrowser appears to be
-              ;; abandoned and without an official source.
-              ;; fpga-interchange-schema is used only by the
-              ;; "fpga_interchange" architecture target, which this package
-              ;; doesn't build.
+(define nextpnr
+  (package
+    (name "nextpnr")
+    (version "0.7")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/YosysHQ/nextpnr/")
+             (commit (string-append "nextpnr-" version))
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0sbhqscgmlk4q2207rsqsw99qx4fyrxx1hsd669lrk42gmk3s9lm"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list
+      #:out-of-source? #t
+      #:configure-flags
+      #~(list "-DBUILD_GUI=ON" "-DUSE_OPENMP=yes" "-DBUILD_TESTS=ON"
+              (string-append "-DCURRENT_GIT_VERSION=nextpnr-"
+                             #$version) "-DUSE_IPO=OFF")
+      #:phases
+      #~(modify-phases %standard-phases
+          ;; Remove bundled source code for which Guix has packages.
+          ;; Note the bundled copies of json11 and python-console contain
+          ;; modifications, while QtPropertyBrowser appears to be
+          ;; abandoned and without an official source.
+          ;; fpga-interchange-schema is used only by the
+          ;; "fpga_interchange" architecture target, which this package
+          ;; doesn't build.
+          (add-after 'unpack 'remove-deps
+            (lambda _
               (with-directory-excursion "3rdparty"
                 (for-each delete-file-recursively
                           '("googletest" "imgui" "pybind11" "qtimgui"
-                            "sanitizers-cmake")))
-
+                            "sanitizers-cmake" "corrosion")))))
+          (add-after 'remove-deps 'patch-source
+            (lambda* (#:key inputs #:allow-other-keys)
               ;; Remove references to unbundled code and link against external
               ;; libraries instead.
               (substitute* "CMakeLists.txt"
-                (("^\\s+add_subdirectory\\(3rdparty/googletest.*") "")
-                (("^(\\s+target_link_libraries.*)( gtest_main\\))"
-                  _ prefix suffix)
-                 (string-append prefix " gtest" suffix)))
+                ;; Use the system sanitizers-cmake module.
+                (("\\$\\{CMAKE_SOURCE_DIR\\}/3rdparty/sanitizers-cmake/cmake")
+                 (string-append #$(this-package-native-input
+                                   "sanitizers-cmake")
+                                "/share/sanitizers-cmake/cmake"))
+                ;; Use the system googletest module.
+                (("^\\s+add_subdirectory\\(3rdparty/googletest.*")
+                 "")
+                (("^(\\s+target_link_libraries.*)( gtest_main\\))" _ prefix
+                  suffix)
+                 (string-append prefix " gtest" suffix))
+                ;; Use the system corrosion module.
+                (("^\\s+add_subdirectory\\(3rdparty/corrosion.*")
+                 ""))
               (substitute* "gui/CMakeLists.txt"
-                (("^\\s+../3rdparty/(qt)?imgui.*") "")
+                ;; Compile with system imgui and qtimgui headers.
+                (("^(target_include_directories.*)../3rdparty/imgui(.*)$" _
+                  prefix suffix)
+                 (string-append prefix
+                                (search-input-directory inputs "include/imgui")
+                                suffix))
+                (("^(target_include_directories.*)../3rdparty/qtimgui/(.*)$" _
+                  prefix suffix)
+                 (string-append prefix
+                                (search-input-directory inputs
+                                                        "include/qtimgui")
+                                suffix)))
+              (substitute* "gui/CMakeLists.txt"
+                (("^\\s+../3rdparty/(qt)?imgui.*")
+                 "")
                 (("^(target_link_libraries.*)\\)" _ prefix)
-                 (string-append prefix " imgui qt_imgui_widgets)")))))))
-      (native-inputs
-       (list googletest sanitizers-cmake))
-      (inputs
-       (list boost
-             eigen
-             icestorm
-             imgui-1.86
-             pybind11
-             python
-             qtbase-5
-             qtwayland-5
-             qtimgui
-             yosys))
-      (build-system qt-build-system)
-      (arguments
-       (list
-        #:configure-flags
-        #~(list "-DARCH=ice40"
-                "-DBUILD_GUI=ON"
-                "-DBUILD_TESTS=ON"
-                (string-append "-DCURRENT_GIT_VERSION=" #$tag)
-                (string-append "-DICESTORM_INSTALL_PREFIX="
-                               #$(this-package-input "icestorm"))
-                "-DUSE_IPO=OFF")
-        #:phases
-        #~(modify-phases %standard-phases
-            (add-after 'unpack 'patch-source
-              (lambda* (#:key inputs #:allow-other-keys)
-                (substitute* "CMakeLists.txt"
-                  ;; Use the system sanitizers-cmake module.
-                  (("\\$\\{CMAKE_SOURCE_DIR\\}/3rdparty/sanitizers-cmake/cmake")
-                   (string-append
-                    #$(this-package-native-input "sanitizers-cmake")
-                    "/share/sanitizers-cmake/cmake")))
-                (substitute* "gui/CMakeLists.txt"
-                  ;; Compile with system imgui and qtimgui headers.
-                  (("^(target_include_directories.*)../3rdparty/imgui(.*)$"
-                    _ prefix suffix)
-                   (string-append prefix
-                                  (search-input-directory inputs
-                                                          "include/imgui")
-                                  suffix))
-                  (("^(target_include_directories.*)../3rdparty/qtimgui/(.*)$"
-                    _ prefix suffix)
-                   (string-append prefix
-                                  (search-input-directory inputs
-                                                          "include/qtimgui")
-                                  suffix))))))))
-      (synopsis "Place-and-Route tool for FPGAs")
-      (description "Nextpnr aims to be a vendor neutral, timing driven, FOSS
+                 (string-append prefix " imgui qt_imgui_widgets)"))))))))
+    (native-inputs (list googletest sanitizers-cmake))
+    (inputs (list boost
+                  eigen
+                  corrosion
+                  imgui
+                  pybind11
+                  python
+                  qtbase-5
+                  qtwayland-5
+                  qtimgui
+                  yosys))
+    (synopsis "Place-and-Route tool for FPGAs")
+    (description "Nextpnr aims to be a vendor neutral, timing driven, FOSS
 FPGA place and route tool.")
-      (home-page "https://github.com/YosysHQ/nextpnr")
-      (license license:expat))))
+    (home-page "https://github.com/YosysHQ/nextpnr/")
+    (license license:isc)))
+
+(define-public nextpnr-ice40
+  (package
+    (inherit nextpnr)
+    (name "nextpnr-ice40")
+    (arguments
+     (substitute-keyword-arguments (package-arguments nextpnr)
+       ((#:configure-flags flags
+         ''())
+        #~(cons "-DARCH=ice40"
+                (cons (string-append "-DICESTORM_INSTALL_PREFIX="
+                                     #$(this-package-input "icestorm"))
+                      #$flags)))))
+    (propagated-inputs (modify-inputs (package-propagated-inputs nextpnr)
+                         (prepend icestorm)))))
 
 (define-public gtkwave
   (package

base-commit: fd19785a9a7f111c6a97da25187c3351e7e8f3fd
--
2.48.1





Information forwarded to guix-patches <at> gnu.org:
bug#77114; Package guix-patches. (Tue, 25 Mar 2025 20:47:01 GMT) Full text and rfc822 format available.

Message #8 received at 77114 <at> debbugs.gnu.org (full text, mbox):

From: Cayetano Santos <csantosb <at> inventati.org>
To: 77114 <at> debbugs.gnu.org
Cc: Cayetano Santos <csantosb <at> inventati.org>
Subject: [PATCH v1] gnu: nextpnr: split devices.
Date: Tue, 25 Mar 2025 21:45:05 +0100
* gnu/packages/fpga.scm (nextpnr): split-devices.

Change-Id: I681dfa90a0ace3b507f3b56f3ac7d90227345606
---

- splits the package in 2, a common one plus a device package
- update to 0.8

 gnu/packages/fpga.scm | 181 +++++++++++++++++++++---------------------
 1 file changed, 90 insertions(+), 91 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 28ddfb42d4..cb14d96ea3 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -313,102 +313,101 @@ (define-public icestorm
 Includes the actual FTDI connector.")
     (license license:isc))))
 
-(define-public nextpnr-ice40
-  (let* ((version "0.7")
-         (tag (string-append "nextpnr-" version)))
-    (package
-      (name "nextpnr-ice40")
-      (version version)
-      (source
-       (origin
-         (method git-fetch)
-         (uri (git-reference
-               (url "https://github.com/YosysHQ/nextpnr")
-               (commit tag)
-               (recursive? #t)))
-         (file-name (git-file-name name version))
-         (sha256
-          (base32
-           "0sbhqscgmlk4q2207rsqsw99qx4fyrxx1hsd669lrk42gmk3s9lm"))
-         (modules '((guix build utils)))
-         (snippet
-          #~(begin
-              ;; Remove bundled source code for which Guix has packages.
-              ;; Note the bundled copies of json11 and python-console contain
-              ;; modifications, while QtPropertyBrowser appears to be
-              ;; abandoned and without an official source.
-              ;; fpga-interchange-schema is used only by the
-              ;; "fpga_interchange" architecture target, which this package
-              ;; doesn't build.
+
+(define nextpnr
+  (package
+    (name "nextpnr")
+    (version "0.8")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/YosysHQ/nextpnr/")
+             (commit (string-append "nextpnr-" version))
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0p53a2gl89hf3hfwdxs6pykxyrk82j4lqpwd1fqia2y0c9r2gjlm"))))
+    (build-system qt-build-system)
+    (arguments
+     (list
+      #:cmake cmake
+      #:out-of-source? #t
+      #:configure-flags
+      #~(list "-DBUILD_GUI=OFF"
+              "-DUSE_OPENMP=yes"
+              "-DBUILD_TESTS=ON"
+              (string-append "-DCURRENT_GIT_VERSION=nextpnr-" #$version)
+              "-DUSE_IPO=OFF")
+      #:phases
+      #~(modify-phases %standard-phases
+          ;; Remove bundled source code for which Guix has packages.
+          ;; Note the bundled copies of json11 and python-console contain
+          ;; modifications, while QtPropertyBrowser appears to be
+          ;; abandoned and without an official source.
+          ;; fpga-interchange-schema is used only by the
+          ;; "fpga_interchange" architecture target, which this package
+          ;; doesn't build.
+          (add-after 'unpack 'remove-deps
+            (lambda _
               (with-directory-excursion "3rdparty"
                 (for-each delete-file-recursively
                           '("googletest" "imgui" "pybind11" "qtimgui"
-                            "sanitizers-cmake")))
-
-              ;; Remove references to unbundled code and link against external
-              ;; libraries instead.
+                            "sanitizers-cmake" "corrosion")))))
+          ;; Remove references to unbundled code and link against external
+          ;; libraries instead.
+          (add-after 'remove-deps 'patch-source
+            (lambda* (#:key inputs #:allow-other-keys)
               (substitute* "CMakeLists.txt"
-                (("^\\s+add_subdirectory\\(3rdparty/googletest.*") "")
-                (("^(\\s+target_link_libraries.*)( gtest_main\\))"
-                  _ prefix suffix)
-                 (string-append prefix " gtest" suffix)))
+                ;; Use the system sanitizers-cmake module.
+                (("\\$\\{CMAKE_SOURCE_DIR\\}/3rdparty/sanitizers-cmake/cmake")
+                 (string-append #$(this-package-native-input "sanitizers-cmake")
+                                "/share/sanitizers-cmake/cmake"))
+                ;; Use the system googletest and corrosion modules
+                (("^\\s+add_subdirectory\\(3rdparty/googletest.*")
+                 "")
+                (("^\\s+add_subdirectory\\(3rdparty/corrosion.*")
+                 "")
+                ;; replace gtest_main by gtest
+                (("^(\\s+target_link_libraries.*)( gtest_main)" _ prefix suffix)
+                 (string-append prefix " gtest")))
+              ;; gui
               (substitute* "gui/CMakeLists.txt"
-                (("^\\s+../3rdparty/(qt)?imgui.*") "")
-                (("^(target_link_libraries.*)\\)" _ prefix)
-                 (string-append prefix " imgui qt_imgui_widgets)")))))))
-      (native-inputs
-       (list googletest sanitizers-cmake))
-      (inputs
-       (list boost
-             eigen
-             icestorm
-             imgui-1.86
-             pybind11
-             python
-             qtbase-5
-             qtwayland-5
-             qtimgui
-             yosys))
-      (build-system qt-build-system)
-      (arguments
-       (list
-        #:configure-flags
-        #~(list "-DARCH=ice40"
-                "-DBUILD_GUI=ON"
-                "-DBUILD_TESTS=ON"
-                (string-append "-DCURRENT_GIT_VERSION=" #$tag)
-                (string-append "-DICESTORM_INSTALL_PREFIX="
-                               #$(this-package-input "icestorm"))
-                "-DUSE_IPO=OFF")
-        #:phases
-        #~(modify-phases %standard-phases
-            (add-after 'unpack 'patch-source
-              (lambda* (#:key inputs #:allow-other-keys)
-                (substitute* "CMakeLists.txt"
-                  ;; Use the system sanitizers-cmake module.
-                  (("\\$\\{CMAKE_SOURCE_DIR\\}/3rdparty/sanitizers-cmake/cmake")
-                   (string-append
-                    #$(this-package-native-input "sanitizers-cmake")
-                    "/share/sanitizers-cmake/cmake")))
-                (substitute* "gui/CMakeLists.txt"
-                  ;; Compile with system imgui and qtimgui headers.
-                  (("^(target_include_directories.*)../3rdparty/imgui(.*)$"
-                    _ prefix suffix)
-                   (string-append prefix
-                                  (search-input-directory inputs
-                                                          "include/imgui")
-                                  suffix))
-                  (("^(target_include_directories.*)../3rdparty/qtimgui/(.*)$"
-                    _ prefix suffix)
-                   (string-append prefix
-                                  (search-input-directory inputs
-                                                          "include/qtimgui")
-                                  suffix))))))))
-      (synopsis "Place-and-Route tool for FPGAs")
-      (description "Nextpnr aims to be a vendor neutral, timing driven, FOSS
-FPGA place and route tool.")
-      (home-page "https://github.com/YosysHQ/nextpnr")
-      (license license:expat))))
+                (("\\$\\{CMAKE_SOURCE_DIR\\}(/3rdparty/imgui)")
+                 (string-append #$(this-package-input "imgui") "/include/imgui"))
+                (("\\$\\{CMAKE_SOURCE_DIR\\}(/3rdparty/qtimgui)")
+                 (string-append #$(this-package-input "qtimgui") "/include/qtimgui"))
+                (("^\\s+../3rdparty/(qt)?imgui.*")
+                 "")))))))
+    (native-inputs (list googletest sanitizers-cmake))
+    (inputs (list boost
+                  eigen
+                  corrosion
+                  imgui
+                  pybind11
+                  python
+                  qtbase-5
+                  qtwayland-5
+                  qtimgui))
+    (synopsis "Place-and-Route tool for FPGAs")
+    (description "Nextpnr is a portable FPGA place and route tool.")
+    (home-page "https://github.com/YosysHQ/nextpnr/")
+    (license license:isc)))
+
+(define-public nextpnr-ice40
+  (package
+    (inherit nextpnr)
+    (name "nextpnr-ice40")
+    (arguments
+     (substitute-keyword-arguments (package-arguments nextpnr)
+       ((#:configure-flags flags
+         ''())
+        #~(cons "-DARCH=ice40"
+                (cons (string-append "-DICESTORM_INSTALL_PREFIX="
+                                     #$(this-package-input "icestorm"))
+                      #$flags)))))
+    (propagated-inputs (modify-inputs (package-propagated-inputs nextpnr)
+                         (prepend icestorm)))))
 
 (define-public gtkwave
   (package

base-commit: 744cf07005745312ccddb549bb1bab5ab7031106
--
2.49.0





Information forwarded to guix-patches <at> gnu.org:
bug#77114; Package guix-patches. (Fri, 28 Mar 2025 09:49:03 GMT) Full text and rfc822 format available.

Message #11 received at 77114 <at> debbugs.gnu.org (full text, mbox):

From: Cayetano Santos <csantosb <at> inventati.org>
To: 77114 <at> debbugs.gnu.org
Cc: Cayetano Santos via Guix-patches via <guix-patches <at> gnu.org>
Subject: [PATCH v2] gnu: nextpnr: split devices.
Date: Fri, 28 Mar 2025 10:48:10 +0100
From: Cayetano Santos via Guix-patches via <guix-patches <at> gnu.org>

* gnu/packages/fpga.scm (nextpnr): split-devices.

Change-Id: I681dfa90a0ace3b507f3b56f3ac7d90227345606

Replace old nextpnr-ice40 by a common nextpnr package, plus a
device specific nextpnr-ice40 which inherits from it. Other device
packages will follow.

- compliant with #77067 (ice40 depends on icestorm)
- update to 0.8
- update substitutions in Makefiles
- addapt config and make flags to each package
- include tests from icestorm in nextpnr-ice40

Change-Id: Icbf9459347fefdcaaa43e7a6a5682eb0fb33ffe0
---
 gnu/packages/fpga.scm | 205 +++++++++++++++++++++++-------------------
 1 file changed, 115 insertions(+), 90 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 893e875276..20ee787e0f 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -313,102 +313,127 @@ (define-public icestorm
 Includes the actual FTDI connector.")
     (license license:isc))))
 
-(define-public nextpnr-ice40
-  (let* ((version "0.7")
-         (tag (string-append "nextpnr-" version)))
-    (package
-      (name "nextpnr-ice40")
-      (version version)
-      (source
-       (origin
-         (method git-fetch)
-         (uri (git-reference
-               (url "https://github.com/YosysHQ/nextpnr")
-               (commit tag)
-               (recursive? #t)))
-         (file-name (git-file-name name version))
-         (sha256
-          (base32
-           "0sbhqscgmlk4q2207rsqsw99qx4fyrxx1hsd669lrk42gmk3s9lm"))
-         (modules '((guix build utils)))
-         (snippet
-          #~(begin
-              ;; Remove bundled source code for which Guix has packages.
-              ;; Note the bundled copies of json11 and python-console contain
-              ;; modifications, while QtPropertyBrowser appears to be
-              ;; abandoned and without an official source.
-              ;; fpga-interchange-schema is used only by the
-              ;; "fpga_interchange" architecture target, which this package
-              ;; doesn't build.
+
+(define nextpnr
+  (package
+    (name "nextpnr")
+    (version "0.8")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/YosysHQ/nextpnr/")
+             (commit (string-append "nextpnr-" version))
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0p53a2gl89hf3hfwdxs6pykxyrk82j4lqpwd1fqia2y0c9r2gjlm"))))
+    (build-system qt-build-system)
+    (arguments
+     (list
+      #:cmake cmake
+      #:out-of-source? #t
+      #:configure-flags
+      #~(list "-DBUILD_GUI=OFF"
+              "-DUSE_OPENMP=yes"
+              "-DBUILD_TESTS=ON"
+              (string-append "-DCURRENT_GIT_VERSION=nextpnr-" #$version)
+              "-DUSE_IPO=OFF")
+      #:phases
+      #~(modify-phases %standard-phases
+          ;; Remove bundled source code for which Guix has packages.
+          ;; Note the bundled copies of json11 and python-console contain
+          ;; modifications, while QtPropertyBrowser appears to be
+          ;; abandoned and without an official source.
+          ;; fpga-interchange-schema is used only by the
+          ;; "fpga_interchange" architecture target, which this package
+          ;; doesn't build.
+          (add-after 'unpack 'remove-deps
+            (lambda _
               (with-directory-excursion "3rdparty"
                 (for-each delete-file-recursively
                           '("googletest" "imgui" "pybind11" "qtimgui"
-                            "sanitizers-cmake")))
-
-              ;; Remove references to unbundled code and link against external
-              ;; libraries instead.
+                            "sanitizers-cmake" "corrosion")))))
+          ;; Remove references to unbundled code and link against external
+          ;; libraries instead.
+          (add-after 'remove-deps 'patch-source
+            (lambda* (#:key inputs #:allow-other-keys)
               (substitute* "CMakeLists.txt"
-                (("^\\s+add_subdirectory\\(3rdparty/googletest.*") "")
-                (("^(\\s+target_link_libraries.*)( gtest_main\\))"
-                  _ prefix suffix)
-                 (string-append prefix " gtest" suffix)))
+                ;; Use the system sanitizers-cmake module.
+                (("\\$\\{CMAKE_SOURCE_DIR\\}/3rdparty/sanitizers-cmake/cmake")
+                 (string-append #$(this-package-native-input "sanitizers-cmake")
+                                "/share/sanitizers-cmake/cmake"))
+                ;; Use the system googletest and corrosion modules
+                (("^\\s+add_subdirectory\\(3rdparty/googletest.*")
+                 "")
+                (("^\\s+add_subdirectory\\(3rdparty/corrosion.*")
+                 "")
+                ;; replace gtest_main by gtest
+                (("^(\\s+target_link_libraries.*)( gtest_main)" _ prefix suffix)
+                 (string-append prefix " gtest")))
+              ;; gui
               (substitute* "gui/CMakeLists.txt"
-                (("^\\s+../3rdparty/(qt)?imgui.*") "")
-                (("^(target_link_libraries.*)\\)" _ prefix)
-                 (string-append prefix " imgui qt_imgui_widgets)")))))))
-      (native-inputs
-       (list googletest sanitizers-cmake))
-      (inputs
-       (list boost
-             eigen
-             icestorm
-             imgui-1.86
-             pybind11
-             python
-             qtbase-5
-             qtwayland-5
-             qtimgui
-             yosys))
-      (build-system qt-build-system)
-      (arguments
-       (list
-        #:configure-flags
-        #~(list "-DARCH=ice40"
-                "-DBUILD_GUI=ON"
-                "-DBUILD_TESTS=ON"
-                (string-append "-DCURRENT_GIT_VERSION=" #$tag)
-                (string-append "-DICESTORM_INSTALL_PREFIX="
-                               #$(this-package-input "icestorm"))
-                "-DUSE_IPO=OFF")
-        #:phases
-        #~(modify-phases %standard-phases
-            (add-after 'unpack 'patch-source
+                (("\\$\\{CMAKE_SOURCE_DIR\\}(/3rdparty/imgui)")
+                 (string-append #$(this-package-input "imgui") "/include/imgui"))
+                (("\\$\\{CMAKE_SOURCE_DIR\\}(/3rdparty/qtimgui)")
+                 (string-append #$(this-package-input "qtimgui") "/include/qtimgui"))
+                (("^\\s+../3rdparty/(qt)?imgui.*")
+                 "")))))))
+    (native-inputs (list googletest sanitizers-cmake))
+    (inputs (list boost
+                  eigen
+                  corrosion
+                  imgui
+                  pybind11
+                  python
+                  qtbase-5
+                  qtwayland-5
+                  qtimgui))
+    (synopsis "Place-and-Route tool for FPGAs")
+    (description "Nextpnr is a portable FPGA place and route tool.")
+    (home-page "https://github.com/YosysHQ/nextpnr/")
+    (license license:isc)))
+
+(define-public nextpnr-ice40
+  (package
+    (inherit nextpnr)
+    (name "nextpnr-ice40")
+    (arguments
+     (substitute-keyword-arguments (package-arguments nextpnr)
+       ;; tests
+       ((#:phases phases #~%standard-phases)
+        #~(modify-phases #$phases
+            ;; get icestorm/examples
+            (add-after 'compress-documentation 'get-icestorm
               (lambda* (#:key inputs #:allow-other-keys)
-                (substitute* "CMakeLists.txt"
-                  ;; Use the system sanitizers-cmake module.
-                  (("\\$\\{CMAKE_SOURCE_DIR\\}/3rdparty/sanitizers-cmake/cmake")
-                   (string-append
-                    #$(this-package-native-input "sanitizers-cmake")
-                    "/share/sanitizers-cmake/cmake")))
-                (substitute* "gui/CMakeLists.txt"
-                  ;; Compile with system imgui and qtimgui headers.
-                  (("^(target_include_directories.*)../3rdparty/imgui(.*)$"
-                    _ prefix suffix)
-                   (string-append prefix
-                                  (search-input-directory inputs
-                                                          "include/imgui")
-                                  suffix))
-                  (("^(target_include_directories.*)../3rdparty/qtimgui/(.*)$"
-                    _ prefix suffix)
-                   (string-append prefix
-                                  (search-input-directory inputs
-                                                          "include/qtimgui")
-                                  suffix))))))))
-      (synopsis "Place-and-Route tool for FPGAs")
-      (description "Nextpnr aims to be a vendor neutral, timing driven, FOSS
-FPGA place and route tool.")
-      (home-page "https://github.com/YosysHQ/nextpnr")
-      (license license:expat))))
+                (copy-recursively
+                 #$(origin (inherit (package-source icestorm)))
+                 "icestorm")))
+            ;; run all examples as tests
+            (add-after 'get-icestorm 'test
+              (lambda* _
+                (let ((dir (opendir "icestorm/examples")))
+                  (do ((entry (readdir dir)
+                              (readdir dir)))
+                      ((eof-object? entry))
+                    (when (not (member entry '("." "..")))
+                      (setenv "PATH"
+                              (string-append (string-append #$output "/bin")
+                                             ":"
+                                             (getenv "PATH")))
+                      (invoke "make" "-C"
+                              (string-append "icestorm/examples/" entry))))
+                  (closedir dir))))))
+       ((#:configure-flags original-flags #~(list))
+        #~(append #$original-flags
+                  `("-DARCH=ice40"
+                    ,(string-append "-DICESTORM_INSTALL_PREFIX="
+                                    #$(this-package-input "icestorm")))))))
+    (propagated-inputs (modify-inputs (package-propagated-inputs nextpnr)
+                         (prepend icestorm)))
+    ;; tests
+    (native-inputs (modify-inputs (package-native-inputs nextpnr)
+                     (prepend yosys)))))
 
 (define-public gtkwave
   (package

base-commit: 0b6d9901ec11c9365f9c77da21c2d0bf4e07c6d9
-- 
2.49.0





Information forwarded to guix-patches <at> gnu.org:
bug#77114; Package guix-patches. (Fri, 28 Mar 2025 09:57:02 GMT) Full text and rfc822 format available.

Message #14 received at 77114 <at> debbugs.gnu.org (full text, mbox):

From: Cayetano Santos <csantosb <at> inventati.org>
To: 77114 <at> debbugs.gnu.org
Cc: Cayetano Santos via Guix-patches via <guix-patches <at> gnu.org>
Subject: [PATCH v2] gnu: nextpnr: split devices.
Date: Fri, 28 Mar 2025 10:55:45 +0100
From: Cayetano Santos via Guix-patches via <guix-patches <at> gnu.org>

* gnu/packages/fpga.scm (nextpnr): split-devices.

Change-Id: I681dfa90a0ace3b507f3b56f3ac7d90227345606

Replace old nextpnr-ice40 by a common nextpnr package, plus a
device specific nextpnr-ice40 which inherits from it. Other device
packages will follow.

- compliant with #77067 (ice40 depends on icestorm)
- update to 0.8
- update substitutions in Makefiles
- addapt config and make flags to each package
- include tests from icestorm in nextpnr-ice40

Change-Id: Icbf9459347fefdcaaa43e7a6a5682eb0fb33ffe0
---
 gnu/packages/fpga.scm | 205 +++++++++++++++++++++++-------------------
 1 file changed, 115 insertions(+), 90 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 893e875276..20ee787e0f 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -313,102 +313,127 @@ (define-public icestorm
 Includes the actual FTDI connector.")
     (license license:isc))))
 
-(define-public nextpnr-ice40
-  (let* ((version "0.7")
-         (tag (string-append "nextpnr-" version)))
-    (package
-      (name "nextpnr-ice40")
-      (version version)
-      (source
-       (origin
-         (method git-fetch)
-         (uri (git-reference
-               (url "https://github.com/YosysHQ/nextpnr")
-               (commit tag)
-               (recursive? #t)))
-         (file-name (git-file-name name version))
-         (sha256
-          (base32
-           "0sbhqscgmlk4q2207rsqsw99qx4fyrxx1hsd669lrk42gmk3s9lm"))
-         (modules '((guix build utils)))
-         (snippet
-          #~(begin
-              ;; Remove bundled source code for which Guix has packages.
-              ;; Note the bundled copies of json11 and python-console contain
-              ;; modifications, while QtPropertyBrowser appears to be
-              ;; abandoned and without an official source.
-              ;; fpga-interchange-schema is used only by the
-              ;; "fpga_interchange" architecture target, which this package
-              ;; doesn't build.
+
+(define nextpnr
+  (package
+    (name "nextpnr")
+    (version "0.8")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/YosysHQ/nextpnr/")
+             (commit (string-append "nextpnr-" version))
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0p53a2gl89hf3hfwdxs6pykxyrk82j4lqpwd1fqia2y0c9r2gjlm"))))
+    (build-system qt-build-system)
+    (arguments
+     (list
+      #:cmake cmake
+      #:out-of-source? #t
+      #:configure-flags
+      #~(list "-DBUILD_GUI=OFF"
+              "-DUSE_OPENMP=yes"
+              "-DBUILD_TESTS=ON"
+              (string-append "-DCURRENT_GIT_VERSION=nextpnr-" #$version)
+              "-DUSE_IPO=OFF")
+      #:phases
+      #~(modify-phases %standard-phases
+          ;; Remove bundled source code for which Guix has packages.
+          ;; Note the bundled copies of json11 and python-console contain
+          ;; modifications, while QtPropertyBrowser appears to be
+          ;; abandoned and without an official source.
+          ;; fpga-interchange-schema is used only by the
+          ;; "fpga_interchange" architecture target, which this package
+          ;; doesn't build.
+          (add-after 'unpack 'remove-deps
+            (lambda _
               (with-directory-excursion "3rdparty"
                 (for-each delete-file-recursively
                           '("googletest" "imgui" "pybind11" "qtimgui"
-                            "sanitizers-cmake")))
-
-              ;; Remove references to unbundled code and link against external
-              ;; libraries instead.
+                            "sanitizers-cmake" "corrosion")))))
+          ;; Remove references to unbundled code and link against external
+          ;; libraries instead.
+          (add-after 'remove-deps 'patch-source
+            (lambda* (#:key inputs #:allow-other-keys)
               (substitute* "CMakeLists.txt"
-                (("^\\s+add_subdirectory\\(3rdparty/googletest.*") "")
-                (("^(\\s+target_link_libraries.*)( gtest_main\\))"
-                  _ prefix suffix)
-                 (string-append prefix " gtest" suffix)))
+                ;; Use the system sanitizers-cmake module.
+                (("\\$\\{CMAKE_SOURCE_DIR\\}/3rdparty/sanitizers-cmake/cmake")
+                 (string-append #$(this-package-native-input "sanitizers-cmake")
+                                "/share/sanitizers-cmake/cmake"))
+                ;; Use the system googletest and corrosion modules
+                (("^\\s+add_subdirectory\\(3rdparty/googletest.*")
+                 "")
+                (("^\\s+add_subdirectory\\(3rdparty/corrosion.*")
+                 "")
+                ;; replace gtest_main by gtest
+                (("^(\\s+target_link_libraries.*)( gtest_main)" _ prefix suffix)
+                 (string-append prefix " gtest")))
+              ;; gui
               (substitute* "gui/CMakeLists.txt"
-                (("^\\s+../3rdparty/(qt)?imgui.*") "")
-                (("^(target_link_libraries.*)\\)" _ prefix)
-                 (string-append prefix " imgui qt_imgui_widgets)")))))))
-      (native-inputs
-       (list googletest sanitizers-cmake))
-      (inputs
-       (list boost
-             eigen
-             icestorm
-             imgui-1.86
-             pybind11
-             python
-             qtbase-5
-             qtwayland-5
-             qtimgui
-             yosys))
-      (build-system qt-build-system)
-      (arguments
-       (list
-        #:configure-flags
-        #~(list "-DARCH=ice40"
-                "-DBUILD_GUI=ON"
-                "-DBUILD_TESTS=ON"
-                (string-append "-DCURRENT_GIT_VERSION=" #$tag)
-                (string-append "-DICESTORM_INSTALL_PREFIX="
-                               #$(this-package-input "icestorm"))
-                "-DUSE_IPO=OFF")
-        #:phases
-        #~(modify-phases %standard-phases
-            (add-after 'unpack 'patch-source
+                (("\\$\\{CMAKE_SOURCE_DIR\\}(/3rdparty/imgui)")
+                 (string-append #$(this-package-input "imgui") "/include/imgui"))
+                (("\\$\\{CMAKE_SOURCE_DIR\\}(/3rdparty/qtimgui)")
+                 (string-append #$(this-package-input "qtimgui") "/include/qtimgui"))
+                (("^\\s+../3rdparty/(qt)?imgui.*")
+                 "")))))))
+    (native-inputs (list googletest sanitizers-cmake))
+    (inputs (list boost
+                  eigen
+                  corrosion
+                  imgui
+                  pybind11
+                  python
+                  qtbase-5
+                  qtwayland-5
+                  qtimgui))
+    (synopsis "Place-and-Route tool for FPGAs")
+    (description "Nextpnr is a portable FPGA place and route tool.")
+    (home-page "https://github.com/YosysHQ/nextpnr/")
+    (license license:isc)))
+
+(define-public nextpnr-ice40
+  (package
+    (inherit nextpnr)
+    (name "nextpnr-ice40")
+    (arguments
+     (substitute-keyword-arguments (package-arguments nextpnr)
+       ;; tests
+       ((#:phases phases #~%standard-phases)
+        #~(modify-phases #$phases
+            ;; get icestorm/examples
+            (add-after 'compress-documentation 'get-icestorm
               (lambda* (#:key inputs #:allow-other-keys)
-                (substitute* "CMakeLists.txt"
-                  ;; Use the system sanitizers-cmake module.
-                  (("\\$\\{CMAKE_SOURCE_DIR\\}/3rdparty/sanitizers-cmake/cmake")
-                   (string-append
-                    #$(this-package-native-input "sanitizers-cmake")
-                    "/share/sanitizers-cmake/cmake")))
-                (substitute* "gui/CMakeLists.txt"
-                  ;; Compile with system imgui and qtimgui headers.
-                  (("^(target_include_directories.*)../3rdparty/imgui(.*)$"
-                    _ prefix suffix)
-                   (string-append prefix
-                                  (search-input-directory inputs
-                                                          "include/imgui")
-                                  suffix))
-                  (("^(target_include_directories.*)../3rdparty/qtimgui/(.*)$"
-                    _ prefix suffix)
-                   (string-append prefix
-                                  (search-input-directory inputs
-                                                          "include/qtimgui")
-                                  suffix))))))))
-      (synopsis "Place-and-Route tool for FPGAs")
-      (description "Nextpnr aims to be a vendor neutral, timing driven, FOSS
-FPGA place and route tool.")
-      (home-page "https://github.com/YosysHQ/nextpnr")
-      (license license:expat))))
+                (copy-recursively
+                 #$(origin (inherit (package-source icestorm)))
+                 "icestorm")))
+            ;; run all examples as tests
+            (add-after 'get-icestorm 'test
+              (lambda* _
+                (let ((dir (opendir "icestorm/examples")))
+                  (do ((entry (readdir dir)
+                              (readdir dir)))
+                      ((eof-object? entry))
+                    (when (not (member entry '("." "..")))
+                      (setenv "PATH"
+                              (string-append (string-append #$output "/bin")
+                                             ":"
+                                             (getenv "PATH")))
+                      (invoke "make" "-C"
+                              (string-append "icestorm/examples/" entry))))
+                  (closedir dir))))))
+       ((#:configure-flags original-flags #~(list))
+        #~(append #$original-flags
+                  `("-DARCH=ice40"
+                    ,(string-append "-DICESTORM_INSTALL_PREFIX="
+                                    #$(this-package-input "icestorm")))))))
+    (propagated-inputs (modify-inputs (package-propagated-inputs nextpnr)
+                         (prepend icestorm)))
+    ;; tests
+    (native-inputs (modify-inputs (package-native-inputs nextpnr)
+                     (prepend yosys)))))
 
 (define-public gtkwave
   (package

base-commit: 0b6d9901ec11c9365f9c77da21c2d0bf4e07c6d9
-- 
2.49.0





This bug report was last modified 11 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.