[FFmpeg-devel] [PATCH] Add Windows resource file support for shared libraries
Timothy Gu
timothygu99 at gmail.com
Tue Nov 26 01:26:42 CET 2013
On Mon, Nov 25, 2013 at 2:06 PM, James Almer <jamrial at gmail.com> wrote:
> On 25/11/13 6:59 PM, Timothy Gu wrote:
>> Based on patch by: James Almer <jamrial at gmail.com>
>>
>> Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
>> ---
>>
>> Sorry if the older patch in the thread doesn't apply.
>>
>> ---
>>
>> Differences from James's version [1]:
>> * Now generate the .rc files from configure (like we do with pkg-config files).
>
> I'm not sure about this. They don't get installed, and having one .rc file per
> folder won't bother anyone, whereas the big generator function in configure will
> be a small nuisance with merges from libav.
> x264 and mplayer ship with the .rc files in the source tree and don't generate them
> either.
OK. How about adding this function as a standalone tool to tool/?
>
>> * Use descriptions of libraries from the pkg-config file generation function
>> * Use "FFmpeg Project" as CompanyName like Alexander suggested in the old thread
>> * Use "FFmpeg" for ProductName as MSDN says "name of the product with which the
>> file is distributed" [2].
>> * Use FFmpeg's version (N-xxxxx-gxxxxxxx) for ProductVersion per MSDN [2].
>>
>> [1] http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2012-September/131705.html
>> [2] http://msdn.microsoft.com/en-us/library/windows/desktop/aa381058.aspx
>
> I'm fine with the changes.
> Afterwards we should try to extend this to also cover the executables, like Gianluigi Tiesi
> did on his repo.
Yeah, I was trying to do that too. But one step at a time, right?
>
> Some comments below.
>
>>
>> ---
>> .gitignore | 1 +
>> Makefile | 3 ++-
>> common.mak | 9 +++++--
>> configure | 65 +++++++++++++++++++++++++++++++++++++++++++++++++-
>> libavcodec/Makefile | 3 +++
>> libavdevice/Makefile | 3 +++
>> libavfilter/Makefile | 3 +++
>> libavformat/Makefile | 3 +++
>> libavresample/Makefile | 3 +++
>> libavutil/Makefile | 3 +++
>> libpostproc/Makefile | 3 +++
>> library.mak | 2 +-
>> libswresample/Makefile | 3 +++
>> libswscale/Makefile | 3 +++
>> 14 files changed, 102 insertions(+), 5 deletions(-)
>>
>> diff --git a/.gitignore b/.gitignore
>> index 7d8adda..8a63efc 100644
>> --- a/.gitignore
>> +++ b/.gitignore
>> @@ -13,6 +13,7 @@
>> *.lib
>> *.pc
>> *.pdb
>> +*.rc
>> *.so
>> *.so.*
>> *.ver
>> diff --git a/Makefile b/Makefile
>> index 10202d0..53b8841 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -6,6 +6,7 @@ vpath %.cpp $(SRC_PATH)
>> vpath %.h $(SRC_PATH)
>> vpath %.S $(SRC_PATH)
>> vpath %.asm $(SRC_PATH)
>> +vpath %.rc $(SRC_PATH)
>> vpath %.v $(SRC_PATH)
>> vpath %.texi $(SRC_PATH)
>> vpath %/fate_config.sh.template $(SRC_PATH)
>> @@ -74,7 +75,7 @@ SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \
>> ALTIVEC-OBJS VIS-OBJS \
>> MMX-OBJS YASM-OBJS \
>> MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSPR1-OBJS MIPS32R2-OBJS \
>> - OBJS HOSTOBJS TESTOBJS
>> + OBJS SLIBOBJS HOSTOBJS TESTOBJS
>>
>> define RESET
>> $(1) :=
>> diff --git a/common.mak b/common.mak
>> index b22badd..0ddaaa5 100644
>> --- a/common.mak
>> +++ b/common.mak
>> @@ -10,7 +10,7 @@ ifndef SUBDIR
>> ifndef V
>> Q = @
>> ECHO = printf "$(1)\t%s\n" $(2)
>> -BRIEF = CC CXX HOSTCC HOSTLD AS YASM AR LD STRIP CP
>> +BRIEF = CC CXX HOSTCC HOSTLD AS YASM AR LD STRIP CP WINDRES
>> SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
>>
>> MSG = $@
>> @@ -56,6 +56,9 @@ COMPILE_S = $(call COMPILE,AS)
>> %.o: %.S
>> $(COMPILE_S)
>>
>> +%.o: %.rc
>> + $(WINDRES) $(IFLAGS) -o $@ $<
>> +
>> %.i: %.c
>> $(CC) $(CCFLAGS) $(CC_E) $<
>>
>> @@ -82,6 +85,7 @@ endif
>> include $(SRC_PATH)/arch.mak
>>
>> OBJS += $(OBJS-yes)
>> +SLIBOBJS += $(SLIBOBJS-yes)
>> FFLIBS := $(FFLIBS-yes) $(FFLIBS)
>> TESTPROGS += $(TESTPROGS-yes)
>>
>> @@ -90,6 +94,7 @@ FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
>>
>> EXAMPLES := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF))
>> OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
>> +SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
>> TESTOBJS := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
>> TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
>> HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
>> @@ -127,7 +132,7 @@ $(TOOLOBJS): | tools
>> OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(TESTOBJS))
>>
>> CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ho *.gcno *.gcda
>> -DISTCLEANSUFFIXES = *.pc
>> +DISTCLEANSUFFIXES = *.pc *.rc
>> LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
>>
>> define RULES
>> diff --git a/configure b/configure
>> index 6b0375b..b334898 100755
>> --- a/configure
>> +++ b/configure
>> @@ -267,6 +267,7 @@ Advanced options (experts only):
>> --nm=NM use nm tool NM [$nm_default]
>> --ar=AR use archive tool AR [$ar_default]
>> --as=AS use assembler AS [$as_default]
>> + --windres=WINDRES use windows resource compiler WINDRES [$windres_default]
>> --yasmexe=EXE use yasm-compatible assembler EXE [$yasmexe_default]
>> --cc=CC use C compiler CC [$cc_default]
>> --cxx=CXX use C compiler CXX [$cxx_default]
>> @@ -1478,6 +1479,7 @@ HAVE_LIST="
>> gettimeofday
>> glob
>> gnu_as
>> + gnu_windres
>> gsm_h
>> ibm_asm
>> inet_aton
>> @@ -2325,6 +2327,7 @@ pkg_config_default=pkg-config
>> ranlib="ranlib"
>> strip_default="strip"
>> yasmexe_default="yasm"
>> +windres_default="windres"
>>
>> nogas=":"
>>
>> @@ -2594,6 +2597,7 @@ nm_default="${cross_prefix}${nm_default}"
>> pkg_config_default="${cross_prefix}${pkg_config_default}"
>> ranlib="${cross_prefix}${ranlib}"
>> strip_default="${cross_prefix}${strip_default}"
>> +windres_default="${cross_prefix}${windres_default}"
>>
>> sysinclude_default="${sysroot}/usr/include"
>>
>> @@ -3112,7 +3116,7 @@ test -n "$cc_type" && enable $cc_type ||
>> : ${dep_cc_default:=$cc}
>> : ${ld_default:=$cc}
>> : ${host_ld_default:=$host_cc}
>> -set_default ar as dep_cc ld host_ld
>> +set_default ar as dep_cc ld host_ld windres
>>
>> probe_cc as "$as"
>> asflags_filter=$_flags_filter
>> @@ -3594,6 +3598,7 @@ case $target_os in
>> elif enabled arm; then
>> LIBTARGET=arm-wince
>> fi
>> + enabled shared && check_cmd $windres --version && enable gnu_windres
>> check_ldflags -Wl,--nxcompat
>> check_ldflags -Wl,--dynamicbase
>> shlibdir_default="$bindir_default"
>> @@ -3656,6 +3661,7 @@ case $target_os in
>> SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
>> objformat="win32"
>> enable dos_paths
>> + enabled shared && check_cmd $windres --version && enable gnu_windres
>> ;;
>> *-dos|freedos|opendos)
>> network_extralibs="-lsocket"
>> @@ -4831,6 +4837,7 @@ LD_O=$LD_O
>> LD_LIB=$LD_LIB
>> LD_PATH=$LD_PATH
>> DLLTOOL=$dlltool
>> +WINDRES=$windres
>> LDFLAGS=$LDFLAGS
>> SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
>> YASMFLAGS=$YASMFLAGS
>> @@ -4916,6 +4923,7 @@ cat > $TMPH <<EOF
>> #define av_restrict $_restrict
>> #define EXTERN_PREFIX "${extern_prefix}"
>> #define EXTERN_ASM ${extern_prefix}
>> +#define BUILDSUF "$build_suffix"
>> #define SLIBSUF "$SLIBSUF"
>> #define HAVE_MMX2 HAVE_MMXEXT
>> EOF
>> @@ -5016,6 +5024,51 @@ Cflags: -I\${includedir}
>> EOF
>> }
>>
>> +windres_generate(){
>> + enabled gnu_windres || return 0
>> + name=$1
>> + shortname=${name#lib}
>> + comment=$2
>> + capname=`echo $name | awk '{print toupper($0)}'`
>> + version=${capname}_VERSION
>> + enabled ${name#lib} || return 0
>> + mkdir -p $name
>> + cat <<EOF > $name/${shortname}res.rc
>> +#include <windows.h>
>> +#include "$name/version.h"
>> +#include "../version.h"
>> +#include "config.h"
>> +
>> +1 VERSIONINFO
>> +FILEVERSION ${version}_MAJOR, ${version}_MINOR, ${version}_MICRO, 0
>> +PRODUCTVERSION ${version}_MAJOR, ${version}_MINOR, ${version}_MICRO, 0
>> +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
>> +FILEOS VOS_NT_WINDOWS32
>> +FILETYPE VFT_DLL
>> +{
>> + BLOCK "StringFileInfo"
>> + {
>> + BLOCK "040904E4"
>
> 040904B0 might be better (04B0 = Unicode, 04E4 = multilingual).
Well, they are probably the same, but 0x04b0 seems more specific.
>
>> + {
>> + VALUE "CompanyName", "FFmpeg Project"
>> + VALUE "FileDescription", "$comment"
>> + VALUE "FileVersion", AV_STRINGIFY($version)
>> + VALUE "InternalName", "$name"
>> + VALUE "LegalCopyright", "Copyright (C) 2000-2013 FFmpeg Project"
>
> This is the one thing that left me unsatisfied back when i first wrote this patch.
> It would be nice if 2013 could be replaced with a variable to avoid having to update
> it every year.
> Maybe moving "const int this_year = 2013;" from cmdutils.c to some header, changing
> it into a define and including it from the .rc files.
[...]
Timothy
More information about the ffmpeg-devel
mailing list