darwin.ICU: convert to upstream build system and use mkAppleDerivation
This commit is contained in:
parent
eed715ac43
commit
0335ce09c0
@ -1,89 +0,0 @@
|
||||
{ appleDerivation, lib, stdenv, buildPackages, python3 }:
|
||||
|
||||
let
|
||||
formatVersionNumeric = version:
|
||||
let
|
||||
versionParts = lib.versions.splitVersion version;
|
||||
major = lib.toInt (lib.elemAt versionParts 0);
|
||||
minor = lib.toInt (lib.elemAt versionParts 1);
|
||||
patch = if lib.length versionParts > 2 then lib.toInt (lib.elemAt versionParts 2) else 0;
|
||||
in toString (major * 10000 + minor * 100 + patch);
|
||||
in
|
||||
|
||||
appleDerivation {
|
||||
patches = [ ./suppress-icu-check-crash.patch ];
|
||||
|
||||
nativeBuildInputs = [ python3 ];
|
||||
|
||||
depsBuildBuild = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ buildPackages.stdenv.cc ];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace makefile \
|
||||
--replace-fail "/usr/bin/" "" \
|
||||
--replace-fail "xcrun --sdk macosx --find" "echo -n" \
|
||||
--replace-fail "xcrun --sdk macosx.internal --show-sdk-path" "echo -n /dev/null" \
|
||||
--replace-fail "-install_name " "-install_name $out" \
|
||||
--replace-fail '-x -u -r -S' '-x --keep-undefined -S'
|
||||
|
||||
substituteInPlace icuSources/config/mh-darwin \
|
||||
--replace-fail "-install_name " "-install_name $out/"
|
||||
|
||||
# drop using impure /var/db/timezone/icutz
|
||||
substituteInPlace makefile \
|
||||
--replace-fail '-DU_TIMEZONE_FILES_DIR=\"\\\"$(TZDATA_LOOKUP_DIR)\\\"\" -DU_TIMEZONE_PACKAGE=\"\\\"$(TZDATA_PACKAGE)\\\"\"' ""
|
||||
|
||||
# FIXME: This will cause `ld: warning: OS version (12.0) too small, changing to 13.0.0`, APPLE should fix it.
|
||||
substituteInPlace makefile \
|
||||
--replace-fail "ZIPPERING_LDFLAGS=-Wl,-iosmac_version_min,12.0" "ZIPPERING_LDFLAGS="
|
||||
|
||||
# skip test for missing encodingSamples data
|
||||
substituteInPlace icuSources/test/cintltst/ucsdetst.c \
|
||||
--replace-fail "&TestMailFilterCSS" "NULL"
|
||||
|
||||
patchShebangs icuSources
|
||||
'' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
|
||||
|
||||
# This looks like a bug in the makefile. It defines ENV_BUILDHOST to
|
||||
# propagate the correct value of CC, CXX, etc, but has the following double
|
||||
# expansion that results in the empty string.
|
||||
substituteInPlace makefile \
|
||||
--replace-fail '$($(ENV_BUILDHOST))' '$(ENV_BUILDHOST)'
|
||||
'';
|
||||
|
||||
# APPLE is using makefile to save its default configuration and call ./configure, so we hack makeFlags
|
||||
# instead of configuring ourself, trying to stay abreast of APPLE.
|
||||
dontConfigure = true;
|
||||
makeFlags = [
|
||||
"DSTROOT=$(out)"
|
||||
|
||||
# remove /usr prefix on include and lib
|
||||
"PRIVATE_HDR_PREFIX="
|
||||
"libdir=/lib/"
|
||||
|
||||
"DATA_INSTALL_DIR=/share/icu/"
|
||||
"DATA_LOOKUP_DIR=$(DSTROOT)$(DATA_INSTALL_DIR)"
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # darwin* platform properties are only defined on darwin
|
||||
# hack to use our lower macos version
|
||||
"MAC_OS_X_VERSION_MIN_REQUIRED=${formatVersionNumeric stdenv.hostPlatform.darwinMinVersion}"
|
||||
"ICU_TARGET_VERSION=-m${stdenv.hostPlatform.darwinPlatform}-version-min=${stdenv.hostPlatform.darwinMinVersion}"
|
||||
]
|
||||
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
|
||||
"CROSS_BUILD=YES"
|
||||
"BUILD_TYPE="
|
||||
"RC_ARCHS=${stdenv.hostPlatform.darwinArch}"
|
||||
"HOSTCC=cc"
|
||||
"HOSTCXX=c++"
|
||||
"CC=${stdenv.cc.targetPrefix}cc"
|
||||
"CXX=${stdenv.cc.targetPrefix}c++"
|
||||
"HOSTISYSROOT="
|
||||
"OSX_HOST_VERSION_MIN_STRING=${stdenv.buildPlatform.darwinMinVersion}"
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
checkTarget = "check";
|
||||
|
||||
postInstall = ''
|
||||
# we don't need all those in usr/local
|
||||
rm -rf $out/usr
|
||||
'';
|
||||
}
|
202
pkgs/os-specific/darwin/apple-source-releases/ICU/package.nix
Normal file
202
pkgs/os-specific/darwin/apple-source-releases/ICU/package.nix
Normal file
@ -0,0 +1,202 @@
|
||||
{
|
||||
lib,
|
||||
bootstrapStdenv,
|
||||
buildPackages,
|
||||
fixDarwinDylibNames,
|
||||
mkAppleDerivation,
|
||||
python3,
|
||||
testers,
|
||||
}:
|
||||
|
||||
# Based on:
|
||||
# - ../../../development/libraries/icu/make-icu.nix
|
||||
# - https://github.com/apple-oss-distributions/ICU/blob/main/makefile
|
||||
let
|
||||
stdenv = bootstrapStdenv;
|
||||
withStatic = stdenv.hostPlatform.isStatic;
|
||||
|
||||
# Cross-compiled icu4c requires a build-root of a native compile
|
||||
nativeBuildRoot = buildPackages.darwin.ICU.buildRootOnly;
|
||||
|
||||
baseAttrs = finalAttrs: {
|
||||
releaseName = "ICU";
|
||||
|
||||
sourceRoot = "source/icuSources";
|
||||
|
||||
patches = [
|
||||
# Skip MessageFormatTest test, which is known to crash sometimes and should be suppressed if it does.
|
||||
./patches/suppress-icu-check-crash.patch
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
patchShebangs --build .
|
||||
# $(includedir) is different from $(prefix)/include due to multiple outputs
|
||||
sed -i -e 's|^\(CPPFLAGS = .*\) -I\$(prefix)/include|\1 -I$(includedir)|' config/Makefile.inc.in
|
||||
'';
|
||||
|
||||
dontDisableStatic = withStatic;
|
||||
|
||||
configureFlags =
|
||||
[
|
||||
(lib.enableFeature false "debug")
|
||||
(lib.enableFeature false "renaming")
|
||||
(lib.enableFeature false "extras")
|
||||
(lib.enableFeature false "layout")
|
||||
(lib.enableFeature false "samples")
|
||||
]
|
||||
++ lib.optionals (stdenv.hostPlatform.isFreeBSD || stdenv.hostPlatform.isDarwin) [
|
||||
(lib.enableFeature true "rpath")
|
||||
]
|
||||
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
|
||||
(lib.withFeatureAs true "cross-build" nativeBuildRoot)
|
||||
]
|
||||
++ lib.optionals withStatic [ (lib.enableFeature true "static") ];
|
||||
|
||||
nativeBuildInputs = [ python3 ];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
# Per the source-release makefile, these are enabled.
|
||||
env.NIX_CFLAGS_COMPILE = toString [
|
||||
"-DU_SHOW_CPLUSPLUS_API=1"
|
||||
"-DU_SHOW_INTERNAL_API=1"
|
||||
];
|
||||
|
||||
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
||||
passthru.buildRootOnly = mkWithAttrs buildRootOnlyAttrs;
|
||||
|
||||
meta = {
|
||||
description = "Unicode and globalization support library with Apple customizations";
|
||||
license = [ lib.licenses.icu ];
|
||||
maintainers = lib.teams.darwin.members;
|
||||
platforms = lib.platforms.darwin;
|
||||
pkgConfigModules = [
|
||||
"icu-i18n"
|
||||
"icu-io"
|
||||
"icu-uc"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
realAttrs = self: super: {
|
||||
outputs = [
|
||||
"out"
|
||||
"dev"
|
||||
] ++ lib.optional withStatic "static";
|
||||
outputBin = "dev";
|
||||
|
||||
postPatch = lib.optionalString self.finalPackage.doCheck ''
|
||||
# Skip test for missing encodingSamples data.
|
||||
substituteInPlace test/cintltst/ucsdetst.c \
|
||||
--replace-fail "&TestMailFilterCSS" "NULL"
|
||||
|
||||
# Disable failing tests
|
||||
substituteInPlace test/cintltst/cloctst.c \
|
||||
--replace-fail 'TESTCASE(TestCanonicalForm);' ""
|
||||
|
||||
substituteInPlace test/intltest/rbbitst.cpp \
|
||||
--replace-fail 'TESTCASE_AUTO(TestExternalBreakEngineWithFakeYue);' ""
|
||||
'';
|
||||
|
||||
# remove dependency on bootstrap-tools in early stdenv build
|
||||
postInstall =
|
||||
lib.optionalString withStatic ''
|
||||
mkdir -p $static/lib
|
||||
mv -v lib/*.a $static/lib
|
||||
''
|
||||
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
sed -i 's/INSTALL_CMD=.*install/INSTALL_CMD=install/' $out/lib/icu/*/pkgdata.inc
|
||||
''
|
||||
+ (
|
||||
let
|
||||
replacements = [
|
||||
{
|
||||
from = "\${prefix}/include";
|
||||
to = "${placeholder "dev"}/include";
|
||||
} # --cppflags-searchpath
|
||||
{
|
||||
from = "\${pkglibdir}/Makefile.inc";
|
||||
to = "${placeholder "dev"}/lib/icu/Makefile.inc";
|
||||
} # --incfile
|
||||
{
|
||||
from = "\${pkglibdir}/pkgdata.inc";
|
||||
to = "${placeholder "dev"}/lib/icu/pkgdata.inc";
|
||||
} # --incpkgdatafile
|
||||
];
|
||||
in
|
||||
''
|
||||
rm $out/share/icu/*/install-sh $out/share/icu/*/mkinstalldirs # Avoid having a runtime dependency on bash
|
||||
|
||||
substituteInPlace "$dev/bin/icu-config" \
|
||||
${lib.concatMapStringsSep " " (r: "--replace-fail '${r.from}' '${r.to}'") replacements}
|
||||
''
|
||||
# Create library with everything reexported to provide the same ABI as the system ICU.
|
||||
+ lib.optionalString stdenv.hostPlatform.isDarwin (
|
||||
if stdenv.hostPlatform.isStatic then
|
||||
''
|
||||
${stdenv.cc.targetPrefix}ar qL "$out/lib/libicucore.a" \
|
||||
"$out/lib/libicuuc.a" \
|
||||
"$out/lib/libicudata.a" \
|
||||
"$out/lib/libicui18n.a" \
|
||||
"$out/lib/libicuio.a"
|
||||
''
|
||||
else
|
||||
''
|
||||
icuVersion=$(basename "$out/share/icu/"*)
|
||||
${stdenv.cc.targetPrefix}clang -dynamiclib \
|
||||
-L "$out/lib" \
|
||||
-Wl,-reexport-licuuc \
|
||||
-Wl,-reexport-licudata \
|
||||
-Wl,-reexport-licui18n \
|
||||
-Wl,-reexport-licuio \
|
||||
-compatibility_version 1 \
|
||||
-current_version "$icuVersion" \
|
||||
-install_name "$out/lib/libicucore.A.dylib" \
|
||||
-o "$out/lib/libicucore.A.dylib"
|
||||
ln -s libicucore.A.dylib "$out/lib/libicucore.dylib"
|
||||
''
|
||||
)
|
||||
);
|
||||
|
||||
postFixup = ''moveToOutput lib/icu "$dev" '';
|
||||
|
||||
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
||||
|
||||
nativeCheckInputs = [ python3 ];
|
||||
|
||||
# Some tests use `log(name)`, which clang identifies as potentially insecure.
|
||||
checkFlags = [
|
||||
"CFLAGS+=-Wno-format-security"
|
||||
"CXXFLAGS+=-Wno-format-security"
|
||||
];
|
||||
checkTarget = "check";
|
||||
};
|
||||
|
||||
buildRootOnlyAttrs = self: super: {
|
||||
pname = "ICU-build-root";
|
||||
|
||||
preConfigure =
|
||||
super.preConfigure
|
||||
+ ''
|
||||
mkdir build
|
||||
cd build
|
||||
configureScript=../configure
|
||||
|
||||
# Apple’s customizations require building and linking additional files, which are handled via `Makefile.local`.
|
||||
# These need copied into the build environment to avoid link errors from not building them.
|
||||
mkdir common i18n
|
||||
cp ../common/Makefile.local common/Makefile.local
|
||||
cp ../i18n/Makefile.local i18n/Makefile.local
|
||||
'';
|
||||
|
||||
postBuild = ''
|
||||
cd ..
|
||||
mv build $out
|
||||
echo "Doing build-root only, exiting now" >&2
|
||||
exit 0
|
||||
'';
|
||||
};
|
||||
|
||||
mkWithAttrs = attrs: mkAppleDerivation (lib.extends attrs baseAttrs);
|
||||
in
|
||||
mkWithAttrs realAttrs
|
@ -1,7 +1,7 @@
|
||||
diff --git a/icuSources/test/cintltst/cmsgtst.c b/icuSources/test/cintltst/cmsgtst.c
|
||||
diff --git a/test/cintltst/cmsgtst.c b/test/cintltst/cmsgtst.c
|
||||
index cb328707..1073e6c1 100644
|
||||
--- a/icuSources/test/cintltst/cmsgtst.c
|
||||
+++ b/icuSources/test/cintltst/cmsgtst.c
|
||||
--- a/test/cintltst/cmsgtst.c
|
||||
+++ b/test/cintltst/cmsgtst.c
|
||||
@@ -231,7 +231,7 @@ static void MessageFormatTest( void )
|
||||
austrdup(result), austrdup(testResultStrings[i]) );
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
{
|
||||
CommonCrypto = applePackage' "CommonCrypto" "60178.40.2" "macos-11.0.1" "129gsxhhcxqycg0zjrdrz2ay4dv2ih1ckafqh33qrc499z8dam2p" {};
|
||||
Csu = applePackage' "Csu" "88" "macos-11.0.1" "1lzp9x8iv60c2h12q2s89nf49b5hvpqq4a9li44zr2fxszn8lqxh" {};
|
||||
ICU = applePackage' "ICU" "66108" "macos-11.0.1" "0mclizp99daihghqy2sgzjkid8i93dsn5pi8q9p7b3156chrhw57" {};
|
||||
ICU = callPackage ./ICU/package.nix { };
|
||||
Libc = applePackage' "Libc" "1439.40.11" "macos-11.0.1" "12k5sbz2k1pl839w2lk9iw414zzl50zdjzgq2x6bm20yjbfj69qm" {};
|
||||
Libinfo = applePackage' "Libinfo" "542.40.3" "macos-11.0.1" "18jvl7cdg64x6clhsfv5pbzxis2aldddpca5r81xqakrmi9mck80" {};
|
||||
Libnotify = applePackage' "Libnotify" "279.40.4" "macos-11.0.1" "1vr11s0c42ssjs29shy1m8rj008np7aswdzjpimsfzyav47jb6y7" {};
|
||||
|
@ -7,6 +7,10 @@
|
||||
"hash": "sha256-l8RI8aiin7ovZuoDh54thDmd/b502w+dtjN5ZoISZBg=",
|
||||
"version": "88"
|
||||
},
|
||||
"ICU": {
|
||||
"hash": "sha256-p3CYITMljHVuwijeYnUbKaIWp/xPC4/hg1G1lO6PlFU=",
|
||||
"version": "66108"
|
||||
},
|
||||
"adv_cmds": {
|
||||
"hash": "sha256-Ztp8ALWcviEpthoiY8ttWzGI8OcsLzsULjlqe8GIzw8=",
|
||||
"version": "163"
|
||||
|
Loading…
Reference in New Issue
Block a user