Commit 280160bd authored by Otavio Salvador's avatar Otavio Salvador Committed by Anderson Torres
Browse files

dtc: 1.6.1 -> 1.7.0



The package now uses Meson and Ninja as the build system.

Signed-off-by: default avatarOtavio Salvador <otavio@ossystems.com.br>
parent 37f7c78f
Loading
Loading
Loading
Loading
+0 −90
Original line number Diff line number Diff line
From c1d426bdd477ffeb3dfa03501de089a341b85d0b Mon Sep 17 00:00:00 2001
From: Tero Tervala <tero.tervala@unikie.com>
Date: Wed, 15 Jun 2022 13:44:55 +0300
Subject: [PATCH] Depend on .a instead of .so when building static

Static build needs to be indicated with environment variable:
STATIC_BUILD=1

Checks are skipped on static builds

Signed-off-by: Tero Tervala <tero.tervala@unikie.com>
---
 Makefile             | 12 +++++++++---
 tests/Makefile.tests | 11 ++++++++---
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index ee77115..9f550b4 100644
--- a/Makefile
+++ b/Makefile
@@ -198,6 +198,12 @@ LIBFDT_lib = $(LIBFDT_dir)/$(LIBFDT_LIB)
 LIBFDT_include = $(addprefix $(LIBFDT_dir)/,$(LIBFDT_INCLUDES))
 LIBFDT_version = $(addprefix $(LIBFDT_dir)/,$(LIBFDT_VERSION))
 
+ifeq ($(STATIC_BUILD),1)
+	LIBFDT_dep = $(LIBFDT_archive)
+else
+	LIBFDT_dep = $(LIBFDT_lib)
+endif
+
 include $(LIBFDT_dir)/Makefile.libfdt
 
 .PHONY: libfdt
@@ -261,11 +267,11 @@ convert-dtsv0: $(CONVERT_OBJS)
 
 fdtdump:	$(FDTDUMP_OBJS)
 
-fdtget:	$(FDTGET_OBJS) $(LIBFDT_lib)
+fdtget:	$(FDTGET_OBJS) $(LIBFDT_dep)
 
-fdtput:	$(FDTPUT_OBJS) $(LIBFDT_lib)
+fdtput:	$(FDTPUT_OBJS) $(LIBFDT_dep)
 
-fdtoverlay: $(FDTOVERLAY_OBJS) $(LIBFDT_lib)
+fdtoverlay: $(FDTOVERLAY_OBJS) $(LIBFDT_dep)
 
 dist:
 	git archive --format=tar --prefix=dtc-$(dtc_version)/ HEAD \
diff --git a/tests/Makefile.tests b/tests/Makefile.tests
index 2f78952..f13b16d 100644
--- a/tests/Makefile.tests
+++ b/tests/Makefile.tests
@@ -60,17 +60,17 @@ TESTS_CLEANDIRS = $(TESTS_CLEANDIRS_L:%=$(TESTS_PREFIX)%)
 .PHONY: tests
 tests:	$(TESTS) $(TESTS_TREES)
 
-$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_lib)
+$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_dep)
 
 # Not necessary on all platforms; allow -ldl to be excluded instead of forcing
 # other platforms to patch it out.
 LIBDL = -ldl
-$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_lib)
+$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_dep)
 	@$(VECHO) LD [libdl] $@
 	$(LINK.c) -o $@ $^ $(LIBDL)
 
 $(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o \
-		util.o $(LIBFDT_lib)
+		util.o $(LIBFDT_dep)
 
 $(TESTS_PREFIX)dumptrees: $(TESTS_PREFIX)trees.o
 
@@ -83,8 +83,13 @@ tests_clean:
 	rm -f $(TESTS_CLEANFILES)
 	rm -rf $(TESTS_CLEANDIRS)
 
+ifeq ($(STATIC_BUILD),1)
+check:
+	@echo Skipping checks for static build
+else
 check:	tests ${TESTS_BIN} $(TESTS_PYLIBFDT)
 	cd $(TESTS_PREFIX); ./run_tests.sh
+endif
 
 ifeq ($(NO_VALGRIND),1)
 checkm:
-- 
2.33.3
+48 −13
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@
, lib
, fetchgit
, fetchpatch
, meson
, ninja
, flex
, bison
, pkg-config
@@ -14,35 +16,68 @@

stdenv.mkDerivation rec {
  pname = "dtc";
  version = "1.6.1";
  version = "1.7.0";

  src = fetchgit {
    url = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git";
    rev = "refs/tags/v${version}";
    sha256 = "sha256-gx9LG3U9etWhPxm7Ox7rOu9X5272qGeHqZtOe68zFs4=";
    sha256 = "sha256-FMh3VvlY3fUK8fbd0M+aCmlUrmG9YegiOOQ7MOByffc=";
  };

  patches = [
    # fix python 3.10 compatibility
    # based on without requiring the setup.py rework
    # https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=383e148b70a47ab15f97a19bb999d54f9c3e810f
    ./python-3.10.patch
    # meson: Fix cell overflow tests when running from meson
    (fetchpatch {
      url = "https://github.com/dgibson/dtc/commit/32174a66efa4ad19fc6a2a6422e4af2ae4f055cb.patch";
      sha256 = "sha256-C7OzwY0zq+2CV3SB5unI7Ill2M3deF7FXeQE3B/Kx2s=";
    })

    # fix dtc static building
    ./0001-Depend-on-.a-instead-of-.so-when-building-static.patch
    # meson.build: bump version to 1.7.0
    (fetchpatch {
      url = "https://github.com/dgibson/dtc/commit/64a907f08b9bedd89833c1eee674148cff2343c6.patch";
      sha256 = "sha256-p2KGS5GW+3uIPgXfuIx6aDC54csM+5FZDkK03t58AL8=";
    })

    # Fix version in libfdt/meson.build
    (fetchpatch {
      url = "https://github.com/dgibson/dtc/commit/723545ebe9933b90ea58dc125e4987c6bcb04ade.patch";
      sha256 = "sha256-5Oq7q+62ZObj3e7rguN9jhSpYoQkwjSfo/N893229dQ=";
    })

    # Use #ifdef NO_VALGRIND
    (fetchpatch {
      url = "https://github.com/dgibson/dtc/commit/41821821101ad8a9f83746b96b163e5bcbdbe804.patch";
      sha256 = "sha256-7QEFDtap2DWbUGqtyT/RgJZJFldKB8oSubKiCtLZ0w4=";
    })
  ];

  nativeBuildInputs = [ flex bison pkg-config which ]
    ++ lib.optionals pythonSupport [ python swig ];
  env.SETUPTOOLS_SCM_PRETEND_VERSION = version;

  nativeBuildInputs = [
    meson
    ninja
    flex
    bison
    pkg-config
    which
  ] ++ lib.optionals pythonSupport [
    python
    python.pkgs.setuptools-scm
    swig
  ];

  buildInputs = [ libyaml ];

  postPatch = ''
    patchShebangs pylibfdt/
    patchShebangs setup.py
  '';

  makeFlags = [ "PYTHON=python" "STATIC_BUILD=${toString stdenv.hostPlatform.isStatic}" ];
  installFlags = [ "INSTALL=install" "PREFIX=$(out)" "SETUP_PREFIX=$(out)" ];
  # Required for installation of Python library and is innocuous otherwise.
  env.DESTDIR = "/";

  mesonAutoFeatures = "auto";
  mesonFlags = [
    (lib.mesonBool "static-build" stdenv.hostPlatform.isStatic)
  ];

  postFixup = lib.optionalString stdenv.isDarwin ''
    install_name_tool -id $out/lib/libfdt.dylib $out/lib/libfdt-${version}.dylib
+0 −28
Original line number Diff line number Diff line
diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
index 51ee801..075ef70 100644
--- a/pylibfdt/libfdt.i
+++ b/pylibfdt/libfdt.i
@@ -1044,9 +1044,9 @@ typedef uint32_t fdt32_t;
 		$result = Py_None;
 	else
         %#if PY_VERSION_HEX >= 0x03000000
-            $result = Py_BuildValue("y#", $1, *arg4);
+            $result = Py_BuildValue("y#", $1, (Py_ssize_t)*arg4);
         %#else
-            $result = Py_BuildValue("s#", $1, *arg4);
+            $result = Py_BuildValue("s#", $1, (Py_ssize_t)*arg4);
         %#endif
 }
 
diff --git a/pylibfdt/setup.py b/pylibfdt/setup.py
index ef40f15..81e161a 100755
--- a/pylibfdt/setup.py
+++ b/pylibfdt/setup.py
@@ -42,6 +42,7 @@ def get_version():
 libfdt_module = Extension(
     '_libfdt',
     sources=[os.path.join(srcdir, 'libfdt.i')],
+    define_macros=[('PY_SSIZE_T_CLEAN', None)],
     include_dirs=[os.path.join(srcdir, '../libfdt')],
     libraries=['fdt'],
     library_dirs=[os.path.join(top_builddir, 'libfdt')],