On Mon, 13 Feb 2023 18:28:37 +0000
Jon Turney wrote:
> On 06/02/2023 13:53, Takashi Yano via Cygwin-apps wrote:
> > if [ ${all_codecs} = "yes" ]
> > then
> >     cat <<_EOF_  > ffmpeg-wchar.patch
> > --- origsrc/ffmpeg-5.1.2/libavcodec/mf_utils.h      2022-07-23 
> > 02:58:39.000000000 +0900
> > +++ src/ffmpeg-5.1.2/libavcodec/mf_utils.h  2023-01-26 12:33:12.745550400 
> > +0900
> > @@ -29,6 +29,7 @@
> >   // mf*.h headers below indirectly include strmif.h.)
> >   #include <icodecapi.h>
> >   #else
> > +#include <wchar.h>
> >   #define NO_DSHOW_STRSAFE
> >   #include <dshow.h>
> >   // Older versions of mingw-w64 need codecapi.h explicitly included, while 
> > newer
> > _EOF_
> >     PATCH_URI+=" ffmpeg-wchar.patch"
> > el
> 
> This seems an odd way to write this. If possible, just apply the patch 
> unconditionally (I assume it doesn't break all_codec=no builds), and 
> treat it normally (i.e. keep it next to the cygport, list it in 
> PATCH_URI, so it gets placed into the source package.)
> 
> If it's really necessary to only apply the patch in the all_codec=yes 
> case, use src_patch_apply_hook [1].
> 
> [1] 
> https://cygwin.github.io/cygport/src_prep_cygpart.html#src_patch_apply_hook
> 
> Otherwise, looks good.

Patching conditionally is necessary because the target file
is excluded from free-source tarball (ffmpeg_free_sources)
if all_codecs != "yes".

I revised the cygport file which uses src_patch_apply_hook()
as you recommended.

-- 
Takashi Yano <takashi.y...@nifty.ne.jp>
NAME="ffmpeg"
VERSION=5.1.2
RELEASE=1
CATEGORY="Audio Video"
SUMMARY="A complete solution to record, convert and stream audio and video."
DESCRIPTION="FFmpeg is the leading multimedia framework, able to decode, 
encode, transcode, mux, demux, stream and filter pretty much anything that 
humans and machines have created. It supports the most obscure ancient formats 
up to the cutting edge."
HOMEPAGE="https://ffmpeg.org/";
LICENSE="GPL-3.0-or-later"
SRC_URI="
        http://ffmpeg.org/releases/${NAME}-${VERSION}.tar.xz
        ffmpeg_free_sources
        enable_decoders
        enable_encoders"
PATCH_URI="
        
https://src.fedoraproject.org/rpms/ffmpeg/raw/rawhide/f/ffmpeg-codec-choice.patch
        
https://src.fedoraproject.org/rpms/ffmpeg/raw/rawhide/f/ffmpeg-new-coder-errors.patch
        
https://src.fedoraproject.org/rpms/ffmpeg/raw/rawhide/f/ffmpeg-allow-fdk-aac-free.patch
        
https://src.fedoraproject.org/rpms/ffmpeg/raw/rawhide/f/ffmpeg-dlopen-openh264.patch
        ffmpeg-wchar.patch
"

all_codecs="no" # Set to "yes" if you want to enable all codecs.

CYGPORT_USE_UNSTABLE_API=1
src_patch_apply_hook() {
        if [ "$1" != "ffmpeg-wchar.patch" -o ${all_codecs} = "yes" ]
        then
                return 0 # apply patch
        else
                echo "$1 will be skipped because all_codecs is 
\"${all_codecs}\"."
                return 1 # skip patch
        fi
}

src_unpack_hook() {
        rm -f libavcodec/libopenh264_dlopen.{c,h}
        if [ ${all_codecs} = "yes" ]
        then
                # restore original sources
                pushd ..
                pushd ../..
                rm ${NAME}-${VERSION}.tar.xz
                wget http://ffmpeg.org/releases/${NAME}-${VERSION}.tar.xz
                popd
                tar xf ../../${NAME}-${VERSION}.tar.xz
                popd
        else
                # make tarball which has only free sources
                pushd ..
                free_sources=$(sed "s%^%${NAME}-${VERSION}/%" 
../../ffmpeg_free_sources)
                free_sources_tarball="../../${NAME}-${VERSION}.tar.xz"
                tar acf ${free_sources_tarball} ${free_sources}
                rm -rf ${NAME}-${VERSION}
                tar xf ${free_sources_tarball}
                popd
        fi
}

PKG_NAMES="ffmpeg libffmpeg5 libffmpeg-devel ffmpeg-doc"
ffmpeg_CONTENTS="--exclude=usr/share/ffmpeg/examples usr/bin/*.exe 
usr/share/ffmpeg usr/share/man/man1"
libffmpeg5_CATEGORY="Audio Video Libs"
libffmpeg5_SUMMARY="FFmpeg runtime libraries."
libffmpeg5_CONTENTS="usr/bin/*.dll"
libffmpeg_devel_CATEGORY="Audio Video Devel"
libffmpeg_devel_SUMMARY="FFmpeg development package."
libffmpeg_devel_CONTENTS="usr/include usr/lib usr/share/ffmpeg/examples 
usr/share/man/man3"
ffmpeg_doc_CATEGORY="Audio Video Doc"
ffmpeg_doc_SUMMARY="FFmpeg documentation"
ffmpeg_doc_CONTENTS="usr/share/doc"

conf_args="--prefix=/usr
                --enable-pic
                --disable-stripping
                --enable-shared
                --disable-static
                --enable-gpl
                --enable-version3
                --disable-openssl
                --enable-bzlib
                --enable-gcrypt
                --enable-gnutls
                --enable-ladspa
                --disable-cuda-sdk
                --enable-libaom
                --enable-libass
                --enable-libbs2b
                --enable-libfdk-aac
                --enable-libfontconfig
                --enable-libfreetype
                --enable-libfribidi
                --enable-libgsm
                --enable-libmfx
                --enable-libmodplug
                --enable-libmp3lame
                --enable-libopenh264-dlopen
                --enable-libopenjpeg
                --enable-libopenmpt
                --enable-libopus
                --enable-libpulse
                --enable-librsvg
                --enable-libsnappy
                --enable-libsoxr
                --enable-libspeex
                --enable-libssh
                --enable-libtheora
                --enable-libtwolame
                --enable-libvorbis
                --enable-libvpx
                --enable-libwebp
                --enable-libxml2
                --enable-libxvid
                --enable-libzmq
                --enable-openal
                --enable-opencl
                --enable-opengl
                --enable-pthreads"

if [ ${all_codecs} = "yes" ]
then
        conf_args+="
                --pkg-config-flags=--static
                --enable-libx264
                --enable-libx265"
else
        conf_args+="
                --enable-muxers
                --enable-demuxers
                --enable-hwaccels
                --disable-encoders
                --disable-decoders
                --disable-decoder=h264,hevc,vc1
                --enable-encoder=$(perl -pe 's{^(\w*).*}{$1,}gs' < 
enable_encoders)
                --enable-decoder=$(perl -pe 's{^(\w*).*}{$1,}gs' < 
enable_decoders)"
fi

src_compile() {
        cd ${B}
        ${S}/configure ${conf_args}
        cygmake
}

BUILD_REQUIRES="libiconv-devel liblzma-devel libzstd-devel libbz2-devel 
libxcb-shm-devel libSDL2-devel libgnutls-devel ladspa-sdk cygwin-devel 
libass-devel libbs2b-devel libmp3lame-devel libopenjpeg-devel libopenmpt-devel 
librsvg2-devel libsnappy-devel libsoxr-devel speex-devel libssh-devel 
libtheora-devel libtwolame-devel libvorbis-devel libvpx-devel libwebp-devel 
libxml2-devel libzmq-devel libfribidi-devel libmodplug-devel libgsm-devel 
libopenjp2-devel libgcrypt-devel libfontconfig-devel libfreetype-devel 
libopenal-devel libOpenCL-devel libfdk-aac-devel xvidcore libopenh264-headers 
nv-codec-headers AMF libmfx-devel libaom-devel"

Reply via email to