dannym pushed a commit to branch master
in repository guix.

commit 58ca09f5544e0f3b8b9fd9ddeff1d2cca3436402
Author: Simon South <[email protected]>
AuthorDate: Fri Jan 27 15:34:33 2023 -0500

    gnu: nextpnr-ice40: Remove bundled software.
    
    * gnu/packages/fpga.scm (nextpnr-ice40)[source]: Add modules, snippet.
    [native-inputs]: Add googletest, sanitizers-cmake.
    [inputs]: Add imgui-1.86, pybind11, qtimgui.
    [arguments]: Add "patch-source" phase; reformat gently.
    
    Signed-off-by: Danny Milosavljevic <[email protected]>
    Change-Id: I1d291ef8356b1cb32f612a055c37654e5c0aba9d
    Signed-off-by: Danny Milosavljevic <[email protected]>
---
 gnu/packages/fpga.scm | 73 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 64 insertions(+), 9 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 8076c0fa44..8647d7feff 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2021 Andrew Miloradovsky <[email protected]>
 ;;; Copyright © 2022 Christian Gelinek <[email protected]>
 ;;; Copyright © 2022 jgart <[email protected]>
+;;; Copyright © 2023 Simon South <[email protected]>
 ;;; Copyright © 2024 Efraim Flashner <[email protected]>
 ;;; Copyright © 2024 Jakob Kirsch <[email protected]>
 ;;;
@@ -69,6 +70,7 @@
   #:use-module (gnu packages qt)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages tcl)
+  #:use-module (gnu packages toolkits)
   #:use-module (gnu packages version-control))
 
 (define-public abc
@@ -298,24 +300,77 @@ Includes the actual FTDI connector.")
           (file-name (git-file-name name version))
           (sha256
            (base32
-            "1llkrh8rk1a1xxzx54apbg49ny2jqzzl2rmbkb8188idipq568ws"))))
+            "1llkrh8rk1a1xxzx54apbg49ny2jqzzl2rmbkb8188idipq568ws"))
+          (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.
+               (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.
+               (substitute* "CMakeLists.txt"
+                 (("^\\s+add_subdirectory\\(3rdparty/googletest.*") "")
+                 (("^(\\s+target_link_libraries.*)( gtest_main\\))"
+                   _ prefix suffix)
+                  (string-append prefix " gtest" 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
+             qtimgui
              yosys))
       (build-system cmake-build-system)
       (arguments
-       (list #:configure-flags
-             #~(list "-DARCH=ice40"
-                     "-DBUILD_TESTS=ON"
-                     (string-append "-DCURRENT_GIT_VERSION="
-                                    #$(string-take commit 8))
-                     (string-append "-DICEBOX_ROOT="
-                                    #$(this-package-input "icestorm")
-                                    "/share/icebox"))))
+       (list
+        #:configure-flags
+        #~(list "-DARCH=ice40"
+                "-DBUILD_TESTS=ON"
+                (string-append "-DCURRENT_GIT_VERSION="
+                               #$(string-take commit 8))
+                (string-append "-DICEBOX_ROOT="
+                               #$(this-package-input "icestorm")
+                               "/share/icebox"))
+        #: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.")

Reply via email to