at master 2.7 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 fetchpatch, 6 unzip, 7}: 8 9let 10 version = "2.6.2"; 11 SHLIB_EXT = stdenv.hostPlatform.extensions.sharedLibrary; 12in 13stdenv.mkDerivation { 14 pname = "tinyxml"; 15 inherit version; 16 17 src = fetchurl { 18 url = "mirror://sourceforge/project/tinyxml/tinyxml/${version}/tinyxml_2_6_2.zip"; 19 sha256 = "04nmw6im2d1xp12yir8va93xns5iz816pwi25n9cql3g3i8bjsxc"; 20 }; 21 22 patches = [ 23 # add pkg-config file 24 ./2.6.2-add-pkgconfig.patch 25 26 # https://sourceforge.net/tracker/index.php?func=detail&aid=3031828&group_id=13559&atid=313559 27 ./2.6.2-entity.patch 28 29 # Use CC, CXX, and LD from environment 30 ./2.6.2-cxx.patch 31 32 (fetchpatch { 33 name = "CVE-2023-34194.patch"; 34 url = "https://salsa.debian.org/debian/tinyxml/-/raw/2366e1f23d059d4c20c43c54176b6bd78d6a83fc/debian/patches/CVE-2023-34194.patch"; 35 hash = "sha256-ow4LmLQV24SAU6M1J8PXpW5c95+el3t8weM9JK5xJfg="; 36 }) 37 (fetchpatch { 38 name = "CVE-2021-42260.patch"; 39 url = "https://salsa.debian.org/debian/tinyxml/-/raw/dc332a9f4e05496c8342b778c14b256083beb1ee/debian/patches/CVE-2021-42260.patch"; 40 hash = "sha256-pIM0uOnUQOW93w/PEPuW3yKq1mdvNT/ClCYVc2hLoY8="; 41 }) 42 ]; 43 44 preConfigure = "export LD=${stdenv.cc.targetPrefix}c++"; 45 46 hardeningDisable = [ "format" ]; 47 48 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-mmacosx-version-min=10.9"; 49 50 nativeBuildInputs = [ unzip ]; 51 buildPhase = '' 52 # use STL (xbmc requires it) 53 sed '1i#define TIXML_USE_STL 1' -i tinyxml.h 54 sed '1i#define TIXML_USE_STL 1' -i xmltest.cpp 55 56 # build xmltest 57 make 58 59 # build the lib as a shared library 60 ''${CXX} -Wall -O2 -shared -fpic tinyxml.cpp \ 61 tinyxmlerror.cpp tinyxmlparser.cpp \ 62 tinystr.cpp -o libtinyxml${SHLIB_EXT} 63 ''; 64 65 doCheck = true; 66 checkPhase = '' 67 ./xmltest 68 result=$? 69 if [[ $result != 0 ]] ; then 70 exit $result 71 fi 72 ''; 73 74 installPhase = '' 75 mkdir -pv $out/include/ 76 mkdir -pv $out/lib/pkgconfig/ 77 mkdir -pv $out/share/doc/tinyxml/ 78 79 cp -v libtinyxml${SHLIB_EXT} $out/lib/ 80 cp -v *.h $out/include/ 81 82 substituteInPlace tinyxml.pc --replace "@out@" "$out" 83 substituteInPlace tinyxml.pc --replace "@version@" "${version}" 84 cp -v tinyxml.pc $out/lib/pkgconfig/ 85 86 cp -v docs/* $out/share/doc/tinyxml/ 87 '' 88 + lib.optionalString stdenv.hostPlatform.isDarwin '' 89 install_name_tool -id $out/lib/libtinyxml.dylib $out/lib/libtinyxml.dylib 90 ''; 91 92 meta = { 93 description = "Simple, small, C++ XML parser that can be easily integrating into other programs"; 94 homepage = "http://www.grinninglizard.com/tinyxml/index.html"; 95 license = lib.licenses.zlib; 96 platforms = lib.platforms.unix; 97 }; 98}