Subject: [PATCH electronics-team] gnu: Add prjtrellis.
From: Cayetano Santos <[email-masked]>
To: [email-masked]
Cc: Cayetano Santos <[email-masked]>
Date: Fri, 25 Apr 2025 20:23:15 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

* gnu/packages/electronics.scm (prjtrellis): New variable.

Change-Id: Iac188df00f55c06f9000fe1b688d6cded9d495fd
---
 gnu/packages/electronics.scm | 43 ++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/gnu/packages/electronics.scm b/gnu/packages/electronics.scm
index 12e44f234a..166de9e27c 100644
--- a/gnu/packages/electronics.scm
+++ b/gnu/packages/electronics.scm
@@ -415,6 +415,49 @@ (define-public openboardview
 @end itemize")
     (license license:expat)))
 
+(define-public prjtrellis
+  (package
+    (name "prjtrellis")
+    (version "1.4")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/YosysHQ/prjtrellis/")
+             (commit version)
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0c3asdfrjmnc6q3vawn3nfghgg43iajwy2zb8kck9d3wrypbhlmc"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list
+      #:tests? #f ; tests are to be run from nextpnr-ecp5
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'chdir
+            (lambda _
+              (chdir "libtrellis")))
+          ;; Remove bundled source code for which Guix has packages.
+          (add-after 'chdir 'remove-deps
+            (lambda _
+              (with-directory-excursion "3rdparty"
+                (for-each delete-file-recursively
+                          '("pybind11")))))
+          ;; point to pybind11 include dir
+          (add-after 'remove-deps 'setenv-pybind11
+            (lambda* (#:key inputs #:allow-other-keys)
+              (setenv "PYBIND11_INCLUDE_DIR"
+                      (string-append #$(this-package-input "pybind11")
+                                     "/include/pybind11")))))))
+    (native-inputs (list python))
+    (inputs (list openocd boost pybind11))
+    (synopsis "Placement and routing for ECP5 FPGAs")
+    (description
+     "Project Trellis is a Nextpnr backend compatible with ECP5 FPGAs.")
+    (home-page "https://github.com/YosysHQ/prjtrellis/")
+    (license license:expat)))
+
 (define-public pulseview
   (package
     (name "pulseview")

base-commit: 4fe4cf9fdd959126d3c53c3df4504d851e7b736a
-- 
2.49.0