Parse gettext command and generate rule.

pull/15/head
Jussi Pakkanen 11 years ago
parent 7006c6aa2c
commit 3c3e580aea
  1. 12
      backends.py
  2. 1
      build.py
  3. 15
      interpreter.py
  4. 3
      test cases/frameworks/6 gettext/po/meson.build

@ -503,7 +503,17 @@ class NinjaBackend(Backend):
ninja_quote(self.environment.get_build_dir()))
outfile.write(" command = '%s' '%s' '%s' '%s' --backend ninja secret-handshake\n" % c)
outfile.write(' description = Regenerating build files\n')
outfile.write(' generator = 1\n\n')
outfile.write(' generator = 1\n')
if len(self.build.pot) > 0:
self.generate_gettext_rules(outfile)
outfile.write('\n')
def generate_gettext_rules(self, outfile):
rule = 'rule GEN_POT\n'
command = " command = xgettext -p '$OUTDIR' -D '%s' -k_ -o '$OUTFILE'\n" % \
self.environment.get_source_dir()
outfile.write(rule)
outfile.write(command)
def generate_static_link_rules(self, is_cross, outfile):
if is_cross:

@ -31,6 +31,7 @@ class Build:
self.static_linker = None
self.static_cross_linker = None
self.configure_files = []
self.pot = []
def add_compiler(self, compiler):
if len(self.compilers) == 0:

@ -881,6 +881,7 @@ class Interpreter():
'find_library' : self.func_find_library,
'configuration_data' : self.func_configuration_data,
'run_command' : self.func_run_command,
'gettext' : self.func_gettext,
}
def get_build_def_files(self):
@ -981,6 +982,20 @@ class Interpreter():
raise InterpreterObject('Run_command arguments must be strings.')
return RunProcess(args, os.path.join(self.environment.source_dir, self.subdir))
def func_gettext(self, nodes, args, kwargs):
if len(args) != 1:
raise InterpreterException('Gettext requires one positional argument (package name).')
packagename = args[0]
if not isinstance(packagename, str):
raise InterpreterException('Gettext argument is not a string.')
languages = kwargs.get('languages', None)
if not isinstance(languages, list):
raise InterpreterException('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 definitions currently not supported.')
self.build.pot.append((packagename, languages))
def func_configuration_data(self, node, args, kwargs):
if len(args) != 0:
raise InterpreterException('configuration_data takes no arguments')

@ -1,5 +1,4 @@
langs = ['fi', 'de']
gettext('intltest',
languages : langs,
dirs : '../src')
languages : langs)

Loading…
Cancel
Save