Skip to content

Commit

Permalink
Merge pull request #217472 from AtnNn/7zz
Browse files Browse the repository at this point in the history
7zz: cross-compile for mingw
  • Loading branch information
flokli authored Feb 21, 2023
2 parents ff440ff + 045e8b3 commit 81e45cc
Show file tree
Hide file tree
Showing 2 changed files with 675 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pkgs/tools/archivers/7zz/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,22 @@ stdenv.mkDerivation rec {

sourceRoot = ".";

patches = [ ./fix-build-on-darwin.patch ];
patches = [
./fix-build-on-darwin.patch
./fix-cross-mingw-build.patch
];
patchFlags = [ "-p0" ];

postPatch = lib.optionalString stdenv.hostPlatform.isMinGW ''
substituteInPlace CPP/7zip/7zip_gcc.mak C/7zip_gcc_c.mak \
--replace windres.exe ${stdenv.cc.targetPrefix}windres
'';

NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [
"-Wno-deprecated-copy-dtor"
] ++ lib.optionals stdenv.hostPlatform.isMinGW [
"-Wno-conversion"
"-Wno-unused-macros"
];

inherit makefile;
Expand All @@ -73,7 +84,8 @@ stdenv.mkDerivation rec {
# aarch64-darwin so we don't need additional changes for it
++ lib.optionals stdenv.isDarwin [ "MACOSX_DEPLOYMENT_TARGET=10.16" ]
# it's the compression code with the restriction, see DOC/License.txt
++ lib.optionals (!enableUnfree) [ "DISABLE_RAR_COMPRESS=true" ];
++ lib.optionals (!enableUnfree) [ "DISABLE_RAR_COMPRESS=true" ]
++ lib.optionals (stdenv.hostPlatform.isMinGW) [ "IS_MINGW=1" "MSYSTEM=1" ];

nativeBuildInputs = lib.optionals useUasm [ uasm ];

Expand All @@ -84,7 +96,7 @@ stdenv.mkDerivation rec {
installPhase = ''
runHook preInstall
install -Dm555 -t $out/bin b/*/7zz
install -Dm555 -t $out/bin b/*/7zz${stdenv.hostPlatform.extensions.executable}
install -Dm444 -t $out/share/doc/${pname} ../../../../DOC/*.txt
runHook postInstall
Expand All @@ -109,7 +121,7 @@ stdenv.mkDerivation rec {
# the unRAR compression code is disabled by default
lib.optionals enableUnfree [ unfree ];
maintainers = with maintainers; [ anna328p peterhoeg jk ];
platforms = platforms.unix;
platforms = platforms.unix ++ platforms.windows;
mainProgram = "7zz";
};
}
Loading

0 comments on commit 81e45cc

Please sign in to comment.