i18n module: Invoke itstool with the full command line
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.
This commit is contained in:
parent
e9e098b73e
commit
ada6236f76
|
@ -14,6 +14,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
|
import shlex
|
||||||
import typing as T
|
import typing as T
|
||||||
|
|
||||||
from . import ExtensionModule, ModuleReturnValue, ModuleInfo
|
from . import ExtensionModule, ModuleReturnValue, ModuleInfo
|
||||||
|
@ -360,11 +361,14 @@ class I18nModule(ExtensionModule):
|
||||||
command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget,
|
command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget,
|
||||||
build.CustomTargetIndex, 'ExternalProgram', mesonlib.File]] = []
|
build.CustomTargetIndex, 'ExternalProgram', mesonlib.File]] = []
|
||||||
command.extend(state.environment.get_build_command())
|
command.extend(state.environment.get_build_command())
|
||||||
|
|
||||||
|
itstool_cmd = self.tools['itstool'].get_command()
|
||||||
|
# TODO: python 3.8 can use shlex.join()
|
||||||
command.extend([
|
command.extend([
|
||||||
'--internal', 'itstool', 'join',
|
'--internal', 'itstool', 'join',
|
||||||
'-i', '@INPUT@',
|
'-i', '@INPUT@',
|
||||||
'-o', '@OUTPUT@',
|
'-o', '@OUTPUT@',
|
||||||
'--itstool=' + self.tools['itstool'].get_path(),
|
'--itstool=' + ' '.join(shlex.quote(c) for c in itstool_cmd),
|
||||||
])
|
])
|
||||||
if its_files:
|
if its_files:
|
||||||
for fname in its_files:
|
for fname in its_files:
|
||||||
|
|
|
@ -17,6 +17,7 @@ import os
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import typing as T
|
import typing as T
|
||||||
|
|
||||||
|
@ -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)
|
shutil.copy(mo_file, tmp_mo_fname)
|
||||||
locale_mo_files.append(tmp_mo_fname)
|
locale_mo_files.append(tmp_mo_fname)
|
||||||
|
|
||||||
cmd = [itstool]
|
cmd = shlex.split(itstool)
|
||||||
if its_files:
|
if its_files:
|
||||||
for fname in its_files:
|
for fname in its_files:
|
||||||
cmd.extend(['-i', fname])
|
cmd.extend(['-i', fname])
|
||||||
|
|
Loading…
Reference in New Issue