about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2018-07-21 17:04:20 -0400
committerGitHub <noreply@github.com>2018-07-21 17:04:20 -0400
commit916f096911162ea4c85f3fb2eed5af8785abf925 (patch)
tree6d1a37cd15afb34dff9cb416ea99a39392ad513d
parente975814b19ba8cb8052a60f18de2ee4aebe1190b (diff)
parentb98b4eac71cfb0ccedc6d909fd58058bc1cb85e7 (diff)
downloadnixlib-916f096911162ea4c85f3fb2eed5af8785abf925.tar
nixlib-916f096911162ea4c85f3fb2eed5af8785abf925.tar.gz
nixlib-916f096911162ea4c85f3fb2eed5af8785abf925.tar.bz2
nixlib-916f096911162ea4c85f3fb2eed5af8785abf925.tar.lz
nixlib-916f096911162ea4c85f3fb2eed5af8785abf925.tar.xz
nixlib-916f096911162ea4c85f3fb2eed5af8785abf925.tar.zst
nixlib-916f096911162ea4c85f3fb2eed5af8785abf925.zip
Merge pull request #43890 from matthewbauer/mingw-fixes
Mingw fixes
-rw-r--r--pkgs/data/fonts/dejavu-fonts/default.nix2
-rw-r--r--pkgs/development/libraries/libxml2/default.nix2
-rw-r--r--pkgs/development/libraries/libxslt/default.nix2
-rw-r--r--pkgs/development/libraries/ncurses/default.nix6
-rw-r--r--pkgs/development/libraries/openssl/default.nix4
-rw-r--r--pkgs/os-specific/windows/libgnurx/default.nix11
-rw-r--r--pkgs/test/cross/default.nix80
-rw-r--r--pkgs/test/default.nix2
-rw-r--r--pkgs/tools/misc/file/default.nix7
-rw-r--r--pkgs/top-level/all-packages.nix6
10 files changed, 114 insertions, 8 deletions
diff --git a/pkgs/data/fonts/dejavu-fonts/default.nix b/pkgs/data/fonts/dejavu-fonts/default.nix
index 251654e2d58d..fa877ea6ed53 100644
--- a/pkgs/data/fonts/dejavu-fonts/default.nix
+++ b/pkgs/data/fonts/dejavu-fonts/default.nix
@@ -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 {
diff --git a/pkgs/development/libraries/libxml2/default.nix b/pkgs/development/libraries/libxml2/default.nix
index 51c142a81119..b28f241d56ee 100644
--- a/pkgs/development/libraries/libxml2/default.nix
+++ b/pkgs/development/libraries/libxml2/default.nix
@@ -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 ];
   };
 }
diff --git a/pkgs/development/libraries/libxslt/default.nix b/pkgs/development/libraries/libxslt/default.nix
index 5b6fdb462c2c..4dfdea582a25 100644
--- a/pkgs/development/libraries/libxslt/default.nix
+++ b/pkgs/development/libraries/libxslt/default.nix
@@ -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 ];
   };
 }
diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
index cf478837b86d..042c09fd8644 100644
--- a/pkgs/development/libraries/ncurses/default.nix
+++ b/pkgs/development/libraries/ncurses/default.nix
@@ -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";
diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index b4b932f8d058..b5b9ae766465 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -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
diff --git a/pkgs/os-specific/windows/libgnurx/default.nix b/pkgs/os-specific/windows/libgnurx/default.nix
new file mode 100644
index 000000000000..f50a0d9f503e
--- /dev/null
+++ b/pkgs/os-specific/windows/libgnurx/default.nix
@@ -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";
+  };
+}
diff --git a/pkgs/test/cross/default.nix b/pkgs/test/cross/default.nix
new file mode 100644
index 000000000000..6f41447ca76a
--- /dev/null
+++ b/pkgs/test/cross/default.nix
@@ -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 doesn’t 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
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix
index 38f6cb8e564e..d2e8e1c7314b 100644
--- a/pkgs/test/default.nix
+++ b/pkgs/test/default.nix
@@ -23,4 +23,6 @@ with pkgs;
   cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };
 
   macOSSierraShared = callPackage ./macos-sierra-shared {};
+
+  cross = callPackage ./cross {};
 }
diff --git a/pkgs/tools/misc/file/default.nix b/pkgs/tools/misc/file/default.nix
index aeb43d7c1151..485f46d03144 100644
--- a/pkgs/tools/misc/file/default.nix
+++ b/pkgs/tools/misc/file/default.nix
@@ -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;
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index c3ef7da594c6..849648d78402 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -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 { };