summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlessandro Ghedini <alessandro@ghedini.me>2014-06-08 16:00:43 +0200
committerwm4 <wm4@nowhere>2014-06-08 20:48:42 +0200
commitcc74bc3fecd9d44d62ff162394cff02ad436a9cc (patch)
treeaef147eb40189cc07eda51ecdf775ad2c52c02d8
parentda27eceb85269f7fbe656e5d967936bcf33e1aa0 (diff)
downloadmpv-cc74bc3fecd9d44d62ff162394cff02ad436a9cc.tar.bz2
mpv-cc74bc3fecd9d44d62ff162394cff02ad436a9cc.tar.xz
build: generate and install zsh completion script
-rw-r--r--old-makefile10
-rw-r--r--waftools/generators/sources.py13
-rw-r--r--wscript4
-rw-r--r--wscript_build.py6
4 files changed, 32 insertions, 1 deletions
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
@@ -58,6 +58,10 @@ build_options = [
'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',
'deps': [ 'os-darwin' ],
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'] )