From: Rafaël Carré Date: Sat, 9 Feb 2008 18:19:40 +0000 (+0000) Subject: fix zsh completion generator, add a script to help compilation, generation, and insta... X-Git-Tag: 0.9.0-test0~2751 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=46d9645373e60a0d07b9fd5a9d3a38158e4fdf3d;p=vlc fix zsh completion generator, add a script to help compilation, generation, and installation of completion --- diff --git a/extras/analyser/Makefile b/extras/analyser/Makefile deleted file mode 100644 index 88383983fe..0000000000 --- a/extras/analyser/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -BUILDDIR ?= ../.. - -zsh: zsh.cpp - g++ ${CXXFLAGS} -I${BUILDDIR} -I${BUILDDIR}/include -I../include zsh.cpp ${BUILDDIR}/src/.libs/libvlc.so -o zsh `top_builddir=${BUILDDIR} ${BUILDDIR}/vlc-config vlc builtin --cflags --libs` diff --git a/extras/analyser/zsh.cpp b/extras/analyser/zsh.cpp index 04c516830d..77c0436d87 100644 --- a/extras/analyser/zsh.cpp +++ b/extras/analyser/zsh.cpp @@ -1,7 +1,7 @@ /***************************************************************************** * zsh.cpp: create zsh completion rule for vlc ***************************************************************************** - * Copyright (C) 2005 the VideoLAN team + * Copyright © 2005-2008 the VideoLAN team * $Id$ * * Authors: Sigmund Augdal Helberg @@ -70,7 +70,7 @@ int main( int i_argc, const char **ppsz_argv ) VLC_Destroy( 0 ); return i_ret; } - p_libvlc = (libvlc_int_t*)vlc_object_get( (vlc_object_t*)NULL, i_ret ); + p_libvlc = (libvlc_int_t*)vlc_object_get( i_ret ); printf("#compdef vlc\n\n" "#This file is autogenerated by zsh.cpp\n" @@ -105,7 +105,10 @@ 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 ); diff --git a/extras/analyser/zsh_completion.sh b/extras/analyser/zsh_completion.sh new file mode 100755 index 0000000000..b49afe0631 --- /dev/null +++ b/extras/analyser/zsh_completion.sh @@ -0,0 +1,106 @@ +#!/bin/sh +# Helper script to install zsh completion for VLC media player +# © 2008 Rafaël Carré + + +HOST=`gcc -dumpmachine` +case $HOST in + *darwin*) + SUFFIX=dylib + ;; + *cygwin*|*mingw*) + SUFFIX=dll + ;; + *linux*|*bsd*) + SUFFIX=so + ;; + *) + echo WARNING: Unknown platform: \'$HOST\' + ;; +esac + +if test -z "$SUFFIX"; then + echo "ERROR: unknown suffix for shared objects +Please run \"SUFFIX=xxx $0\" +where xxx is the shared object extension on your platform." + exit 1 +fi + +#Distributors can run BUILDDIR=XXX ./zsh_completion.sh +if test -z "$BUILDDIR"; then + BUILDDIR=../../ +fi + +function find_libvlc { + for i in $BUILDDIR/src/.libs/libvlc.$SUFFIX $BUILDDIR/src/libvlc.$SUFFIX; do + test -e $i && LIBVLC=$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: " + read BUILDDIR + fi +done + +echo "libvlc found !" + +if test -e ../../extras/contrib/config.mak -a ! "`grep HOST ../../extras/contrib/config.mak 2>/dev/null|awk '{print $3}'`" != "$HOST"; then + echo "contribs found !" + CPPFLAGS="-I../../extras/contrib/include" +fi + +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" + +echo "Building zsh completion generator ... +" +echo $ZSH_BUILD +echo +$ZSH_BUILD || exit 1 + +echo "Generating zsh completion ..." +if ! ./zsh_gen --plugin-path=$BUILDDIR >_vlc 2>/dev/null; then + echo "ERROR: the generation failed.... :( +Please press enter to verify that all the VLC modules are shown" + read i + ./zsh_gen --plugin-path=$BUILDDIR -vvv --list + echo " +If they are shown, press enter to see if you can debug the problem +It will be reproduced by running \"./zsh_gen --plugin-path=$BUILDDIR -vvv\"" + read i + ./zsh_gen --plugin-path=$BUILDDIR -vvv + exit 1 +fi + +echo "zsh completion is `echo \`wc -l _vlc\`` lines long !" + +test -z "$NOINSTALL" || exit 0 +#Distributors can run NOINSTALL=mg ./zsh_completion.sh + +if ! /usr/bin/which -s zsh; then + echo "ERROR: zsh not found, you'll have to copy the _vlc file manually" + exit 1 +fi + +test -z "$ZSH_FPATH" && ZSH_FPATH=`zsh -c "echo \\$fpath|cut -d\" \" -f1"` +if test -z "$ZSH_FPATH"; then + echo "ERROR: Could not find a directory where to install completion +Please run \"ZSH_FPATH=path $0\" +where path is the directory where you want to install completion" + exit 1 +fi + +echo "completion will be installed in $ZSH_FPATH , using root privileges +Press Ctrl+C to abort installation, and copy _vlc manually" +read i +echo "Installing completion ..." +sudo sh -c "chown 0:0 _vlc && chmod 0644 _vlc && mv _vlc $ZSH_FPATH" || exit 1 + +echo "zsh completion for VLC successfully installed :) +Restart running zsh instances, or run \"compinit\" to start using it."