nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 181 lines 5.3 kB view raw
1{ 2 stdenv, 3 lib, 4 buildPackages, 5 fetchurl, 6 fixDarwinDylibNames, 7 testers, 8 updateAutotoolsGnuConfigScriptsHook, 9}: 10 11{ 12 version, 13 hash, 14 patches ? [ ], 15 patchFlags ? [ ], 16 withStatic ? stdenv.hostPlatform.isStatic, 17}: 18 19let 20 # Cross-compiled icu4c requires a build-root of a native compile 21 nativeBuildRoot = buildPackages."icu${lib.versions.major version}".buildRootOnly; 22 23 pname = "icu4c"; 24 25 release = lib.replaceStrings [ "." ] [ "-" ] version; 26 # To test rc versions of ICU replace the line above with the line below. 27 #release = lib.replaceStrings [ "." ] [ "-" ] ( 28 # if lib.hasSuffix "rc" version then lib.replaceStrings [ "1" ] [ "" ] version else version 29 #); 30 31 baseAttrs = { 32 src = fetchurl { 33 url = 34 if lib.versionAtLeast version "78.1" then 35 "https://github.com/unicode-org/icu/releases/download/release-${version}/icu4c-${version}-sources.tgz" 36 else 37 "https://github.com/unicode-org/icu/releases/download/release-${release}/icu4c-${ 38 lib.replaceStrings [ "." ] [ "_" ] version 39 }-src.tgz"; 40 inherit hash; 41 }; 42 43 postUnpack = '' 44 sourceRoot=''${sourceRoot}/source 45 echo Source root reset to ''${sourceRoot} 46 ''; 47 48 # https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27xlocale.h.27 49 postPatch = 50 if 51 (stdenv.hostPlatform.libc == "glibc" || stdenv.hostPlatform.libc == "musl") 52 && lib.versionOlder version "62.1" 53 then 54 "substituteInPlace i18n/digitlst.cpp --replace '<xlocale.h>' '<locale.h>'" 55 else 56 null; # won't find locale_t on darwin 57 58 inherit patchFlags patches; 59 60 preConfigure = '' 61 sed -i -e "s|/bin/sh|${stdenv.shell}|" configure 62 63 # $(includedir) is different from $(prefix)/include due to multiple outputs 64 sed -i -e 's|^\(CPPFLAGS = .*\) -I\$(prefix)/include|\1 -I$(includedir)|' config/Makefile.inc.in 65 '' 66 + lib.optionalString stdenv.hostPlatform.isAarch32 '' 67 # From https://archlinuxarm.org/packages/armv7h/icu/files/icudata-stdlibs.patch 68 sed -e 's/LDFLAGSICUDT=-nodefaultlibs -nostdlib/LDFLAGSICUDT=/' -i config/mh-linux 69 ''; 70 71 dontDisableStatic = withStatic; 72 73 configureFlags = [ 74 "--disable-debug" 75 ] 76 ++ lib.optional (stdenv.hostPlatform.isFreeBSD || stdenv.hostPlatform.isDarwin) "--enable-rpath" 77 ++ lib.optional ( 78 stdenv.buildPlatform != stdenv.hostPlatform 79 ) "--with-cross-build=${nativeBuildRoot}" 80 ++ lib.optional withStatic "--enable-static"; 81 82 enableParallelBuilding = true; 83 84 meta = { 85 description = "Unicode and globalization support library"; 86 homepage = "https://icu.unicode.org/"; 87 maintainers = with lib.maintainers; [ raskin ]; 88 pkgConfigModules = [ 89 "icu-i18n" 90 "icu-io" 91 "icu-uc" 92 ]; 93 platforms = lib.platforms.all; 94 }; 95 }; 96 97 realAttrs = baseAttrs // { 98 inherit pname version; 99 100 outputs = [ 101 "out" 102 "dev" 103 ] 104 ++ lib.optional withStatic "static"; 105 outputBin = "dev"; 106 107 nativeBuildInputs = [ 108 updateAutotoolsGnuConfigScriptsHook 109 ] 110 ++ 111 # FIXME: This fixes dylib references in the dylibs themselves, but 112 # not in the programs in $out/bin. 113 lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 114 115 # remove dependency on bootstrap-tools in early stdenv build 116 postInstall = 117 lib.optionalString withStatic '' 118 mkdir -p $static/lib 119 mv -v lib/*.a $static/lib 120 '' 121 + lib.optionalString stdenv.hostPlatform.isDarwin '' 122 sed -i 's/INSTALL_CMD=.*install/INSTALL_CMD=install/' $out/lib/icu/${lib.versions.majorMinor version}/pkgdata.inc 123 '' 124 + ( 125 let 126 replacements = [ 127 { 128 from = "\${prefix}/include"; 129 to = "${placeholder "dev"}/include"; 130 } # --cppflags-searchpath 131 { 132 from = "\${pkglibdir}/Makefile.inc"; 133 to = "${placeholder "dev"}/lib/icu/Makefile.inc"; 134 } # --incfile 135 { 136 from = "\${pkglibdir}/pkgdata.inc"; 137 to = "${placeholder "dev"}/lib/icu/pkgdata.inc"; 138 } # --incpkgdatafile 139 ]; 140 in 141 '' 142 rm $out/share/icu/${lib.versions.majorMinor version}/install-sh $out/share/icu/${lib.versions.majorMinor version}/mkinstalldirs # Avoid having a runtime dependency on bash 143 144 substituteInPlace "$dev/bin/icu-config" \ 145 ${lib.concatMapStringsSep " " (r: "--replace '${r.from}' '${r.to}'") replacements} 146 '' 147 ); 148 149 postFixup = ''moveToOutput lib/icu "$dev" ''; 150 }; 151 152 buildRootOnlyAttrs = baseAttrs // { 153 pname = pname + "-build-root"; 154 inherit version; 155 156 preConfigure = baseAttrs.preConfigure + '' 157 mkdir build 158 cd build 159 configureScript=../configure 160 ''; 161 162 postBuild = '' 163 cd .. 164 mv build $out 165 echo "Doing build-root only, exiting now" >&2 166 exit 0 167 ''; 168 }; 169 170 mkWithAttrs = 171 attrs: 172 stdenv.mkDerivation ( 173 finalAttrs: 174 attrs 175 // { 176 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 177 passthru.buildRootOnly = mkWithAttrs buildRootOnlyAttrs; 178 } 179 ); 180in 181mkWithAttrs realAttrs