1
Fork 0
mirror of https://https.git.savannah.gnu.org/git/guix.git/ synced 2025-07-13 18:40:57 +02:00

gnu: nextpnr-ice40: Update to 0.8.

* gnu/packages/fpga.scm (nextpnr-ice40): Update to 0.8.
[snippet]: Use 'delete-all-but' defensive idiom and update comment.
[patches]: Apply unbundling patches.
[arguments] <:cmake>: New argument.
<#:configure-flags>: Add -DUSE_OPENMP=ON flag.  Adjust version string used with
-DCURRENT_GIT_VERSION.
<#:phases> {patch-source}: Streamline phase.
[inputs]: Remove imgui-1.86, which is now propagated by qtimgui.
[home-page]: Add trailing '/'.
[description]: Streamline description.  'FOSS' is implied by being part of the
Guix packages collection.
[license]: Correct to ISC license.
* gnu/packages/patches/nextpnr-gtest.patch: New file.
* gnu/packages/patches/nextpnr-imgui.patch: Likewise.
* gnu/local.mk (dist_patch_DATA): Register them.

Co-authored-by: Cayetano Santos <csantosb@inventati.org>
Change-Id: Ied1178c26ed0ba96021a3d5961441c23f0ac508e
This commit is contained in:
Maxim Cournoyer 2025-05-12 14:52:19 +09:00
parent e8525e84ce
commit 221899c202
No known key found for this signature in database
GPG key ID: 1260E46482E63562
4 changed files with 192 additions and 94 deletions

View file

@ -1905,6 +1905,8 @@ dist_patch_DATA = \
%D%/packages/patches/netsurf-system-utf8proc.patch \ %D%/packages/patches/netsurf-system-utf8proc.patch \
%D%/packages/patches/netsurf-y2038-tests.patch \ %D%/packages/patches/netsurf-y2038-tests.patch \
%D%/packages/patches/netsurf-longer-test-timeout.patch \ %D%/packages/patches/netsurf-longer-test-timeout.patch \
%D%/packages/patches/nextpnr-gtest.patch \
%D%/packages/patches/nextpnr-imgui.patch \
%D%/packages/patches/nhc98-c-update.patch \ %D%/packages/patches/nhc98-c-update.patch \
%D%/packages/patches/nix-dont-build-html-doc.diff \ %D%/packages/patches/nix-dont-build-html-doc.diff \
%D%/packages/patches/nfs4-acl-tools-0.3.7-fixpaths.patch \ %D%/packages/patches/nfs4-acl-tools-0.3.7-fixpaths.patch \

View file

@ -357,101 +357,92 @@ files.")
(license license:isc)))) (license license:isc))))
(define-public nextpnr-ice40 (define-public nextpnr-ice40
(let* ((version "0.7") (package
(tag (string-append "nextpnr-" version))) (name "nextpnr-ice40")
(package (version "0.8")
(name "nextpnr-ice40") (source
(version version) (origin
(source (method git-fetch)
(origin (uri (git-reference
(method git-fetch) (url "https://github.com/YosysHQ/nextpnr/")
(uri (git-reference (commit (string-append "nextpnr-" version))
(url "https://github.com/YosysHQ/nextpnr") ;; XXX: Fetch some bundled libraries such as QtPropertyBrowser,
(commit tag) ;; json11 and python-console, which have custom modifications or
(recursive? #t))) ;; no longer have their original upstream.
(file-name (git-file-name name version)) (recursive? #t)))
(sha256 (file-name (git-file-name name version))
(base32 (modules '((guix build utils)
"0sbhqscgmlk4q2207rsqsw99qx4fyrxx1hsd669lrk42gmk3s9lm")) (ice-9 ftw)
(modules '((guix build utils))) (srfi srfi-26)))
(snippet (snippet
#~(begin '(begin
;; Remove bundled source code for which Guix has packages. ;; XXX: 'delete-all-but' is copied from the turbovnc package.
;; Note the bundled copies of json11 and python-console contain (define (delete-all-but directory . preserve)
;; modifications, while QtPropertyBrowser appears to be (define (directory? x)
;; abandoned and without an official source. (and=> (stat x #f)
;; fpga-interchange-schema is used only by the (compose (cut eq? 'directory <>) stat:type)))
;; "fpga_interchange" architecture target, which this package (with-directory-excursion directory
;; doesn't build. (let* ((pred
(with-directory-excursion "3rdparty" (negate (cut member <> (append '("." "..") preserve))))
(for-each delete-file-recursively (items (scandir "." pred)))
'("googletest" "imgui" "pybind11" "qtimgui" (for-each (lambda (item)
"sanitizers-cmake"))) (if (directory? item)
(delete-file-recursively item)
;; Remove references to unbundled code and link against external (delete-file item)))
;; libraries instead. items))))
(delete-all-but "3rdparty"
;; The following sources have all been patched, so
;; cannot easily be unbundled.
"QtPropertyBrowser"
"json11"
"python-console"
"oourafft")))
(patches (search-patches "nextpnr-gtest.patch"
"nextpnr-imgui.patch"))
(sha256
(base32 "0p53a2gl89hf3hfwdxs6pykxyrk82j4lqpwd1fqia2y0c9r2gjlm"))))
(build-system qt-build-system)
(arguments
(list
#:cmake cmake ;CMake 3.25 or higher is required.
#:configure-flags
#~(list "-DARCH=ice40"
"-DBUILD_GUI=ON"
"-DUSE_OPENMP=ON"
"-DBUILD_TESTS=ON"
(string-append "-DCURRENT_GIT_VERSION=nextpnr-" #$version)
(string-append "-DICESTORM_INSTALL_PREFIX="
#$(this-package-input "icestorm"))
"-DUSE_IPO=OFF")
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'unbundle-sanitizers-cmake
(lambda* (#:key inputs #:allow-other-keys)
(substitute* "CMakeLists.txt" (substitute* "CMakeLists.txt"
(("^\\s+add_subdirectory\\(3rdparty/googletest.*") "") ;; Use the system sanitizers-cmake module. This is made
(("^(\\s+target_link_libraries.*)( gtest_main\\))" ;; necessary 'sanitizers-cmake' installing a FindPackage
_ prefix suffix) ;; module but no CMake config file.
(string-append prefix " gtest" suffix))) (("\\$\\{CMAKE_SOURCE_DIR}/3rdparty/sanitizers-cmake/cmake")
(substitute* "gui/CMakeLists.txt" (string-append
(("^\\s+../3rdparty/(qt)?imgui.*") "") #$(this-package-native-input "sanitizers-cmake")
(("^(target_link_libraries.*)\\)" _ prefix) "/share/sanitizers-cmake/cmake"))))))))
(string-append prefix " imgui qt_imgui_widgets)"))))))) (native-inputs
(native-inputs (list googletest
(list googletest sanitizers-cmake)) sanitizers-cmake))
(inputs (inputs
(list boost (list boost
eigen eigen
icestorm icestorm
imgui-1.86 pybind11
pybind11 python
python qtbase-5
qtbase-5 qtwayland-5
qtwayland-5 qtimgui
qtimgui yosys))
yosys)) (synopsis "Place-and-Route tool for FPGAs")
(build-system qt-build-system) (description "Nextpnr is a portable FPGA place and route tool.")
(arguments (home-page "https://github.com/YosysHQ/nextpnr/")
(list (license license:isc)))
#: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))))
(define-public gtkwave (define-public gtkwave
(package (package

View file

@ -0,0 +1,30 @@
Upstream-status: https://github.com/YosysHQ/nextpnr/pull/1478
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 47d60330..88463984 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -217,7 +217,13 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/3rdparty/sanitizers-cmake/cmake" ${CM
find_package(Sanitizers)
if (BUILD_TESTS)
- add_subdirectory(3rdparty/googletest/googletest EXCLUDE_FROM_ALL)
+ find_package(GTest)
+ if(GTest_FOUND)
+ add_library(gtest_main ALIAS GTest::gtest_main)
+ else()
+ add_subdirectory(3rdparty/googletest/googletest EXCLUDE_FROM_ALL)
+ set(gtest_include_dir ${CMAKE_SOURCE_DIR}/3rdparty/googletest/googletest/include)
+ endif()
enable_testing()
endif()
@@ -366,7 +372,7 @@ function(add_nextpnr_architecture target)
add_executable(nextpnr-${target}-test ${arg_TEST_SOURCES})
set_property(TARGET nextpnr-${target}-test PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
- target_include_directories(nextpnr-${target}-test PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/googletest/googletest/include)
+ target_include_directories(nextpnr-${target}-test PRIVATE gtest_include_dir)
target_link_libraries(nextpnr-${target}-test PRIVATE gtest_main nextpnr-${target}-core)
if (BUILD_GUI)

View file

@ -0,0 +1,75 @@
Uptream-status: https://github.com/YosysHQ/nextpnr/pull/1480
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index ff5d9208..c554cc96 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -46,12 +46,42 @@ target_include_directories(nextpnr-${target}-gui PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
+# Detect whether imgui/qtimgui packages are available from the system.
+find_path(IMGUI_INCLUDE_DIR NAMES imgui.h PATH_SUFFIXES imgui)
+find_path(QTIMGUI_INCLUDE_DIR NAMES QtImGui.h PATH_SUFFIXES qtimgui)
+find_library(IMGUI_LIB NAMES imgui)
+find_library(QTIMGUI_LIB NAMES qt_imgui_widgets)
+if (IMGUI_INCLUDE_DIR AND IMGUI_LIB)
+ message("Using system imgui library:
+ IMGUI_INCLUDE_DIR=${IMGUI_INCLUDE_DIR}
+ IMGUI_LIB=${IMGUI_LIB}")
+else()
+ message("Using bundled imgui library")
+ set(IMGUI_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/imgui)
+ set(IMGUI_SOURCES
+ ../3rdparty/imgui/imgui_widgets.cpp
+ ../3rdparty/imgui/imgui_draw.cpp
+ ../3rdparty/imgui/imgui.cpp
+ ../3rdparty/imgui/imgui_demo.cpp)
+endif()
+if (QTIMGUI_INCLUDE_DIR AND QTIMGUI_LIB)
+ message("Using system qtimgui library:
+ QTIMGUI_INCLUDE_DIR=${QTIMGUI_INCLUDE_DIR}
+ QTIMGUI_LIB=${QTIMGUI_LIB}")
+else()
+ message("Using bundled qtimgui library")
+ set(QTIMGUI_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/qtimgui)
+ set(QTIMGUI_SOURCES
+ ../3rdparty/qtimgui/ImGuiRenderer.cpp
+ ../3rdparty/qtimgui/QtImGui.cpp)
+endif()
+
target_include_directories(nextpnr-${target}-gui PRIVATE
${CMAKE_SOURCE_DIR}/frontend
${CMAKE_SOURCE_DIR}/json
${CMAKE_SOURCE_DIR}/3rdparty/QtPropertyBrowser/src
- ${CMAKE_SOURCE_DIR}/3rdparty/imgui
- ${CMAKE_SOURCE_DIR}/3rdparty/qtimgui
+ ${IMGUI_INCLUDE_DIR}
+ ${QTIMGUI_INCLUDE_DIR}
)
target_link_libraries(nextpnr-${target}-gui PUBLIC
@@ -77,14 +107,17 @@ if (BUILD_PYTHON)
../3rdparty/python-console/ParseMessage.cpp
../3rdparty/python-console/modified/pyredirector.cc
../3rdparty/python-console/modified/pyinterpreter.cc
- ../3rdparty/imgui/imgui_widgets.cpp
- ../3rdparty/imgui/imgui_draw.cpp
- ../3rdparty/imgui/imgui.cpp
- ../3rdparty/imgui/imgui_demo.cpp
- ../3rdparty/qtimgui/ImGuiRenderer.cpp
- ../3rdparty/qtimgui/QtImGui.cpp
+ ${IMGUI_SOURCES}
+ ${QTIMGUI_SOURCES}
)
+ if (IMGUI_LIB)
+ target_link_libraries(nextpnr-${target}-gui PRIVATE ${IMGUI_LIB})
+ endif()
+ if (QTIMGUI_LIB)
+ target_link_libraries(nextpnr-${target}-gui PRIVATE ${QTIMGUI_LIB})
+ endif()
+
target_include_directories(nextpnr-${target}-gui PRIVATE
../3rdparty/python-console
../3rdparty/python-console/modified