2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 09:57:15 +01:00

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',
    )
This commit is contained in:
Damián Nohales 2014-09-22 13:53:57 -03:00 committed by Thomas Nagy
parent 620dea5fb7
commit 2459bee8af
2 changed files with 31 additions and 4 deletions

View File

@ -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/",

View File

@ -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)