From 2459bee8af264b7f8e2740c065fcc63c205e833f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Nohales?= Date: Mon, 22 Sep 2014 13:53:57 -0300 Subject: [PATCH] intltool: add style option to intltool_in This allow to user to get abstracted about the passed intltool-merge flags, so this code: bld( features = 'intltool_in', flags = ['-d', '-q', '-u'], source = 'myapp.desktop.in', ) Now is equivalent to: bld( features = 'intltool_in', style = 'desktop', source = 'myapp.desktop.in', ) --- demos/intltool/data/wscript | 4 ++-- waflib/Tools/intltool.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/demos/intltool/data/wscript b/demos/intltool/data/wscript index a147f21f..1ddcece5 100644 --- a/demos/intltool/data/wscript +++ b/demos/intltool/data/wscript @@ -14,7 +14,7 @@ def build(bld): bld( features = "intltool_in", podir = "../po", - flags = ["-d", "-q", "-u"], + style = "desktop", source = 'kupfer.desktop.in', target = 'kupfer.desktop', install_path = "${DATADIR}/applications", @@ -23,7 +23,7 @@ def build(bld): bld( features = "intltool_in", podir = "../po", - flags = ["-x", "-q", "-u"], + style = "xml", source = 'kupfer-mimetypes.xml.in', target = 'kupfer-mimetypes.xml', install_path = "${DATADIR}/mime/packages/", diff --git a/waflib/Tools/intltool.py b/waflib/Tools/intltool.py index fa7c2eeb..928e647d 100644 --- a/waflib/Tools/intltool.py +++ b/waflib/Tools/intltool.py @@ -18,7 +18,8 @@ Usage:: bld( features = "intltool_in", podir = "../po", - flags = ["-d", "-q", "-u"], + style = "desktop", + flags = ["-u"], source = 'kupfer.desktop.in', install_path = "${DATADIR}/applications", ) @@ -33,6 +34,17 @@ from waflib.TaskGen import feature, before_method, taskgen_method from waflib.Logs import error from waflib.Configure import conf +_style_flags = { + 'ba': '-b', + 'desktop': '-d', + 'keys': '-k', + 'quoted': '--quoted-style', + 'quotedxml': '--quotedxml-style', + 'rfc822deb': '-r', + 'schemas': '-s', + 'xml': '-x', +} + @taskgen_method def ensure_localedir(self): # use the tool gnu_dirs to provide options to define this @@ -52,7 +64,8 @@ def apply_intltool_in_f(self): bld( features = "intltool_in", podir = "../po", - flags = ["-d", "-q", "-u"], + style = "desktop", + flags = ["-u"], source = 'kupfer.desktop.in', install_path = "${DATADIR}/applications", ) @@ -61,6 +74,10 @@ def apply_intltool_in_f(self): :type podir: string :param source: source files to process :type source: list of string + :param style: the intltool-merge mode of operation, can be one of the following values: + ``ba``, ``desktop``, ``keys``, ``quoted``, ``quotedxml``, ``rfc822deb``, ``schemas`` and ``xml``. + See the ``intltool-merge`` man page for more information about supported modes of operation. + :type style: string :param flags: compilation flags ("-quc" by default) :type flags: list of string :param install_path: installation path @@ -85,6 +102,16 @@ def apply_intltool_in_f(self): Logs.warn('Redundant -c flag in intltool task %r' % self) self.env.INTLFLAGS.remove('-c') + style = getattr(self, 'style', None) + if style: + try: + style_flag = _style_flags[style] + except KeyError: + self.bld.fatal('intltool_in style "%s" is not valid' % style) + + if style_flag not in self.env.INTLFLAGS: + self.env.append_value('INTLFLAGS', [style_flag]) + for i in self.to_list(self.source): node = self.path.find_resource(i)