From cc74bc3fecd9d44d62ff162394cff02ad436a9cc Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Sun, 8 Jun 2014 16:00:43 +0200 Subject: build: generate and install zsh completion script --- old-makefile | 10 +++++++++- waftools/generators/sources.py | 13 +++++++++++++ wscript | 4 ++++ wscript_build.py | 6 ++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/old-makefile b/old-makefile index c4a4e76ba7..915bb08115 100644 --- a/old-makefile +++ b/old-makefile @@ -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: diff --git a/waftools/generators/sources.py b/waftools/generators/sources.py index 1248ad90b4..4516d0951a 100644 --- a/waftools/generators/sources.py +++ b/waftools/generators/sources.py @@ -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__ diff --git a/wscript b/wscript index 814acb102f..4c0b8fbaab 100644 --- a/wscript +++ b/wscript @@ -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', diff --git a/wscript_build.py b/wscript_build.py index c5063f38d3..6f574ced6e 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -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'] ) -- cgit v1.2.3