[bug#78233,v2,1/2] gnu: Add nextpnr.

Message ID 6ea46fd8ccc0a8aa56e03a9e2f320ac3de37c7a4.1746955119.git.csantosb@inventati.org
State New
Headers
Series [bug#78233,v2,1/2] gnu: Add nextpnr. |

Commit Message

Cayetano Santos May 11, 2025, 9:18 a.m. UTC
  * gnu/packages/fpga.scm (nextpnt): New variable.

Change-Id: Ic3476a6a4220ec20191897a6efb3d4aa347b51c2
---
 gnu/packages/fpga.scm | 79 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)


base-commit: 4fe484ee7e9d598a9d0a249c375b75a14b95d1b4
--
2.49.0
  

Patch

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 2298dde595..083faf7d7a 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -356,6 +356,85 @@  (define-public icestorm
 files.")
       (license license:isc))))
 
+(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))
+             ;; TODO: Package next packages, not yet in Guix.
+             ;; Required to get missing oourafft, json11, python-console and
+             ;; QtPropertyBrowser.
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (modules '((guix build utils)))
+       (snippet
+        ;; Remove bundled source code for which Guix has packages.
+        '(with-directory-excursion "3rdparty"
+           (for-each delete-file-recursively
+                     '("googletest" "imgui" "pybind11" "qtimgui"
+                       "sanitizers-cmake" "corrosion"))))
+       (sha256
+        (base32 "0p53a2gl89hf3hfwdxs6pykxyrk82j4lqpwd1fqia2y0c9r2gjlm"))))
+    (build-system qt-build-system)
+    (arguments
+     (list
+      #:cmake cmake-next                ;CMake 3.25 or higher is required.
+      #: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 references to unbundled code and link against external
+          ;; libraries instead.
+          (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"))
+                ;; Use the system googletest module
+                (("^\\s+add_subdirectory\\(3rdparty/googletest.*")
+                 "")
+                ;; Use the system corrosion module
+                (("^\\s+add_subdirectory\\(3rdparty/corrosion.*")
+                 "")
+                ;; replace gtest_main by gtest
+                (("^(\\s+target_link_libraries.*)( gtest_main)" _ prefix suffix)
+                 (string-append prefix " gtest")))
+              ;; Use the system imgui module
+              (substitute* "gui/CMakeLists.txt"
+                (("\\$\\{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
+                  corrosion
+                  eigen
+                  imgui
+                  pybind11
+                  python
+                  qtbase-5
+                  qtimgui
+                  qtwayland-5))
+    (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:asl2.0)))
+
 (define-public nextpnr-ice40
   (let* ((version "0.7")
          (tag (string-append "nextpnr-" version)))