3daf489719
Without the change `nlohmann_json` build on `gcc-13 `fails as: In file included from <<NIX>>-gcc-13.0.0/include/c++/13.0.0/ext/alloc_traits.h:34, from <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/basic_string.h:39, from <<NIX>>-gcc-13.0.0/include/c++/13.0.0/string:54, from <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/locale_classes.h:40, from <<NIX>>-gcc-13.0.0/include/c++/13.0.0/locale:41, from tests/src/unit-regression2.cpp:19: <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h: In instantiation of 'struct std::__allocator_traits_base::__rebind<my_allocator<unsigned char>, unsigned char, void>': <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:94:11: required by substitution of 'template<class _Alloc, class _Up> using std::__alloc_rebind = typename std::__allocator_traits_base::__rebind<_Alloc, _Up>::type [with _Alloc = my_allocator<unsigned char>; _Up = unsigned char]' <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:228:8: required by substitution of 'template<class _Alloc> template<class _Tp> using std::allocator_traits< <template-parameter-1-1> >::rebind_alloc = std::__alloc_rebind<_Alloc, _Tp> [with _Tp = unsigned char; _Alloc = my_allocator<unsigned char>]' <<NIX>>-gcc-13.0.0/include/c++/13.0.0/ext/alloc_traits.h:126:65: required from 'struct __gnu_cxx::__alloc_traits<my_allocator<unsigned char>, unsigned char>::rebind<unsigned char>' <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/stl_vector.h:88:21: required from 'struct std::_Vector_base<unsigned char, my_allocator<unsigned char> >' <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/stl_vector.h:423:11: required from 'class std::vector<unsigned char, my_allocator<unsigned char> >' tests/src/unit-regression2.cpp:807:63: required from here <<NIX>>-gcc-13.0.0/include/c++/13.0.0/bits/alloc_traits.h:70:31: error: static assertion failed: allocator_traits<A>::rebind_alloc<A::value_type> must be A 70 | _Tp>::value, | ^~~~~
67 lines
1.9 KiB
Nix
67 lines
1.9 KiB
Nix
{ stdenv
|
|
, lib
|
|
, fetchFromGitHub
|
|
, fetchpatch
|
|
, cmake
|
|
}:
|
|
let
|
|
testData = fetchFromGitHub {
|
|
owner = "nlohmann";
|
|
repo = "json_test_data";
|
|
rev = "v3.1.0";
|
|
hash = "sha256-bG34W63ew7haLnC82A3lS7bviPDnApLipaBjJAjLcVk=";
|
|
};
|
|
in stdenv.mkDerivation (finalAttrs: {
|
|
pname = "nlohmann_json";
|
|
version = "3.11.2";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "nlohmann";
|
|
repo = "json";
|
|
rev = "v${finalAttrs.version}";
|
|
hash = "sha256-SUdhIV7tjtacf5DkoWk9cnkfyMlrkg8ZU7XnPZd22Tw=";
|
|
};
|
|
|
|
patches = [
|
|
# Backport fix for gcc-13:
|
|
# https://github.com/nlohmann/json/pull/3895
|
|
(fetchpatch {
|
|
name = "gcc-13-rebind.patch";
|
|
url = "https://github.com/nlohmann/json/commit/a5b09d50b786638ed9deb09ef13860a3cb64eb6b.patch";
|
|
hash = "sha256-Jbi0VwZP+ZHTGbpIwgKCVc66gOmwjkT5iOUe85eIzM0=";
|
|
})
|
|
|
|
# Backport fix for gcc-13:
|
|
# https://github.com/nlohmann/json/pull/3950
|
|
(fetchpatch {
|
|
name = "gcc-13-eq-op.patch";
|
|
url = "https://github.com/nlohmann/json/commit/a49829bd984c0282be18fcec070df0c31bf77dd5.patch";
|
|
hash = "sha256-D+cRtdN6AXr4z3/y9Ui7Zqp3e/y10tp+DOL80ZtPz5E=";
|
|
})
|
|
];
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
cmakeFlags = [
|
|
"-DJSON_BuildTests=${if finalAttrs.doCheck then "ON" else "OFF"}"
|
|
"-DJSON_FastTests=ON"
|
|
"-DJSON_MultipleHeaders=ON"
|
|
] ++ lib.optional finalAttrs.doCheck "-DJSON_TestDataDirectory=${testData}";
|
|
|
|
doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
|
|
|
|
# skip tests that require git or modify “installed files”
|
|
preCheck = ''
|
|
checkFlagsArray+=("ARGS=-LE 'not_reproducible|git_required'")
|
|
'';
|
|
|
|
postInstall = "rm -rf $out/lib64";
|
|
|
|
meta = with lib; {
|
|
description = "JSON for Modern C++";
|
|
homepage = "https://json.nlohmann.me";
|
|
changelog = "https://github.com/nlohmann/json/blob/develop/ChangeLog.md";
|
|
license = licenses.mit;
|
|
platforms = platforms.all;
|
|
};
|
|
})
|