[x264-devel] Add Windows resource file

Henrik Gramner git at videolan.org
Sat Feb 4 21:10:48 CET 2012


x264 | branch: master | Henrik Gramner <hengar-6 at student.ltu.se> | Sat Jan 28 21:38:27 2012 +0100| [a2925c5a707e833c34fa0a64d497c02e6dcfe6e6] | committer: Jason Garrett-Glaser

Add Windows resource file
Displays version info in Windows Explorer.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=a2925c5a707e833c34fa0a64d497c02e6dcfe6e6
---

 Makefile   |   26 ++++++++++++++------
 configure  |   31 +++++++++++++++++++++++
 version.sh |    7 ++++-
 x264res.rc |   78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 132 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 51c40e3..ca2daae 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,10 @@ vpath %.c $(SRCPATH)
 vpath %.h $(SRCPATH)
 vpath %.S $(SRCPATH)
 vpath %.asm $(SRCPATH)
+vpath %.rc $(SRCPATH)
 
 all: default
+default:
 
 SRCS = common/mc.c common/predict.c common/pixel.c common/macroblock.c \
        common/frame.c common/dct.c common/cpu.c common/cabac.c \
@@ -26,6 +28,9 @@ SRCCLI = x264.c input/input.c input/timecode.c input/raw.c input/y4m.c \
          filters/video/select_every.c filters/video/crop.c filters/video/depth.c
 
 SRCSO =
+OBJS =
+OBJSO =
+OBJCLI =
 
 OBJCHK = tools/checkasm.o
 
@@ -131,21 +136,20 @@ ifneq ($(HAVE_GETOPT_LONG),1)
 SRCCLI += extras/getopt.c
 endif
 
-ifneq ($(SONAME),)
 ifeq ($(SYS),WINDOWS)
-SRCSO += x264dll.c
+OBJCLI += $(if $(RC), x264res.o)
+ifneq ($(SONAME),)
+SRCSO  += x264dll.c
+OBJSO  += $(if $(RC), x264res.dll.o)
 endif
 endif
 
-OBJS = $(SRCS:%.c=%.o)
-OBJCLI = $(SRCCLI:%.c=%.o)
-OBJSO = $(SRCSO:%.c=%.o)
-DEP  = depend
+OBJS   += $(SRCS:%.c=%.o)
+OBJCLI += $(SRCCLI:%.c=%.o)
+OBJSO  += $(SRCSO:%.c=%.o)
 
 .PHONY: all default fprofiled clean distclean install uninstall lib-static lib-shared cli install-lib-dev install-lib-static install-lib-shared install-cli
 
-default: $(DEP)
-
 cli: x264$(EXE)
 lib-static: $(LIBX264)
 lib-shared: $(SONAME)
@@ -180,6 +184,12 @@ $(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK): .depend
 	$(AS) $(ASFLAGS) -o $@ $<
 	-@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile
 
+%.dll.o: %.rc x264.h
+	$(RC) -DDLL -o $@ $<
+
+%.o: %.rc x264.h
+	$(RC) -o $@ $<
+
 .depend: config.mak
 	@rm -f .depend
 	@$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%.o) $(DEPMM) 1>> .depend;)
diff --git a/configure b/configure
index 5c58f5a..a86bd1c 100755
--- a/configure
+++ b/configure
@@ -200,6 +200,28 @@ as_check() {
     return $res
 }
 
+rc_check() {
+    log_check "whether $RC works"
+    echo "$1" > conftest.rc
+    if $RC conftest.rc -o conftest.o >conftest.log 2>&1; then
+        res=$?
+        log_ok
+    else
+        res=$?
+        log_fail
+        log_msg "Failed commandline was:"
+        log_msg "--------------------------------------------------"
+        log_msg "$RC conftest.rc -o conftest.o"
+        cat conftest.log >> config.log
+        log_msg "--------------------------------------------------"
+        log_msg "Failed program was:"
+        log_msg "--------------------------------------------------"
+        cat conftest.rc >> config.log
+        log_msg "--------------------------------------------------"
+    fi
+    return $res
+}
+
 define() {
     echo "#define $1$([ -n "$2" ] && echo " $2" || echo " 1")" >> config.h
 }
@@ -606,6 +628,14 @@ case $host_cpu in
         ;;
 esac
 
+RC=""
+if [ $SYS = WINDOWS ]; then
+    RC="${cross_prefix}windres"
+    if ! rc_check "0 RCDATA {0}" ; then
+        RC=""
+    fi
+fi
+
 log_msg "x264 configure script"
 if [ -n "$*" ]; then
     msg="Command line options:"
@@ -1021,6 +1051,7 @@ RANLIB=$RANLIB
 STRIP=$STRIP
 AS=$AS
 ASFLAGS=$ASFLAGS
+RC=$RC
 EXE=$EXE
 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
 DEVNULL=$DEVNULL
diff --git a/version.sh b/version.sh
index 9a415c6..5466ef2 100755
--- a/version.sh
+++ b/version.sh
@@ -4,8 +4,11 @@ git rev-list HEAD | sort > config.git-hash
 LOCALVER=`wc -l config.git-hash | awk '{print $1}'`
 if [ $LOCALVER \> 1 ] ; then
     VER=`git rev-list origin/master | sort | join config.git-hash - | wc -l | awk '{print $1}'`
-    if [ $VER != $LOCALVER ] ; then
-        VER="$VER+$(($LOCALVER-$VER))"
+    VER_DIFF=$(($LOCALVER-$VER))
+    echo "#define X264_REV $VER"
+    echo "#define X264_REV_DIFF $VER_DIFF"
+    if [ $VER_DIFF != 0 ] ; then
+        VER="$VER+$VER_DIFF"
     fi
     if git status | grep -q "modified:" ; then
         VER="${VER}M"
diff --git a/x264res.rc b/x264res.rc
new file mode 100644
index 0000000..4762be5
--- /dev/null
+++ b/x264res.rc
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * x264res.rc: windows resource file
+ *****************************************************************************
+ * Copyright (C) 2012 x264 project
+ *
+ * Authors: Henrik Gramner <hengar-6 at student.ltu.se>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing at x264.com.
+ *****************************************************************************/
+
+#include <windows.h>
+#include <stdint.h>
+#include "x264.h"
+
+#ifndef X264_REV
+#define X264_REV 0
+#define X264_REV_DIFF 0
+#endif
+
+#define str(s) #s
+#define xstr(s) str(s)
+
+VS_VERSION_INFO VERSIONINFO
+FILEVERSION     0, X264_BUILD, X264_REV, X264_REV_DIFF
+PRODUCTVERSION  0, X264_BUILD, X264_REV, X264_REV_DIFF
+FILEFLAGSMASK   VS_FFI_FILEFLAGSMASK
+FILEFLAGS       0
+FILEOS          VOS_NT_WINDOWS32 /* Identical for x86-64 */
+#ifdef DLL
+FILETYPE        VFT_DLL
+#else
+FILETYPE        VFT_APP
+#endif
+FILESUBTYPE     VFT2_UNKNOWN
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904E4"
+        BEGIN
+            VALUE "CompanyName",      "x264 project"
+#ifdef DLL
+            VALUE "FileDescription",  "H.264 (MPEG-4 AVC) encoder library"
+#else
+            VALUE "FileDescription",  "H.264 (MPEG-4 AVC) encoder"
+#endif
+            VALUE "FileVersion",      X264_POINTVER
+            VALUE "InternalName",     "x264"
+            VALUE "LegalCopyright",   "Copyright (C) 2003-2012 x264 project"
+#ifdef DLL
+            VALUE "OriginalFilename", "libx264-" xstr(X264_BUILD) ".dll"
+#else
+            VALUE "OriginalFilename", "x264.exe"
+#endif
+            VALUE "ProductName",      "x264"
+            VALUE "ProductVersion",   X264_POINTVER
+        END
+    END
+
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x0409, 0x04E4
+    END
+END



More information about the x264-devel mailing list