Complete rewrite of vlc_symbols.h generation (closes #155)

New VLC_EXPORTs are now added at the end of module_symbols_t so that
offsets of other function pointers are preserved.

Deleted VLC_EXPORTs are replaced with dummy pointers for padding.

Of course, it doesn't solve the problem with changing shared structures
format :/ and it may cause SVN conflicts when multiple people changes
VLC_EXPORT. I doubt it can be avoided though.
This commit is contained in:
Rémi Denis-Courmont 2005-06-02 12:47:30 +00:00
parent cab6549141
commit 575c056a1c
8 changed files with 1295 additions and 97 deletions

View File

@ -23,6 +23,7 @@ EXTRA_DIST = \
bootstrap \
src/extras/COPYING \
toolbox \
vlc-api.pl \
vlc-config.in.in \
vlc.spec \
vlc.spec.mdk \
@ -45,9 +46,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects
BUILT_SOURCES += \
stamp-api \
include/vlc_symbols.h \
src/misc/modules_builtin.h \
src/misc/modules_plugin.h \
$(NULL)
pkgincludedir = $(includedir)/vlc
@ -63,7 +62,7 @@ dist_pkginclude_HEADERS = \
include/vlc/control.h \
$(NULL)
noinst_HEADERS = $(HEADERS_include) $(HEADERS_include_built)
noinst_HEADERS = $(HEADERS_include)
HEADERS_include = \
include/aout_internal.h \
@ -114,6 +113,7 @@ HEADERS_include = \
include/vlc_playlist.h \
include/vlc_spu.h \
include/vlc_stream.h \
include/vlc_symbols.h \
include/vlc_threads_funcs.h \
include/vlc_threads.h \
include/vlc_video.h \
@ -124,32 +124,12 @@ HEADERS_include = \
include/win32_specific.h \
$(NULL)
HEADERS_include_built = \
include/vlc_symbols.h \
$(NULL)
# Common dependencies for these 3 files : Makefile vlc-config
# Real specific dependencies :
#include/vlc_symbols.h: $(HEADERS_include)
#src/misc/modules_plugin.h: src/misc/modules_plugin.h.in $(HEADERS_include)
#src/misc/modules_builtin.h: src/misc/modules_builtin.h.in vlc-config
include/vlc_symbols.h:
srcdir=$(srcdir) $(srcdir)/toolbox --update-includes
# for some strange reasons (??) modules_plugin.h depends on vlc_symbols.h
# so we have to touch it :(
src/misc/modules_plugin.h: src/misc/modules_plugin.h.in
srcdir=$(srcdir) $(srcdir)/toolbox --update-includes
touch src/misc/modules_plugin.h
src/misc/modules_builtin.h: src/misc/modules_builtin.h.in
src/misc/modules_builtin.h: Makefile src/misc/modules_builtin.h.in vlc-config
srcdir=$(srcdir) $(srcdir)/toolbox --update-includes
touch $@
# These dependencies are mandatory
$(SOURCES): include/vlc_symbols.h
$(SOURCES_libvlc): src/misc/modules_plugin.h src/misc/modules_builtin.h $(LIB_intl)
$(SOURCES_libvlc): src/misc/modules_builtin.h $(LIB_intl)
###############################################################################
# Optional libintl - FIXME, bad dependencies
@ -285,7 +265,6 @@ CLEANFILES = $(BUILT_SOURCES)
lib_LIBRARIES = lib/libvlc.a $(LIBRARIES_libvlc_pic)
lib_libvlc_a_SOURCES = $(SOURCES_libvlc)
dist_lib_libvlc_a_SOURCES = src/misc/modules_plugin.h
lib_libvlc_a_CFLAGS = `$(VLC_CONFIG) --cflags vlc`
lib_libvlc_a_CXXFLAGS = `$(VLC_CONFIG) --cxxflags vlc`
lib_libvlc_a_OBJCFLAGS = `$(VLC_CONFIG) --objcflags vlc`
@ -939,8 +918,8 @@ stamp-builtin: FORCE
done
@if test ! -f $@; then printf "" > $@; fi
stamp-api: Makefile $(HEADERS_include) vlc-config src/misc/modules_plugin.h.in src/misc/modules_builtin.h.in
srcdir=$(srcdir) $(srcdir)/toolbox --update-includes
stamp-api: Makefile.in $(HEADERS_include) vlc-config vlc-api.pl src/misc/modules_builtin.h.in
cd $(srcdir) && cat $(HEADERS_include) | perl ./vlc-api.pl
touch stamp-api
###############################################################################

1101
include/vlc_symbols.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,2 @@
DIST_SUBDIRS = interface playlist input audio_output video_output stream_output misc
EXTRA_DIST = misc/modules_builtin.h.in misc/modules_plugin.h.in
EXTRA_DIST = misc/modules_builtin.h.in

View File

@ -107,10 +107,6 @@
#include "vlc_image.h"
#ifdef HAVE_DYNAMIC_PLUGINS
# include "modules_plugin.h"
#endif
#if defined( _MSC_VER ) && defined( UNDER_CE )
# include "modules_builtin_evc.h"
#elif defined( _MSC_VER )

View File

@ -1,26 +0,0 @@
/*****************************************************************************
* modules_plugin.h : Plugin management functions used by the core application.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* STORE_SYMBOLS: store known symbols into p_symbols for plugin access.
*****************************************************************************/

36
toolbox
View File

@ -403,44 +403,8 @@ then
if test -z "${builddir}"; then
builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
fi
mkdir -p "${builddir}/include"
LIBVLC_HEADERS=`getfiles HEADERS_include`
BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' vlc-config`
file="${builddir}/include/vlc_symbols.h"
rm -f ${file}.in
echo '/* DO NOT EDIT THIS FILE! See Makefile.am */' >> ${file}.in
echo 'struct module_symbols_t {' >> ${file}.in
cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ \1 (* \2_inner) \3;/' >> ${file}.in
echo '};' >> ${file}.in
echo '#ifdef __PLUGIN__' >> ${file}.in
cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/# define \2 p_symbols->\2_inner/' >> ${file}.in
echo '#endif /* __PLUGIN__ */' >> ${file}.in
if diff >/dev/null 2>&1 ${file} ${file}.in
then
rm -f ${file}.in
else
echo "creating new ${file}"
mv -f ${file}.in ${file}
fi
file="${builddir}/src/misc/modules_plugin.h"
rm -f ${file}.tmp
sed -e 's#.*\$[I][d]:.*# * Automatically generated from '${file}'.in by bootstrap#' < ${srcdir}/src/misc/modules_plugin.h.in > ${file}.tmp
echo '#define STORE_SYMBOLS( p_symbols ) \' >> ${file}.tmp
cat ${LIBVLC_HEADERS} | grep '^ *VLC_EXPORT.*;' | sed -e 's/VLC_EXPORT( *\([^,]*\), *\([^,]*\), *\(.*\));.*/ (p_symbols)->\2_inner = \2; \\/' >> ${file}.tmp
echo '' >> ${file}.tmp
if diff >/dev/null 2>&1 ${file} ${file}.tmp
then
rm -f ${file}.tmp
else
echo "creating new ${file}"
mv -f ${file}.tmp ${file}
fi
file="${builddir}/src/misc/modules_builtin.h"
rm -f ${file}.tmp && cp ${srcdir}/src/misc/modules_builtin.h.in ${file}.tmp

184
vlc-api.pl Executable file
View File

@ -0,0 +1,184 @@
#!/usr/bin/perl
#*****************************************************************************
#* vlc-api.pl: VLC API maintenance script
#*****************************************************************************
#* Copyright (C) 2005 VideoLAN
#* $Id$
#*
#* Authors: Rémi Denis-Courmont <rem # videolan.org>
#*
#* 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
#*****************************************************************************/
use strict;
#
# Reads to-be exported APIs
#
my %new_APIs;
while (<STDIN>)
{
if (/VLC_EXPORT\(\s*(\w.*\S)\s*,\s*(\w*)\s*,\s*\(\s*(\w.*\S)\s*\)\s*\)[^)]*$/)
{
$new_APIs{$2} = [ ( $1, $3 ) ];
}
}
#
# Write header's header
#
open my $new_sym, '> include/vlc_symbols.h.new' or die "$!";
print { $new_sym }
"/*\n".
" * This file is automatically generated. DO NOT EDIT!\n".
" * You can force an update with \"make stamp-api\".\n".
" */\n".
"\n".
"#ifndef __VLC_SYMBOLS_H\n".
"# define __VLC_SYMBOLS_H\n".
"\n".
"/*\n".
" * This is the big VLC API structure for plugins :\n".
" * Changing its layout breaks plugin's binary compatibility,\n".
" * so DO NOT DO THAT.\n".
" * In case of conflict with SVN, add your uncommited APIs\n".
" * at the *end* of the structure so they don't mess the other's\n".
" * offset in the structure.\n".
" */\n".
"struct module_symbols_t\n".
"{\n";
my $changes = 0;
#
# Compares new APIs with currently exported APIs
#
my @API;
my @deprecated_API;
open my $oldfd, '< include/vlc_symbols.h';
while (<$oldfd>)
{
if (/^ void \*(\w*)_deprecated;$/)
{
if (defined $new_APIs{$2})
{
print "[info] $2 was RESTORED!\n";
print { $new_sym }
" ".$new_APIs{$1}[0]." (*$1_inner) (".$new_APIs{$1}[1].");\n";
delete $new_APIs{$1};
push (@API, $1);
$changes++;
}
else
{
print { $new_sym } $_;
push (@deprecated_API, $1);
}
}
elsif (/^\s*(\w.*\S)\s*\(\*\s*(\w*)_inner\)\s*\(\s*(\w.*\S)\s*\)\s*;\s*$/)
{
if (!defined $new_APIs{$2})
{
print "[warn] $2 was REMOVED!\n";
print { $new_sym } " void *$2_deprecated;\n";
push (@deprecated_API, $2);
$changes++;
}
elsif (($new_APIs{$2}[0] ne $1)
|| ($new_APIs{$2}[1] ne $3))
{
print
"[warn] $2 was CHANGED!\n".
" Old argument(s) : \"$3\"\n".
" New argument(s) : \"".$new_APIs{$2}[1]."\"\n".
" Old return type : \"$1\"\n".
" New return type : \"".$new_APIs{$2}[0]."\"\n";
print { $new_sym }
" ".$new_APIs{$2}[0]." (*$2_inner) (".$new_APIs{$2}[1].");\n";
delete $new_APIs{$2};
push (@API, $2);
$changes++;
}
else
{
print { $new_sym } " $1 (*$2_inner) ($3);\n";
push (@API, $2);
delete $new_APIs{$2};
}
}
}
close $oldfd;
#
# Adds brand-new APIs
#
foreach (keys %new_APIs)
{
print "[info] $_ was ADDED!\n";
print { $new_sym }
" ".$new_APIs{$_}[0]." (*${_}_inner) (".$new_APIs{$_}[1].");\n";
push (@API, $_);
$changes++;
}
#
# Writes #defines
#
print { $new_sym }
"};\n".
"# if defined (__PLUGIN__)\n";
foreach (@API)
{
print { $new_sym } "# define $_ (p_symbols)->${_}_inner\n";
}
print { $new_sym }
"# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)\n".
"/******************************************************************\n".
" * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.\n".
" ******************************************************************/\n".
"# define STORE_SYMBOLS( p_symbols ) \\\n";
foreach (@API)
{
print { $new_sym } " ((p_symbols)->${_}_inner) = $_; \\\n";
}
foreach (@deprecated_API)
{
print { $new_sym } " (p_symbols)->${_}_deprecated = NULL; \\\n";
}
print { $new_sym }
"\n".
"# endif /* __PLUGIN__ */\n".
"#endif /* __VLC_SYMBOLS_H */\n";
close $new_sym;
#
# Replace headers if needed
#
if ($changes != 0)
{
rename 'include/vlc_symbols.h.new', 'include/vlc_symbols.h';
print "$changes API(s) changed.\n";
}
else
{
unlink 'include/vlc_symbols.h.new';
}

View File

@ -85,7 +85,7 @@ if test "${top_builddir}" != ""; then
elif test "${TOP_BUILDDIR}" != ""; then
top_builddir="${TOP_BUILDDIR}/"
fi
includes="${includes} -I${top_builddir}include"
includes="${includes}"
cppflags="${includes}"
libs="-L@libdir@"
module=""