From 176af2c8c33e79732680ebb1e2a25b5cd7a51bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Wed, 25 Jul 2018 18:26:07 +0200 Subject: [PATCH] i18n: respect variable substitution for the target name when merging translations Previously it wasn't possible to use twice @BASENAME@ as the targets would then be named @BASENAME@_merge --- mesonbuild/modules/i18n.py | 14 +++++++++++- .../frameworks/6 gettext/data/meson.build | 22 ++++++++++++++++++- .../6 gettext/data/test2.desktop.in | 6 +++++ .../frameworks/6 gettext/installed_files.txt | 2 ++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 test cases/frameworks/6 gettext/data/test2.desktop.in diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py index b44fbea5f..40f73f7ff 100644 --- a/mesonbuild/modules/i18n.py +++ b/mesonbuild/modules/i18n.py @@ -80,7 +80,19 @@ class I18nModule(ExtensionModule): command.append(datadirs) kwargs['command'] = command - ct = build.CustomTarget(kwargs['output'] + '_merge', state.subdir, state.subproject, kwargs) + + inputfile = kwargs['input'] + if isinstance(inputfile, str): + inputfile = mesonlib.File.from_source_file(state.environment.source_dir, + state.subdir, inputfile) + output = kwargs['output'] + ifile_abs = inputfile.absolute_path(state.environment.source_dir, + state.environment.build_dir) + values = mesonlib.get_filenames_templates_dict([ifile_abs], None) + outputs = mesonlib.substitute_values([output], values) + output = outputs[0] + + ct = build.CustomTarget(output + '_merge', state.subdir, state.subproject, kwargs) return ModuleReturnValue(ct, [ct]) @FeatureNewKwargs('i18n.gettext', '0.37.0', ['preset']) diff --git a/test cases/frameworks/6 gettext/data/meson.build b/test cases/frameworks/6 gettext/data/meson.build index d927ba3af..a6b0a8b08 100644 --- a/test cases/frameworks/6 gettext/data/meson.build +++ b/test cases/frameworks/6 gettext/data/meson.build @@ -1,6 +1,26 @@ +# Use filename substitution i18n.merge_file( input: 'test.desktop.in', - output: 'test.desktop', + output: '@BASENAME@', + type: 'desktop', + po_dir: '../po', + install: true, + install_dir: join_paths(get_option('datadir'), 'applications') +) + +# Use filename substitution for another file +i18n.merge_file( + input: 'test2.desktop.in', + output: '@BASENAME@', + type: 'desktop', + po_dir: '../po', + install: true, + install_dir: join_paths(get_option('datadir'), 'applications') +) + +i18n.merge_file( + input: 'test.desktop.in', + output: 'test3.desktop', type: 'desktop', po_dir: '../po', install: true, diff --git a/test cases/frameworks/6 gettext/data/test2.desktop.in b/test cases/frameworks/6 gettext/data/test2.desktop.in new file mode 100644 index 000000000..41f931c36 --- /dev/null +++ b/test cases/frameworks/6 gettext/data/test2.desktop.in @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=Test 2 +GenericName=Application +Comment=Test Application +Type=Application + diff --git a/test cases/frameworks/6 gettext/installed_files.txt b/test cases/frameworks/6 gettext/installed_files.txt index 879f56bc5..929890912 100644 --- a/test cases/frameworks/6 gettext/installed_files.txt +++ b/test cases/frameworks/6 gettext/installed_files.txt @@ -2,3 +2,5 @@ usr/bin/intlprog?exe usr/share/locale/de/LC_MESSAGES/intltest.mo usr/share/locale/fi/LC_MESSAGES/intltest.mo usr/share/applications/test.desktop +usr/share/applications/test2.desktop +usr/share/applications/test3.desktop