i18n: Fix source root in Gettext targets for subprojects

Gettext should search for input files relative to the (sub)project
source root, not the global source root.

This change exposes a root_subdir member in ModuleState.
pull/10622/merge
David Ward 3 years ago committed by Eli Schwartz
parent 7eb5709bd9
commit 68add86f7b
  1. 1
      mesonbuild/modules/__init__.py
  2. 15
      mesonbuild/modules/i18n.py

@ -49,6 +49,7 @@ class ModuleState:
interpreter.environment.get_build_dir())
self.subproject = interpreter.subproject
self.subdir = interpreter.subdir
self.root_subdir = interpreter.root_subdir
self.current_lineno = interpreter.current_lineno
self.environment = interpreter.environment
self.project_name = interpreter.build.project_name

@ -256,10 +256,13 @@ class I18nModule(ExtensionModule):
extra_arg = '--extra-args=' + '@@'.join(extra_args) if extra_args else None
source_root = path.join(state.source_root, state.root_subdir)
subdir = path.relpath(state.subdir, start=state.root_subdir) if state.subdir else None
potargs = state.environment.get_build_command() + ['--internal', 'gettext', 'pot', pkg_arg]
potargs.append(f'--source-root={state.source_root}')
if state.subdir:
potargs.append(f'--subdir={state.subdir}')
potargs.append(f'--source-root={source_root}')
if subdir:
potargs.append(f'--subdir={subdir}')
if datadirs:
potargs.append(datadirs)
if extra_arg:
@ -302,9 +305,9 @@ class I18nModule(ExtensionModule):
targets.append(allgmotarget)
updatepoargs = state.environment.get_build_command() + ['--internal', 'gettext', 'update_po', pkg_arg]
updatepoargs.append(f'--source-root={state.source_root}')
if state.subdir:
updatepoargs.append(f'--subdir={state.subdir}')
updatepoargs.append(f'--source-root={source_root}')
if subdir:
updatepoargs.append(f'--subdir={subdir}')
if lang_arg:
updatepoargs.append(lang_arg)
if datadirs:

Loading…
Cancel
Save