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