diff --git a/kiwixbuild/configs/base.py b/kiwixbuild/configs/base.py index a9c6e44..426debd 100644 --- a/kiwixbuild/configs/base.py +++ b/kiwixbuild/configs/base.py @@ -27,6 +27,7 @@ class ConfigInfo(metaclass=_MetaConfig): configure_options = [] mixed = False libdir = None + force_posix_path = False @property def arch_name(self): diff --git a/kiwixbuild/configs/winbash.py b/kiwixbuild/configs/winbash.py index 66ed0b1..e0f3d94 100644 --- a/kiwixbuild/configs/winbash.py +++ b/kiwixbuild/configs/winbash.py @@ -12,6 +12,7 @@ class WinBashConfigInfo(ConfigInfo): compatible_hosts = ["Windows"] exe_wrapper_def = "" static = True + force_posix_path = True @property def arch_name(self): diff --git a/kiwixbuild/dependencies/base.py b/kiwixbuild/dependencies/base.py index 9cdfb2e..1ba0222 100644 --- a/kiwixbuild/dependencies/base.py +++ b/kiwixbuild/dependencies/base.py @@ -428,7 +428,13 @@ class MakeBuilder(Builder): ] env = self.get_env(cross_comp_flags=True, cross_compilers=True, cross_path=True) self.set_configure_env(env) - run_command(command, self.build_path, context, env=env) + run_command( + command, + self.build_path, + context, + env=env, + force_posix_path=self.buildEnv.configInfo.force_posix_path, + ) def _compile(self, context): context.try_skip(self.build_path) diff --git a/kiwixbuild/utils.py b/kiwixbuild/utils.py index 40dd789..d51ceb8 100644 --- a/kiwixbuild/utils.py +++ b/kiwixbuild/utils.py @@ -8,7 +8,7 @@ import urllib.error import ssl import subprocess import re -from pathlib import Path +from pathlib import Path, PurePosixPath from collections import namedtuple, defaultdict from kiwixbuild._global import neutralEnv, option @@ -322,19 +322,23 @@ def extract_archive(archive_path: Path, dest_dir: Path, topdir=None, name=None): archive.close() -def run_command(command, cwd, context, *, env=None, input=None): +def run_command(command, cwd, context, *, env=None, input=None, force_posix_path=False): os.makedirs(cwd, exist_ok=True) if env is None: env = DefaultEnv() log = None - command = [str(v) for v in command] + if force_posix_path: + transform_path = lambda v: PurePosixPath(v) if isinstance(v, Path) else v + else: + transform_path = lambda v: v + command = [str(transform_path(v)) for v in command] try: if not option("verbose"): log = open(context.log_file, "w") print(f"run command '{command}'", file=log) print(f"current directory is '{cwd}'", file=log) print("env is :", file=log) - env = {k: str(v) for k, v in env.items()} + env = {k: str(transform_path(v)) for k, v in env.items()} for k, v in env.items(): print(f" {k} : {v!r}", file=log)