Add an option in config to force the usage of posix path
This commit is contained in:
parent
c59ace0e5a
commit
3854c8570e
|
@ -27,6 +27,7 @@ class ConfigInfo(metaclass=_MetaConfig):
|
|||
configure_options = []
|
||||
mixed = False
|
||||
libdir = None
|
||||
force_posix_path = False
|
||||
|
||||
@property
|
||||
def arch_name(self):
|
||||
|
|
|
@ -12,6 +12,7 @@ class WinBashConfigInfo(ConfigInfo):
|
|||
compatible_hosts = ["Windows"]
|
||||
exe_wrapper_def = ""
|
||||
static = True
|
||||
force_posix_path = True
|
||||
|
||||
@property
|
||||
def arch_name(self):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue