Skip to content

Commit

Permalink
i18n module: Invoke itstool with the full command line
Browse files Browse the repository at this point in the history
Certain envs may not support invoking itstool by itself directly as a script
as shebang lines are not supported, such as under cmd.exe shells on Windows,
that are normally used for Visual Studio (and the like, such as clang-cl)
builds.

This will call the corresponding interpreter to invoke itstool when needed, so
that itstool can be properly run, even if shebang lines are not supported by
the env.

This will fix building appstream on Windows using clang-cl, for instance.
  • Loading branch information
fanc999-1 authored and eli-schwartz committed Oct 26, 2023
1 parent e9e098b commit ada6236
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mesonbuild/modules/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from __future__ import annotations

from os import path
import shlex
import typing as T

from . import ExtensionModule, ModuleReturnValue, ModuleInfo
Expand Down Expand Up @@ -360,11 +361,14 @@ def itstool_join(self, state: 'ModuleState', args: T.List['TYPE_var'], kwargs: '
command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget,
build.CustomTargetIndex, 'ExternalProgram', mesonlib.File]] = []
command.extend(state.environment.get_build_command())

itstool_cmd = self.tools['itstool'].get_command()
# TODO: python 3.8 can use shlex.join()
command.extend([
'--internal', 'itstool', 'join',
'-i', '@INPUT@',
'-o', '@OUTPUT@',
'--itstool=' + self.tools['itstool'].get_path(),
'--itstool=' + ' '.join(shlex.quote(c) for c in itstool_cmd),
])
if its_files:
for fname in its_files:
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/scripts/itstool.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import argparse
import subprocess
import tempfile
import shlex
import shutil
import typing as T

Expand Down Expand Up @@ -56,7 +57,7 @@ def run_join(build_dir: str, itstool: str, its_files: T.List[str], mo_files: T.L
shutil.copy(mo_file, tmp_mo_fname)
locale_mo_files.append(tmp_mo_fname)

cmd = [itstool]
cmd = shlex.split(itstool)
if its_files:
for fname in its_files:
cmd.extend(['-i', fname])
Expand Down

0 comments on commit ada6236

Please sign in to comment.