Merge pull request #43890 from matthewbauer/mingw-fixes

Mingw fixes
This commit is contained in:
Matthew Bauer 2018-07-21 17:04:20 -04:00 committed by GitHub
commit 916f096911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 114 additions and 8 deletions

View File

@ -20,7 +20,7 @@ let
# See http://dejavu-fonts.org/wiki/License for details
license = stdenv.lib.licenses.free;
platforms = stdenv.lib.platforms.unix;
platforms = stdenv.lib.platforms.all;
};
full-ttf = stdenv.mkDerivation {

View File

@ -70,7 +70,7 @@ in stdenv.mkDerivation rec {
homepage = http://xmlsoft.org/;
description = "An XML parsing library for C";
license = lib.licenses.mit;
platforms = lib.platforms.unix;
platforms = lib.platforms.all;
maintainers = [ lib.maintainers.eelco ];
};
}

View File

@ -59,7 +59,7 @@ stdenv.mkDerivation rec {
homepage = http://xmlsoft.org/XSLT/;
description = "A C library and tools to do XSL transformations";
license = licenses.mit;
platforms = platforms.unix;
platforms = platforms.all;
maintainers = [ maintainers.eelco ];
};
}

View File

@ -34,7 +34,11 @@ stdenv.mkDerivation rec {
] ++ lib.optional unicode "--enable-widec"
++ lib.optional enableStatic "--enable-static"
++ lib.optional (!withCxx) "--without-cxx"
++ lib.optional (abiVersion == "5") "--with-abi-version=5";
++ lib.optional (abiVersion == "5") "--with-abi-version=5"
++ lib.optionals hostPlatform.isWindows [
"--enable-sp-funcs"
"--enable-term-driver"
];
# Only the C compiler, and explicitly not C++ compiler needs this flag on solaris:
CFLAGS = lib.optionalString stdenv.isSunOS "-D_XOPEN_SOURCE_EXTENDED";

View File

@ -44,7 +44,9 @@ let
if hostPlatform == buildPlatform
then "./config"
else if hostPlatform.isMinGW
then "./Configure mingw${toString hostPlatform.parsed.cpu.bits}"
then "./Configure mingw${optionalString
(hostPlatform.parsed.cpu.bits != 32)
(toString hostPlatform.parsed.cpu.bits)}"
else if hostPlatform.isLinux
then "./Configure linux-generic${toString hostPlatform.parsed.cpu.bits}"
else if hostPlatform.isiOS

View File

@ -0,0 +1,11 @@
{ stdenv, fetchurl }:
let
version = "2.5.1";
in stdenv.mkDerivation rec {
name = "libgnurx-${version}";
src = fetchurl {
url = "mirror://sourceforge/mingw/Other/UserContributed/regex/mingw-regex-${version}/mingw-${name}-src.tar.gz";
sha256 = "0xjxcxgws3bblybw5zsp9a4naz2v5bs1k3mk8dw00ggc0vwbfivi";
};
}

View File

@ -0,0 +1,80 @@
{ pkgs, pkgsCross, lib }:
let
emulators = {
mingw32 = "WINEDEBUG=-all ${pkgs.winePackages.minimal}/bin/wine";
mingwW64 = "WINEDEBUG=-all ${pkgs.wineWowPackages.minimal}/bin/wine";
# TODO: add some qemu-based emulaltors here
};
getExecutable = pkgs: pkgFun: exec:
"${pkgFun pkgs}${exec}${pkgs.hostPlatform.extensions.executable}";
compareTest = { emulator, pkgFun, hostPkgs, crossPkgs, exec, args ? [] }: let
pkgName = (pkgFun hostPkgs).name;
args' = lib.concatStringsSep " " args;
in pkgs.runCommand "test-${pkgName}-${crossPkgs.hostPlatform.config}" {
nativeBuildInputs = [ pkgs.dos2unix ];
} ''
HOME=$(pwd)
mkdir -p $out
# We need to remove whitespace, unfortunately
# Windows programs use \r but Unix programs use \n
# find expected value natively
${getExecutable hostPkgs pkgFun exec} ${args'} \
| dos2unix > $out/expected
# run emulator to get actual value
${emulator} ${getExecutable crossPkgs pkgFun exec} ${args'} \
| dos2unix > $out/actual
if [ "$(cat $out/actual)" != "$(cat $out/expected)" ]; then
echo "${pkgName} did not output expected value:"
cat $out/expected
echo "instead it output:"
cat $out/actual
exit 1
else
echo "${pkgName} test passed"
echo "both produced output:"
cat $out/actual
fi
'';
in
lib.mapAttrs (name: emulator: let
crossPkgs = pkgsCross.${name};
# Apply some transformation on windows to get dlls in the right
# place. Unfortunately mingw doesnt seem to be able to do linking
# properly.
platformFun = pkg: if crossPkgs.hostPlatform.isWindows then
pkgs.buildEnv {
name = "${pkg.name}-winlinks";
paths = [pkg] ++ pkg.buildInputs;
} else pkg;
in {
hello = compareTest {
inherit emulator crossPkgs;
hostPkgs = pkgs;
exec = "/bin/hello";
pkgFun = pkgs: pkgs.hello;
};
file = compareTest {
inherit emulator crossPkgs;
hostPkgs = pkgs;
exec = "/bin/file";
args = [
"${pkgs.file}/share/man/man1/file.1.gz"
"${pkgs.dejavu_fonts}/share/fonts/truetype/DejaVuMathTeXGyre.ttf"
];
pkgFun = pkgs: platformFun pkgs.file;
};
}) emulators

View File

@ -23,4 +23,6 @@ with pkgs;
cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };
macOSSierraShared = callPackage ./macos-sierra-shared {};
cross = callPackage ./cross {};
}

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, file, zlib }:
{ stdenv, fetchurl, file, zlib, libgnurx }:
stdenv.mkDerivation rec {
name = "file-${version}";
@ -13,10 +13,13 @@ stdenv.mkDerivation rec {
};
nativeBuildInputs = stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) file;
buildInputs = [ zlib ];
buildInputs = [ zlib ]
++ stdenv.lib.optional stdenv.hostPlatform.isWindows libgnurx;
doCheck = true;
makeFlags = if stdenv.hostPlatform.isWindows then "FILE_COMPILE=file"
else null;
meta = with stdenv.lib; {
homepage = http://darwinsys.com/file;

View File

@ -2387,7 +2387,9 @@ with pkgs;
figlet = callPackage ../tools/misc/figlet { };
file = callPackage ../tools/misc/file { };
file = callPackage ../tools/misc/file {
inherit (windows) libgnurx;
};
filegive = callPackage ../tools/networking/filegive { };
@ -14538,6 +14540,8 @@ with pkgs;
};
wxMSW = callPackage ../os-specific/windows/wxMSW-2.8 { };
libgnurx = callPackage ../os-specific/windows/libgnurx { };
};
wirelesstools = callPackage ../os-specific/linux/wireless-tools { };