Commit d550023d authored by Rafaël Carré's avatar Rafaël Carré

Fix zsh completion generation

parent a3bdb881
......@@ -37,6 +37,7 @@ typedef std::pair<int, std::string> mcpair;
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc/vlc.h>
/* evil hack */
......@@ -44,8 +45,8 @@ typedef std::pair<int, std::string> mcpair;
#undef __BUILTIN__
#include <../src/modules/modules.h>
void ParseModules( libvlc_int_t *p_libvlc, mumap &mods, mcmap &mods2 );
void PrintModuleList( libvlc_int_t *p_libvlc, mumap &mods, mcmap &mods2 );
void ParseModules( mumap &mods, mcmap &mods2 );
void PrintModuleList( mumap &mods, mcmap &mods2 );
void ParseOption( module_config_t *p_item, mumap &mods, mcmap &mods2 );
void PrintOption( char *psz_option, char i_short, char *psz_exlusive,
char *psz_text, char *psz_longtext, char *psz_args );
......@@ -55,22 +56,19 @@ int main( int i_argc, const char **ppsz_argv )
mumap mods;
mcmap mods2;
/* Create a libvlc structure */
int i_ret = VLC_Create();
libvlc_int_t *p_libvlc;
if( i_ret < 0 )
{
return i_ret;
}
libvlc_exception_t ex;
libvlc_exception_init(&ex);
const char * const argv[] = { "vlc" };
libvlc_instance_t *p_libvlc_instance = libvlc_new(1, argv, &ex);
/* Initialize libvlc */
i_ret = VLC_Init( 0, i_argc, ppsz_argv );
if( i_ret < 0 )
if( !p_libvlc_instance || libvlc_exception_raised(&ex) )
{
VLC_Destroy( 0 );
return i_ret;
libvlc_exception_clear(&ex);
return 1;
}
p_libvlc = (libvlc_int_t*)vlc_object_get( i_ret );
printf("#compdef vlc\n\n"
"#This file is autogenerated by zsh.cpp\n"
......@@ -78,10 +76,10 @@ int main( int i_argc, const char **ppsz_argv )
"local context state line ret=1\n"
"local modules\n\n" );
PrintModuleList( p_libvlc, mods, mods2 );
PrintModuleList( mods, mods2 );
printf( "_arguments -S -s \\\n" );
ParseModules( p_libvlc, mods, mods2 );
ParseModules( mods, mods2 );
printf( " \"(--module)-p[print help on module]:print help on module:($modules)\"\\\n" );
printf( " \"(-p)--module[print help on module]:print help on module:($modules)\"\\\n" );
printf( " \"(--help)-h[print help]\"\\\n" );
......@@ -105,34 +103,26 @@ int main( int i_argc, const char **ppsz_argv )
printf( "return ret\n" );
/* Exit early since we did not release all the objects we used,
* but we don't care, our task is over */
return 0;
/* Finish the threads */
VLC_CleanUp( 0 );
/* Destroy the libvlc structure */
VLC_Destroy( 0 );
return i_ret;
libvlc_release( p_libvlc_instance );
return 0;
}
void ParseModules( libvlc_int_t *p_libvlc, mumap &mods, mcmap &mods2 )
void ParseModules( mumap &mods, mcmap &mods2 )
{
vlc_list_t *p_list = NULL;;
module_t **p_list;
module_t *p_module;
module_config_t *p_item;
int i_index;
int i_items;
size_t i_modules;
/* List the plugins */
p_list = vlc_list_find( p_libvlc, VLC_OBJECT_MODULE, FIND_ANYWHERE );
p_list = module_list_get(&i_modules);
if( !p_list ) return;
for( i_index = 0; i_index < p_list->i_count; i_index++ )
for( i_index = 0; i_index < i_modules; i_index++ )
{
p_module = (module_t *)p_list->p_values[i_index].p_object;
p_module = p_list[i_index];
/* Exclude empty plugins (submodules don't have config options, they
* are stored in the parent module) */
......@@ -163,21 +153,22 @@ void ParseModules( libvlc_int_t *p_libvlc, mumap &mods, mcmap &mods2 )
}
}
void PrintModuleList( libvlc_int_t *p_libvlc, mumap &mods, mcmap &mods2 )
void PrintModuleList( mumap &mods, mcmap &mods2 )
{
vlc_list_t *p_list = NULL;;
module_t **p_list = NULL;
module_t *p_module;
int i_index;
int i_items;
size_t i_modules;
/* List the plugins */
p_list = vlc_list_find( p_libvlc, VLC_OBJECT_MODULE, FIND_ANYWHERE );
p_list = module_list_get(&i_modules);
if( !p_list ) return;
printf( "modules=\"" );
for( i_index = 0; i_index < p_list->i_count; i_index++ )
for( i_index = 0; i_index < i_modules; i_index++ )
{
p_module = (module_t *)p_list->p_values[i_index].p_object;
p_module = p_list[i_index];
/* Exclude empty plugins (submodules don't have config options, they
* are stored in the parent module) */
......
......@@ -38,6 +38,13 @@ function find_libvlc {
return 1
}
function find_libvlccore {
for i in $BUILDDIR/src/.libs/libvlccore.$SUFFIX $BUILDDIR/src/libvlccore.$SUFFIX; do
test -e $i && LIBVLCCORE=$i && return 0
done
return 1
}
while test -z "$LIBVLC"; do
if ! find_libvlc; then
/bin/echo -n "Please enter the directory where you built vlc: "
......@@ -47,6 +54,10 @@ done
echo "libvlc found !"
if ! find_libvlccore; then
/bin/echo -n "libvlccore not found ! Linking will fail !"
fi
LD_LIBRARY_PATH=$BUILDDIR/src/.libs
if test -e ../../extras/contrib/config.mak -a ! "`grep HOST ../../extras/contrib/config.mak 2>/dev/null|awk '{print $3}'`" != "$HOST"; then
......@@ -58,7 +69,7 @@ if test -z "$CXX"; then
CXX=g++
fi
ZSH_BUILD="$CXX $CPPFLAGS $CXXFLAGS -D__LIBVLC__ -DHAVE_CONFIG_H -I$BUILDDIR -I$BUILDDIR/include -I../../include zsh.cpp $LIBVLC -o zsh_gen"
ZSH_BUILD="$CXX $CPPFLAGS $CXXFLAGS -D__LIBVLC__ -DHAVE_CONFIG_H -I$BUILDDIR -I$BUILDDIR/include -I../../include zsh.cpp $LIBVLC $LIBVLCCORE -o zsh_gen"
echo "Building zsh completion generator ... "
echo $ZSH_BUILD
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment