diff mbox series

[bug#68023,01/13] gnu: dtc: Update to 1.7.0.

Message ID 9946d80edc86aa465acc39b9c51094c65c2c5bf1.1703494195.git.othacehe@gnu.org
State New
Headers show
Series Add support for Linux `make dtbs_check` | expand

Commit Message

Mathieu Othacehe Dec. 25, 2023, 9:09 a.m. UTC
Enable the python bindings and switch to the meson build system that handles
the python bindings better than the Makefile build system here.

* gnu/packages/patches/dtc-meson-cell-overflow.patch: New file
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/bootloaders.scm (dtc): Update to 1.7.0.
[build-system]: Switch to the meson-build-system.
[arguments]: Remove #:make-flags. Add a new 'preparations phase. Do not edit
the Makefile in the 'patch-pkg-config phase. Remove the 'configure phase.

Change-Id: Ie61c920829ab3a8c32f4924c694dba6bda807711
Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
---
 gnu/local.mk                                  |  1 +
 gnu/packages/bootloaders.scm                  | 57 ++++++++++++-------
 .../patches/dtc-meson-cell-overflow.patch     | 32 +++++++++++
 3 files changed, 70 insertions(+), 20 deletions(-)
 create mode 100644 gnu/packages/patches/dtc-meson-cell-overflow.patch
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index a472c62acb..91a34983c8 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1093,6 +1093,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/doxygen-hurd.patch			\
   %D%/packages/patches/dstat-fix-crash-when-specifying-delay.patch	\
   %D%/packages/patches/dstat-skip-devices-without-io.patch	\
+  %D%/packages/patches/dtc-meson-cell-overflow.patch		\
   %D%/packages/patches/dune-common-skip-failing-tests.patch	\
   %D%/packages/patches/dune-grid-add-missing-include-cassert.patch	\
   %D%/packages/patches/dune-istl-fix-solver-playground.patch	\
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index bd8b621e35..f8ba93ce01 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -55,6 +55,8 @@  (define-module (gnu packages bootloaders)
   #:use-module (gnu packages man)
   #:use-module (gnu packages mtools)
   #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages ninja)
+  #:use-module (gnu packages package-management)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -71,6 +73,7 @@  (define-module (gnu packages bootloaders)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system meson)
   #:use-module (guix build-system pyproject)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
@@ -631,7 +634,7 @@  (define-public syslinux
 (define-public dtc
   (package
     (name "dtc")
-    (version "1.6.1")
+    (version "1.7.0")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -639,42 +642,56 @@  (define-public dtc
                     "dtc-" version ".tar.gz"))
               (sha256
                (base32
-                "0xm38h31jb29xfh2sfyk48d8wdfq4b8lmb412zx9vjr35izjb9iq"))))
-    (build-system gnu-build-system)
+                "0cij9399snpn672pdbda8qbxljdkfg068kvv3g5811rz6yslx124"))
+              (patches
+               (search-patches "dtc-meson-cell-overflow.patch"))))
+    (build-system meson-build-system)
     (arguments
      (list
-      #:modules `(,@%gnu-build-system-modules (srfi srfi-26))
-      #:make-flags
-      #~(list (string-append "CC=" #$(cc-for-target))
-              ;; /bin/fdt{get,overlay,put} need help finding libfdt.so.1.
-              (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib")
-              (string-append "PREFIX=" #$output)
-              (string-append "SETUP_PREFIX=" #$output)
-              "INSTALL=install")
+      #:modules '((guix build meson-build-system)
+                  (guix build utils)
+                  (srfi srfi-26))
       #:phases
       #~(modify-phases %standard-phases
-          (add-after 'unpack 'patch-pkg-config
+          (add-after 'unpack 'preparations
             (lambda _
-              (substitute* '("Makefile"
-                             "tests/run_tests.sh")
-                (("pkg-config")
-                 #$(pkg-config-for-target)))))
-          (delete 'configure)           ;no configure script
-          (add-before 'build 'install-doc
+              ;; The version string is usually derived via setuptools-scm, but
+              ;; without the git metadata available this fails.
+              (setenv "SETUPTOOLS_SCM_PRETEND_VERSION" #$version)
+
+              ;; Needed by setup.py.
+              (setenv "DESTDIR" "/")
+
+              ;; Native gcc needed by run_test.sh.
+              (setenv "CC" "gcc")
+
+              ;; /bin/fdt{get,overlay,put} need help finding libfdt.so.1.
+              (setenv "LDFLAGS"
+                      (string-append "-Wl,-rpath=" #$output "/lib"))))
+          (add-after 'unpack 'install-doc
             (lambda _
               (with-directory-excursion "Documentation"
                 (for-each (cut install-file <> (string-append
                                                 #$output "/share/doc/dtc/"))
                           '("dts-format.txt"
                             "dt-object-internal.txt"
-                            "manual.txt"))))))))
+                            "manual.txt")))))
+          (add-after 'unpack 'patch-pkg-config
+            (lambda _
+              (substitute* '("tests/run_tests.sh")
+                (("pkg-config")
+                 #$(pkg-config-for-target))))))))
     (native-inputs
      (append
       (list bison
             flex
             libyaml
+            ninja
             pkg-config
-            swig)
+            python
+            python-setuptools-scm
+            swig
+            which)
       (if (member (%current-system) (package-supported-systems valgrind))
           (list valgrind)
           '())))
diff --git a/gnu/packages/patches/dtc-meson-cell-overflow.patch b/gnu/packages/patches/dtc-meson-cell-overflow.patch
new file mode 100644
index 0000000000..1c319312f7
--- /dev/null
+++ b/gnu/packages/patches/dtc-meson-cell-overflow.patch
@@ -0,0 +1,32 @@ 
+Taken from upstream:
+https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=32174a66efa4ad19fc6a2a6422e4af2ae4f055cb
+
+From 32174a66efa4ad19fc6a2a6422e4af2ae4f055cb Mon Sep 17 00:00:00 2001
+From: David Gibson <david@gibson.dropbear.id.au>
+Date: Tue, 28 Feb 2023 10:33:58 +1100
+Subject: [PATCH] meson: Fix cell overflow tests when running from meson
+
+Because meson always builds out-of-tree we need to reference things in the
+original source tree via $SRCDIR from run_tests.sh.  We forgot a couple of
+cases for the cell overflow tests.  Fix them.
+
+Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
+---
+ tests/run_tests.sh | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tests/run_tests.sh b/tests/run_tests.sh
+index 91350ad3..f899d8cb 100755
+--- a/tests/run_tests.sh
++++ b/tests/run_tests.sh
+@@ -519,8 +519,8 @@ libfdt_tests () {
+     check_tests "$SRCDIR/phandle-args-overflow.dts" clocks_property
+ 
+     ## https://github.com/dgibson/dtc/issues/74
+-    run_dtc_test -I dts -O dtb -o cell-overflow-results.test.dtb cell-overflow-results.dts
+-    run_dtc_test -I dts -O dtb -o cell-overflow.test.dtb cell-overflow.dts
++    run_dtc_test -I dts -O dtb -o cell-overflow-results.test.dtb "$SRCDIR/cell-overflow-results.dts"
++    run_dtc_test -I dts -O dtb -o cell-overflow.test.dtb "$SRCDIR/cell-overflow.dts"
+     run_test dtbs_equal_ordered cell-overflow.test.dtb cell-overflow-results.test.dtb
+ 
+     # check full tests