icu: Fix cross-building.

The icu4c cross-build process requires access to a full buildRoot of a
native build, so we add a variant of the build that just does the
buildPhase and copies the buildRoot to $out for access by the cross
compile.
This commit is contained in:
Shea Levy 2018-02-24 08:02:06 -05:00
parent 39ccb6ac87
commit 7142440d75
No known key found for this signature in database
GPG key ID: 5C0BD6957D86FE27
2 changed files with 99 additions and 66 deletions

View file

@ -1,25 +1,19 @@
{ version, sha256, patches ? [], patchFlags ? "" }:
{ stdenv, fetchurl, fetchpatch, fixDarwinDylibNames }:
{ stdenv, fetchurl, fetchpatch, fixDarwinDylibNames
# Cross-compiled icu4c requires a build-root of a native compile
, buildRootOnly ? false, nativeBuildRoot, buildPlatform, hostPlatform
}:
let
pname = "icu4c";
in
stdenv.mkDerivation {
name = pname + "-" + version;
baseAttrs = {
src = fetchurl {
url = "http://download.icu-project.org/files/${pname}/${version}/${pname}-"
+ (stdenv.lib.replaceChars ["."] ["_"] version) + "-src.tgz";
inherit sha256;
};
outputs = [ "out" "dev" ];
outputBin = "dev";
# FIXME: This fixes dylib references in the dylibs themselves, but
# not in the programs in $out/bin.
buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
postUnpack = ''
sourceRoot=''${sourceRoot}/source
echo Source root reset to ''${sourceRoot}
@ -43,7 +37,28 @@ stdenv.mkDerivation {
'';
configureFlags = "--disable-debug" +
stdenv.lib.optionalString (stdenv.isFreeBSD || stdenv.isDarwin) " --enable-rpath";
stdenv.lib.optionalString (stdenv.isFreeBSD || stdenv.isDarwin) " --enable-rpath" +
stdenv.lib.optionalString (buildPlatform != hostPlatform) " --with-cross-build=${nativeBuildRoot}";
enableParallelBuilding = true;
meta = with stdenv.lib; {
description = "Unicode and globalization support library";
homepage = http://site.icu-project.org/;
maintainers = with maintainers; [ raskin ];
platforms = platforms.all;
};
};
realAttrs = baseAttrs // {
name = pname + "-" + version;
outputs = [ "out" "dev" ];
outputBin = "dev";
# FIXME: This fixes dylib references in the dylibs themselves, but
# not in the programs in $out/bin.
buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
# remove dependency on bootstrap-tools in early stdenv build
postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
@ -54,13 +69,27 @@ stdenv.mkDerivation {
'';
postFixup = ''moveToOutput lib/icu "$dev" '';
enableParallelBuilding = true;
meta = with stdenv.lib; {
description = "Unicode and globalization support library";
homepage = http://site.icu-project.org/;
maintainers = with maintainers; [ raskin ];
platforms = platforms.all;
};
}
buildRootOnlyAttrs = baseAttrs // {
name = pname + "-build-root-" + version;
preConfigure = baseAttrs.preConfigure + ''
mkdir build
cd build
configureScript=../configure
'';
postBuild = ''
cd ..
mv build $out
echo "Doing build-root only, exiting now" >&2
exit 0
'';
};
attrs = if buildRootOnly
then buildRootOnlyAttrs
else realAttrs;
in
stdenv.mkDerivation attrs

View file

@ -9210,16 +9210,20 @@ with pkgs;
hyena = callPackage ../development/libraries/hyena { };
icu58 = callPackage ../development/libraries/icu/58.nix
icu58 = callPackage ../development/libraries/icu/58.nix {
nativeBuildRoot = buildPackages.icu58.override { buildRootOnly = true; };
} //
(stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4'
});
icu59 = callPackage ../development/libraries/icu/59.nix
(stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
icu59 = callPackage ../development/libraries/icu/59.nix {
nativeBuildRoot = buildPackages.icu59.override { buildRootOnly = true; };
} // (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4'
});
icu60 = callPackage ../development/libraries/icu/60.nix
(stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
icu60 = callPackage ../development/libraries/icu/60.nix {
nativeBuildRoot = buildPackages.icu60.override { buildRootOnly = true; };
} // (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4'
});