aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/ninjabackend.py22
-rw-r--r--mesonbuild/build.py6
-rw-r--r--mesonbuild/interpreter.py14
-rw-r--r--mesonbuild/modules/i18n.py29
-rw-r--r--test cases/frameworks/6 gettext/meson.build2
-rw-r--r--test cases/frameworks/6 gettext/po/intltest.pot4
-rw-r--r--test cases/frameworks/6 gettext/po/meson.build3
7 files changed, 55 insertions, 25 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 8e8fa42..2f2c70b 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -406,17 +406,16 @@ int dummy;
def generate_po(self, outfile):
for p in self.build.pot:
- (packagename, languages, subdir) = p
- input_file = os.path.join(subdir, 'POTFILES')
+ input_file = os.path.join(p.subdir, 'POTFILES')
elem = NinjaBuildElement(self.all_outputs, 'pot', 'GEN_POT', [])
- elem.add_item('PACKAGENAME', packagename)
- elem.add_item('OUTFILE', packagename + '.pot')
+ elem.add_item('PACKAGENAME', p.packagename)
+ elem.add_item('OUTFILE', p.packagename + '.pot')
elem.add_item('FILELIST', os.path.join(self.environment.get_source_dir(), input_file))
- elem.add_item('OUTDIR', os.path.join(self.environment.get_source_dir(), subdir))
+ elem.add_item('OUTDIR', os.path.join(self.environment.get_source_dir(), p.subdir))
elem.write(outfile)
- for l in languages:
- infile = os.path.join(self.environment.get_source_dir(), subdir, l + '.po')
- outfilename = os.path.join(subdir, l + '.gmo')
+ for l in p.languages:
+ infile = os.path.join(self.environment.get_source_dir(), p.subdir, l + '.po')
+ outfilename = os.path.join(p.subdir, l + '.gmo')
lelem = NinjaBuildElement(self.all_outputs, outfilename, 'GEN_GMO', infile)
lelem.add_item('INFILE', infile)
lelem.add_item('OUTFILE', outfilename)
@@ -482,11 +481,10 @@ int dummy;
def generate_po_install(self, d, elem):
for p in self.build.pot:
- (package_name, languages, subdir) = p
# FIXME: assumes only one po package per source
- d.po_package_name = package_name
- for lang in languages:
- rel_src = os.path.join(subdir, lang + '.gmo')
+ d.po_package_name = p.packagename
+ for lang in p.languages:
+ rel_src = os.path.join(p.subdir, lang + '.gmo')
src_file = os.path.join(self.environment.get_build_dir(), rel_src)
d.po.append((src_file, self.environment.coredata.get_builtin_option('localedir'), lang))
elem.add_dep(rel_src)
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 3f480e8..d064dd7 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1016,3 +1016,9 @@ class InstallScript:
def __init__(self, cmd_arr):
assert(isinstance(cmd_arr, list))
self.cmd_arr = cmd_arr
+
+class PoInfo():
+ def __init__(self, packagename, languages, subdir):
+ self.packagename = packagename
+ self.languages = languages
+ self.subdir = subdir
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index ef6f3c1..88d4efb 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1039,6 +1039,10 @@ class Interpreter():
self.build.install_scripts.append(v)
elif isinstance(v, build.Data):
self.build.data.append(v)
+ elif isinstance(v, build.PoInfo):
+ if len(self.build.pot) > 0:
+ raise coredata.MesonException('More than one gettext definition currently not supported.')
+ self.build.pot.append(v)
else:
print(v)
raise InterpreterException('Module returned a value of unknown type.')
@@ -1269,15 +1273,7 @@ class Interpreter():
@stringArgs
def func_gettext(self, nodes, args, kwargs):
- if len(args) != 1:
- raise InterpreterException('Gettext requires one positional argument (package name).')
- packagename = args[0]
- languages = kwargs.get('languages', None)
- check_stringlist(languages, 'Argument languages must be a list of strings.')
- # TODO: check that elements are strings
- if len(self.build.pot) > 0:
- raise InterpreterException('More than one gettext definition currently not supported.')
- self.build.pot.append((packagename, languages, self.subdir))
+ raise InterpreterException('Gettext() function has been moved to module i18n. Import it and use i18n.gettext() instead')
def func_option(self, nodes, args, kwargs):
raise InterpreterException('Tried to call option() in build description file. All options must be in the option file.')
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
new file mode 100644
index 0000000..1467e7d
--- /dev/null
+++ b/mesonbuild/modules/i18n.py
@@ -0,0 +1,29 @@
+# Copyright 2016 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .. import coredata, mesonlib, build
+
+class I18nModule:
+
+ def gettext(self, state, args, kwargs):
+ if len(args) != 1:
+ raise coredata.MesonException('Gettext requires one positional argument (package name).')
+ packagename = args[0]
+ languages = mesonlib.stringlistify(kwargs.get('languages', []))
+ if len(languages) == 0:
+ raise coredata.MesonException('List of languages empty.')
+ return build.PoInfo(packagename, languages, state.subdir)
+
+def initialize():
+ return I18nModule()
diff --git a/test cases/frameworks/6 gettext/meson.build b/test cases/frameworks/6 gettext/meson.build
index 4384978..6bba7e0 100644
--- a/test cases/frameworks/6 gettext/meson.build
+++ b/test cases/frameworks/6 gettext/meson.build
@@ -1,4 +1,6 @@
project('gettext example', 'c')
+i18n = import('i18n')
+
subdir('po')
subdir('src')
diff --git a/test cases/frameworks/6 gettext/po/intltest.pot b/test cases/frameworks/6 gettext/po/intltest.pot
index 05da67d..d65e2c1 100644
--- a/test cases/frameworks/6 gettext/po/intltest.pot
+++ b/test cases/frameworks/6 gettext/po/intltest.pot
@@ -1,6 +1,6 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
+# This file is distributed under the same license as the intltest package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: intltest\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-09-12 19:04+0300\n"
+"POT-Creation-Date: 2016-03-28 19:59+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/test cases/frameworks/6 gettext/po/meson.build b/test cases/frameworks/6 gettext/po/meson.build
index 3376c84..8ea2c11 100644
--- a/test cases/frameworks/6 gettext/po/meson.build
+++ b/test cases/frameworks/6 gettext/po/meson.build
@@ -1,4 +1,3 @@
langs = ['fi', 'de']
-gettext('intltest',
-languages : langs)
+i18n.gettext('intltest', languages : langs)