build: generate and install zsh completion script

This commit is contained in:
Alessandro Ghedini 2014-06-08 16:00:43 +02:00 committed by wm4
parent da27eceb85
commit cc74bc3fec
4 changed files with 32 additions and 1 deletions

View File

@ -379,6 +379,9 @@ player/lua.c: player/lua/defaults.inc \
player/lua/osc.inc \
player/lua/options.inc
etc/_mpv: TOOLS/zsh.pl ./mpv
./$< > $@
# ./configure must be rerun if it changed
config.mak: configure
@echo "############################################################"
@ -450,12 +453,17 @@ install-mpv-config: etc/encoding-profiles.conf
$(INSTALL) -d $(CONFDIR)
$(INSTALL) -m 644 etc/encoding-profiles.conf $(CONFDIR)
install-data: install-mpv-icons install-mpv-desktop install-mpv-config
install-mpv-zsh: etc/_mpv
$(INSTALL) -d $(prefix)/share/zsh/vendor-completions
$(INSTALL) -m 644 etc/_mpv $(prefix)/share/zsh/vendor-completions/
install-data: install-mpv-icons install-mpv-desktop install-mpv-config install-mpv-zsh
uninstall:
$(RM) $(BINDIR)/mpv
$(RM) $(MANDIR)/man1/mpv.1 $(MANDIR)/en/man1/mpv.1
$(RM) $(prefix)/share/applications/mpv.desktop
$(RM) $(prefix)/share/zsh/vendor-completions/_mpv
$(RM) $(foreach size,$(ICONSIZES),$(prefix)/share/icons/hicolor/$(size)/apps/mpv.png)
clean:

View File

@ -9,6 +9,10 @@ def __matroska_cmd__(ctx, argument):
return "${{BIN_PERL}} {0}/TOOLS/matroska.pl {1} ${{SRC}} > ${{TGT}}" \
.format(ctx.srcnode.abspath(), argument)
def __zshcomp_cmd__(ctx, argument):
return "${{BIN_PERL}} {0}/TOOLS/zsh.pl {1} > ${{TGT}}" \
.format(ctx.srcnode.abspath(), argument)
def __file2string__(ctx, **kwargs):
ctx(
rule = __file2string_cmd__(ctx),
@ -32,6 +36,15 @@ def __matroska_definitions__(ctx, **kwargs):
**kwargs
)
def __zshcomp__(ctx, **kwargs):
ctx(
rule = __zshcomp_cmd__(ctx, './mpv'),
before = ("c",),
name = os.path.basename(kwargs['target']),
**kwargs
)
BuildContext.file2string = __file2string__
BuildContext.matroska_header = __matroska_header__
BuildContext.matroska_definitions = __matroska_definitions__
BuildContext.zshcomp = __zshcomp__

View File

@ -57,6 +57,10 @@ build_options = [
'deps': [ 'dlopen' ],
'default': 'disable',
'func': check_true
}, {
'name': '--zsh-comp',
'desc': 'zsh completion',
'func': check_true,
}, {
'name': '--macosx-bundle',
'desc': 'compilation of a Mac OS X Application bundle',

View File

@ -524,6 +524,12 @@ def build(ctx):
if ctx.dependency_satisfied('pdf-build'):
_build_pdf(ctx)
if ctx.dependency_satisfied('zsh-comp'):
ctx.zshcomp(target = "etc/_mpv")
ctx.install_files(
ctx.env.DATADIR + '/zsh/vendor-completions',
['etc/_mpv'])
ctx.install_files(
ctx.env.DATADIR + '/applications',
['etc/mpv.desktop'] )