Merge pull request #153863 from marius851000/ffmpegwin

ffmpeg-full: better support for cross-compilation to windows, add openh264
This commit is contained in:
Guillaume Girol 2022-02-02 21:28:12 +00:00 committed by GitHub
commit 7d682af240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 12 deletions

View File

@ -1,4 +1,4 @@
{ lib, stdenv, ffmpeg, addOpenGLRunpath, pkg-config, perl, texinfo, yasm
{ lib, stdenv, buildPackages, ffmpeg, addOpenGLRunpath, pkg-config, perl, texinfo, yasm
/*
* Licensing options (yes some are listed twice, filters and such are not listed)
*/
@ -107,7 +107,7 @@
, opencore-amr ? null # AMR-NB de/encoder & AMR-WB decoder
#, opencv ? null # Video filtering
, openglExtlib ? false, libGL ? null, libGLU ? null # OpenGL rendering
#, openh264 ? null # H.264/AVC encoder
, openh264 ? null # H.264/AVC encoder
, openjpeg ? null # JPEG 2000 de/encoder
, opensslExtlib ? false, openssl ? null
, libpulseaudio ? null # Pulseaudio input support
@ -164,7 +164,7 @@
*
* Not packaged:
* aacplus avisynth cdio-paranoia crystalhd libavc1394 libiec61883
* libnut libquvi nvenc opencl openh264 oss shine twolame
* libnut libquvi nvenc opencl oss shine twolame
* utvideo vo-aacenc vo-amrwbenc xvmc zvbi blackmagic-design-desktop-video
*
* Need fixes to support Darwin:
@ -260,7 +260,7 @@ stdenv.mkDerivation rec {
configurePlatforms = [];
configureFlags = [
"--target_os=${stdenv.hostPlatform.parsed.kernel.name}"
"--target_os=${if stdenv.hostPlatform.isMinGW then "mingw64" else stdenv.hostPlatform.parsed.kernel.name}" #mingw32 and mingw64 doesn't have a difference here, it is internally rewritten as mingw32
"--arch=${stdenv.hostPlatform.parsed.cpu.name}"
/*
* Licensing flags
@ -282,7 +282,7 @@ stdenv.mkDerivation rec {
(enableFeature hardcodedTablesBuild "hardcoded-tables")
(enableFeature safeBitstreamReaderBuild "safe-bitstream-reader")
(if multithreadBuild then (
if isCygwin then
if stdenv.hostPlatform.isWindows then
"--disable-pthreads --enable-w32threads"
else # Use POSIX threads by default
"--enable-pthreads --disable-w32threads")
@ -382,7 +382,7 @@ stdenv.mkDerivation rec {
(enableFeature (opencore-amr != null && version3Licensing) "libopencore-amrnb")
#(enableFeature (opencv != null) "libopencv")
(enableFeature openglExtlib "opengl")
#(enableFeature (openh264 != null) "openh264")
(enableFeature (openh264 != null) "libopenh264")
(enableFeature (openjpeg != null) "libopenjpeg")
(enableFeature (opensslExtlib && gplLicensing) "openssl")
(enableFeature (libpulseaudio != null) "libpulse")
@ -420,6 +420,7 @@ stdenv.mkDerivation rec {
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"--cross-prefix=${stdenv.cc.targetPrefix}"
"--enable-cross-compile"
"--host-cc=${buildPackages.stdenv.cc}/bin/cc"
] ++ optionals stdenv.cc.isClang [
"--cc=clang"
"--cxx=clang++"
@ -433,7 +434,7 @@ stdenv.mkDerivation rec {
libogg libopus librsvg libssh libtheora libvdpau libvorbis libvpx libwebp libX11
libxcb libXv libXext xz openal openjpeg libpulseaudio rav1e svt-av1 rtmpdump opencore-amr
samba SDL2 soxr speex srt vid-stab vo-amrwbenc x264 x265 xavs xvidcore
zeromq4 zimg zlib
zeromq4 zimg zlib openh264
] ++ optionals openglExtlib [ libGL libGLU ]
++ optionals nonfreeLicensing [ fdk_aac openssl ]
++ optional ((isLinux || isFreeBSD) && libva != null) libva

View File

@ -1,4 +1,4 @@
{ stdenv, lib, fetchurl, libiconv, xz }:
{ stdenv, lib, fetchurl, fetchpatch, libiconv, xz }:
# Note: this package is used for bootstrapping fetchurl, and thus
# cannot use fetchpatch! All mutable patches (generated by GitHub or
@ -15,7 +15,11 @@ stdenv.mkDerivation rec {
};
patches = [
./absolute-paths.diff
];
] ++ lib.optional stdenv.hostPlatform.isWindows (fetchpatch {
url = "https://aur.archlinux.org/cgit/aur.git/plain/gettext_formatstring-ruby.patch?h=mingw-w64-gettext&id=e8b577ee3d399518d005e33613f23363a7df07ee";
name = "gettext_formatstring-ruby.patch";
sha256 = "sha256-6SxZObOMkQDxuKJuJY+mQ/VuJJxSeGbf97J8ZZddCV0=";
});
outputs = [ "out" "man" "doc" "info" ];

View File

@ -93,6 +93,7 @@ stdenv.mkDerivation rec {
buildInputs = [
libelf setupHook pcre
] ++ optionals (!stdenv.hostPlatform.isWindows) [
bash gnum4 # install glib-gettextize and m4 macros for other apps to use
] ++ optionals stdenv.isLinux [
libselinux
@ -143,6 +144,9 @@ stdenv.mkDerivation rec {
patchShebangs glib/gen-unicode-tables.pl
patchShebangs tests/gen-casefold-txt.py
patchShebangs tests/gen-casemap-txt.py
'' + lib.optionalString stdenv.hostPlatform.isWindows ''
substituteInPlace gio/win32/meson.build \
--replace "libintl, " ""
'';
DETERMINISTIC_BUILD = 1;

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, nasm }:
{ lib, stdenv, fetchFromGitHub, nasm, windows }:
stdenv.mkDerivation rec {
pname = "openh264";
@ -13,10 +13,16 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ nasm ];
buildInputs = lib.optional stdenv.hostPlatform.isWindows windows.pthreads;
makeFlags = [
"PREFIX=${placeholder "out"}"
"ARCH=${stdenv.hostPlatform.linuxArch}"
];
] ++ lib.optional stdenv.hostPlatform.isWindows "OS=mingw_nt";
enableParallelBuilding = true;
hardeningDisable = lib.optional stdenv.hostPlatform.isWindows "stackprotector";
meta = with lib; {
description = "A codec library which supports H.264 encoding and decoding";

View File

@ -94,7 +94,8 @@ stdenv.mkDerivation {
# indeed GHC will refuse to compile with a binutils suffering from it. See
# this comment for more information:
# https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333
lib.optional (stdenv.targetPlatform.isAarch32 && stdenv.hostPlatform.system != stdenv.targetPlatform.system) ./R_ARM_COPY.patch;
lib.optional (stdenv.targetPlatform.isAarch32 && stdenv.hostPlatform.system != stdenv.targetPlatform.system) ./R_ARM_COPY.patch
++ lib.optional stdenv.targetPlatform.isWindows ./windres-locate-gcc.patch;
outputs = [ "out" "info" "man" ];

View File

@ -0,0 +1,19 @@
diff --git a/binutils/resrc.c b/binutils/resrc.c
index a875c3a4..0411d047 100644
--- a/binutils/resrc.c
+++ b/binutils/resrc.c
@@ -521,7 +521,13 @@ read_rc_file (const char *filename, const char *preprocessor,
cpp_pipe = 0;
- if (dash)
+ /* Nixpkgs specific : look first at the prefixed path
+ ( there should be no gcc in the binutils folder ) */
+ if (slash && dash) {
+ cpp_pipe = look_for_default(cmd, slash + 1, dash - slash, preprocargs, filename);
+ }
+
+ if (dash && ! cpp_pipe)
{
/* First, try looking for a prefixed gcc in the windres
directory, with the same prefix as windres */