2022-06-02 14:04:08 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchgit
|
|
|
|
, fetchpatch
|
2023-05-24 17:23:55 +00:00
|
|
|
, meson
|
|
|
|
, ninja
|
2022-06-02 14:04:08 +00:00
|
|
|
, flex
|
|
|
|
, bison
|
|
|
|
, pkg-config
|
|
|
|
, which
|
|
|
|
, pythonSupport ? false
|
|
|
|
, python ? null
|
|
|
|
, swig
|
|
|
|
, libyaml
|
2019-09-11 13:07:31 +00:00
|
|
|
}:
|
2015-06-07 22:13:44 +00:00
|
|
|
|
2023-06-10 19:43:05 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2019-01-19 02:00:58 +00:00
|
|
|
pname = "dtc";
|
2023-05-24 17:23:55 +00:00
|
|
|
version = "1.7.0";
|
2015-06-07 22:13:44 +00:00
|
|
|
|
|
|
|
src = fetchgit {
|
2018-03-13 13:11:15 +00:00
|
|
|
url = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git";
|
2023-06-10 19:43:05 +00:00
|
|
|
rev = "refs/tags/v${finalAttrs.version}";
|
2023-05-24 17:23:55 +00:00
|
|
|
sha256 = "sha256-FMh3VvlY3fUK8fbd0M+aCmlUrmG9YegiOOQ7MOByffc=";
|
2015-06-07 22:13:44 +00:00
|
|
|
};
|
|
|
|
|
2022-06-02 14:04:08 +00:00
|
|
|
patches = [
|
2023-05-24 17:23:55 +00:00
|
|
|
# meson: Fix cell overflow tests when running from meson
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/dgibson/dtc/commit/32174a66efa4ad19fc6a2a6422e4af2ae4f055cb.patch";
|
|
|
|
sha256 = "sha256-C7OzwY0zq+2CV3SB5unI7Ill2M3deF7FXeQE3B/Kx2s=";
|
|
|
|
})
|
2022-05-18 13:14:01 +00:00
|
|
|
|
2023-05-24 17:23:55 +00:00
|
|
|
# Use #ifdef NO_VALGRIND
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/dgibson/dtc/commit/41821821101ad8a9f83746b96b163e5bcbdbe804.patch";
|
|
|
|
sha256 = "sha256-7QEFDtap2DWbUGqtyT/RgJZJFldKB8oSubKiCtLZ0w4=";
|
|
|
|
})
|
2023-05-31 14:24:33 +00:00
|
|
|
|
|
|
|
# dtc: Fix linker options so it also works in Darwin
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/dgibson/dtc/commit/3acde70714df3623e112cf3ec99fc9b5524220b8.patch";
|
|
|
|
sha256 = "sha256-uLXL0Sjcn+bnMuF+A6PjUW1Rq6uNg1dQl58zbeYpP/U=";
|
|
|
|
})
|
2023-06-01 13:32:24 +00:00
|
|
|
|
|
|
|
# meson: allow disabling tests
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/dgibson/dtc/commit/35f26d2921b68d97fefbd5a2b6e821a2f02ff65d.patch";
|
|
|
|
sha256 = "sha256-cO4f/jJX/pQL7kk4jpKUhsCVESW2ZuWaTr7z3BuvVkw=";
|
|
|
|
})
|
2022-06-02 14:04:08 +00:00
|
|
|
];
|
|
|
|
|
2023-06-10 19:43:05 +00:00
|
|
|
env.SETUPTOOLS_SCM_PRETEND_VERSION = finalAttrs.version;
|
2023-05-24 17:23:55 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
flex
|
|
|
|
bison
|
|
|
|
pkg-config
|
|
|
|
which
|
|
|
|
] ++ lib.optionals pythonSupport [
|
|
|
|
python
|
|
|
|
python.pkgs.setuptools-scm
|
|
|
|
swig
|
|
|
|
];
|
2022-06-02 14:04:08 +00:00
|
|
|
|
2021-04-09 00:02:36 +00:00
|
|
|
buildInputs = [ libyaml ];
|
2015-06-07 22:13:44 +00:00
|
|
|
|
2017-11-07 00:05:06 +00:00
|
|
|
postPatch = ''
|
2023-05-24 17:23:55 +00:00
|
|
|
patchShebangs setup.py
|
2023-05-31 14:24:33 +00:00
|
|
|
|
|
|
|
# meson.build: bump version to 1.7.0
|
|
|
|
substituteInPlace libfdt/meson.build \
|
2023-06-10 19:43:05 +00:00
|
|
|
--replace "version: '1.6.0'," "version: '${finalAttrs.version}',"
|
2023-05-31 14:24:33 +00:00
|
|
|
substituteInPlace meson.build \
|
2023-06-10 19:43:05 +00:00
|
|
|
--replace "version: '1.6.0'," "version: '${finalAttrs.version}',"
|
2017-11-07 00:05:06 +00:00
|
|
|
'';
|
|
|
|
|
2023-05-24 17:23:55 +00:00
|
|
|
# Required for installation of Python library and is innocuous otherwise.
|
|
|
|
env.DESTDIR = "/";
|
|
|
|
|
|
|
|
mesonAutoFeatures = "auto";
|
|
|
|
mesonFlags = [
|
|
|
|
(lib.mesonBool "static-build" stdenv.hostPlatform.isStatic)
|
2023-06-11 19:29:51 +00:00
|
|
|
(lib.mesonBool "tests" finalAttrs.finalPackage.doCheck)
|
2023-05-24 17:23:55 +00:00
|
|
|
];
|
2015-06-07 22:13:44 +00:00
|
|
|
|
2023-06-10 19:39:27 +00:00
|
|
|
doCheck =
|
|
|
|
# Checks are broken on aarch64 darwin
|
|
|
|
# https://github.com/NixOS/nixpkgs/pull/118700#issuecomment-885892436
|
|
|
|
!stdenv.isDarwin &&
|
|
|
|
|
|
|
|
# we must explicitly disable this here so that mesonFlags receives
|
|
|
|
# `-Dtests=disabled`; without it meson will attempt to run
|
|
|
|
# hostPlatform binaries during the configurePhase.
|
|
|
|
(with stdenv; buildPlatform.canExecute hostPlatform);
|
2021-04-09 00:02:36 +00:00
|
|
|
|
2019-09-11 13:07:31 +00:00
|
|
|
meta = with lib; {
|
2015-06-07 22:13:44 +00:00
|
|
|
description = "Device Tree Compiler";
|
2022-06-05 15:36:26 +00:00
|
|
|
homepage = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git";
|
2021-04-09 00:02:36 +00:00
|
|
|
license = licenses.gpl2Plus; # dtc itself is GPLv2, libfdt is dual GPL/BSD
|
2015-06-07 22:13:44 +00:00
|
|
|
maintainers = [ maintainers.dezgeg ];
|
2016-02-03 02:25:54 +00:00
|
|
|
platforms = platforms.unix;
|
2015-06-07 22:13:44 +00:00
|
|
|
};
|
2023-06-10 19:43:05 +00:00
|
|
|
})
|