From db0aad6b4f71f360dc3b2261b29de51dce4fa59b Mon Sep 17 00:00:00 2001 From: Chris W <22242927+chris1786@users.noreply.github.com> Date: Tue, 5 May 2026 10:12:01 +0100 Subject: [PATCH] [dtc] Add new port (#51538) Co-authored-by: Billy Robert O'Neal III --- ports/dtc/0001-enable-static-or-shared.patch | 32 ++++++++++++++++ ports/dtc/portfile.cmake | 40 ++++++++++++++++++++ ports/dtc/vcpkg.json | 13 +++++++ versions/baseline.json | 4 ++ versions/d-/dtc.json | 9 +++++ 5 files changed, 98 insertions(+) create mode 100644 ports/dtc/0001-enable-static-or-shared.patch create mode 100644 ports/dtc/portfile.cmake create mode 100644 ports/dtc/vcpkg.json create mode 100644 versions/d-/dtc.json diff --git a/ports/dtc/0001-enable-static-or-shared.patch b/ports/dtc/0001-enable-static-or-shared.patch new file mode 100644 index 0000000000..48595948ca --- /dev/null +++ b/ports/dtc/0001-enable-static-or-shared.patch @@ -0,0 +1,32 @@ +diff --git a/libfdt/meson.build b/libfdt/meson.build +index bf8343f..c2f4bd6 100644 +--- a/libfdt/meson.build ++++ b/libfdt/meson.build +@@ -26,7 +26,7 @@ else + endif + + link_args += version_script +-libfdt = both_libraries( ++libfdt = library( + 'fdt', sources, + version: meson.project_version(), + link_args: link_args, +@@ -34,17 +34,11 @@ libfdt = both_libraries( + install: true, + ) + +-if static_build +- link_with = libfdt.get_static_lib() +-else +- link_with = libfdt.get_shared_lib() +-endif +- + libfdt_inc = include_directories('.') + + libfdt_dep = declare_dependency( + include_directories: libfdt_inc, +- link_with: link_with, ++ link_with: libfdt, + ) + + install_headers( diff --git a/ports/dtc/portfile.cmake b/ports/dtc/portfile.cmake new file mode 100644 index 0000000000..c76e32a623 --- /dev/null +++ b/ports/dtc/portfile.cmake @@ -0,0 +1,40 @@ +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_check_linkage(ONLY_STATIC_LIBRARY) # library does not explicitely export its symbols. +endif() + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO dgibson/dtc + REF "v${VERSION}" + SHA512 5cf48c8bd426919bb8aad6a8866e063305eca830547f8ceb5fe7746bc85a8d6a0a1e13fd29432cb389d3d51337368f217077aabf9436b526e77d425b33167694 + HEAD_REF main + PATCHES + 0001-enable-static-or-shared.patch +) + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(STATIC_BUILD true) +else() + set(STATIC_BUILD false) +endif() + +vcpkg_configure_meson( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -Dtools=false + -Dyaml=disabled + -Dvalgrind=disabled + -Dpython=disabled + -Dtests=false + "-Dstatic-build=${STATIC_BUILD}" +) + +vcpkg_install_meson() + +vcpkg_fixup_pkgconfig() + +vcpkg_install_copyright(FILE_LIST + "${SOURCE_PATH}/README.license" + "${SOURCE_PATH}/BSD-2-Clause" + "${SOURCE_PATH}/GPL" +) diff --git a/ports/dtc/vcpkg.json b/ports/dtc/vcpkg.json new file mode 100644 index 0000000000..5542c3f7c5 --- /dev/null +++ b/ports/dtc/vcpkg.json @@ -0,0 +1,13 @@ +{ + "name": "dtc", + "version": "1.7.2", + "description": "Device Tree Compiler (dtc) toolchain for working with device tree source and binary files and also libfdt, a utility library for reading and manipulating the binary format.", + "homepage": "https://github.com/dgibson/dtc", + "license": "GPL-2.0-or-later OR BSD-2-Clause", + "dependencies": [ + { + "name": "vcpkg-tool-meson", + "host": true + } + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index 9f040fd9d6..50f3daab22 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -2620,6 +2620,10 @@ "baseline": "1.3.0", "port-version": 0 }, + "dtc": { + "baseline": "1.7.2", + "port-version": 0 + }, "dtl": { "baseline": "1.21", "port-version": 0 diff --git a/versions/d-/dtc.json b/versions/d-/dtc.json new file mode 100644 index 0000000000..c1a6699046 --- /dev/null +++ b/versions/d-/dtc.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "09cf1dc350d443ca61f4374a51069fc2b2b67522", + "version": "1.7.2", + "port-version": 0 + } + ] +}