1
Fork 0
mirror of https://https.git.savannah.gnu.org/git/guix.git/ synced 2025-07-13 02:20:53 +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-y2038-tests.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/nix-dont-build-html-doc.diff \
%D%/packages/patches/nfs4-acl-tools-0.3.7-fixpaths.patch \

View file

@ -357,101 +357,92 @@ files.")
(license license:isc))))
(define-public nextpnr-ice40
(let* ((version "0.7")
(tag (string-append "nextpnr-" version)))
(package
(name "nextpnr-ice40")
(version version)
(version "0.8")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/YosysHQ/nextpnr")
(commit tag)
(url "https://github.com/YosysHQ/nextpnr/")
(commit (string-append "nextpnr-" version))
;; XXX: Fetch some bundled libraries such as QtPropertyBrowser,
;; json11 and python-console, which have custom modifications or
;; no longer have their original upstream.
(recursive? #t)))
(file-name (git-file-name name version))
(sha256
(base32
"0sbhqscgmlk4q2207rsqsw99qx4fyrxx1hsd669lrk42gmk3s9lm"))
(modules '((guix build utils)))
(modules '((guix build utils)
(ice-9 ftw)
(srfi srfi-26)))
(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.
(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.
'(begin
;; XXX: 'delete-all-but' is copied from the turbovnc package.
(define (delete-all-but directory . preserve)
(define (directory? x)
(and=> (stat x #f)
(compose (cut eq? 'directory <>) stat:type)))
(with-directory-excursion directory
(let* ((pred
(negate (cut member <> (append '("." "..") preserve))))
(items (scandir "." pred)))
(for-each (lambda (item)
(if (directory? item)
(delete-file-recursively item)
(delete-file item)))
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"
(("^\\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)")))))))
;; Use the system sanitizers-cmake module. This is made
;; necessary 'sanitizers-cmake' installing a FindPackage
;; module but no CMake config file.
(("\\$\\{CMAKE_SOURCE_DIR}/3rdparty/sanitizers-cmake/cmake")
(string-append
#$(this-package-native-input "sanitizers-cmake")
"/share/sanitizers-cmake/cmake"))))))))
(native-inputs
(list googletest sanitizers-cmake))
(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))))
(description "Nextpnr is a portable FPGA place and route tool.")
(home-page "https://github.com/YosysHQ/nextpnr/")
(license license:isc)))
(define-public gtkwave
(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