gen-rc 4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
#!/bin/sh
#
# Copyright (c) 2012 James Almer
# Copyright (c) 2013 Tiancheng "Timothy" Gu
#
# This file is part of FFmpeg.
#
# FFmpeg is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# FFmpeg 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

## Help
die() {
    cat <<EOF >&2
This script is used to generate Windows resources file for the FFmpeg libraries.
The output .rc file is to be compiled by windres(1). It is mainly useful for
FFmpeg developers to tweak and regenerate all resources files at once.

Usage: $0 <libname> <comment>

The script will output the file to '<libname>/<libname-without-lib>res.rc'.

Example: $0 libavcodec 'FFmpeg codecs library'
EOF
    exit 1
}

# Script to generate all:
# (to remove prefix '# ' and add 'tools/' as prefix: sed -r 's/^.{2}/tools\//')
# gen-rc libavutil     "FFmpeg utility library"
# gen-rc libavcodec    "FFmpeg codec library"
# gen-rc libavformat   "FFmpeg container format library"
# gen-rc libavdevice   "FFmpeg device handling library"
# gen-rc libavfilter   "FFmpeg audio/video filtering library"
# gen-rc libpostproc   "FFmpeg postprocessing library"
# gen-rc libavresample "Libav audio resampling library"
# gen-rc libswscale    "FFmpeg image rescaling library"
# gen-rc libswresample "FFmpeg audio resampling library"

## Sanity checks and argument parsing
if test $# -lt 2 || test $# -gt 3; then
    die
fi

name=$1
shortname=${name#lib}
comment=$2
capname=`echo $name | awk '{print toupper($0)}'`
version=${capname}_VERSION

mkdir -p "$name"
output="$name/${shortname}res.rc"

## REAL magic
cat <<EOF > $output
/*
 * Windows resource file for $name
 *
 * Copyright (C) 2012 James Almer
 * Copyright (C) 2013 Tiancheng "Timothy" Gu
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include <windows.h>
#include "$name/version.h"
#include "libavutil/ffversion.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 "040904B0"
        {
            VALUE "CompanyName",      "FFmpeg Project"
            VALUE "FileDescription",  "$comment"
            VALUE "FileVersion",      AV_STRINGIFY($version)
            VALUE "InternalName",     "$name"
            VALUE "LegalCopyright",   "Copyright (C) 2000-" AV_STRINGIFY(CONFIG_THIS_YEAR) " FFmpeg Project"
            VALUE "OriginalFilename", "$shortname" BUILDSUF "-" AV_STRINGIFY(${version}_MAJOR) SLIBSUF
            VALUE "ProductName",      "FFmpeg"
            VALUE "ProductVersion",   FFMPEG_VERSION
        }
    }

    BLOCK "VarFileInfo"
    {
        VALUE "Translation", 0x0409, 0x04B0
    }
}
EOF