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 = []
|
configure_options = []
|
||||||
mixed = False
|
mixed = False
|
||||||
libdir = None
|
libdir = None
|
||||||
|
force_posix_path = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def arch_name(self):
|
def arch_name(self):
|
||||||
|
|
|
@ -12,6 +12,7 @@ class WinBashConfigInfo(ConfigInfo):
|
||||||
compatible_hosts = ["Windows"]
|
compatible_hosts = ["Windows"]
|
||||||
exe_wrapper_def = ""
|
exe_wrapper_def = ""
|
||||||
static = True
|
static = True
|
||||||
|
force_posix_path = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def arch_name(self):
|
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)
|
env = self.get_env(cross_comp_flags=True, cross_compilers=True, cross_path=True)
|
||||||
self.set_configure_env(env)
|
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):
|
def _compile(self, context):
|
||||||
context.try_skip(self.build_path)
|
context.try_skip(self.build_path)
|
||||||
|
|
|
@ -8,7 +8,7 @@ import urllib.error
|
||||||
import ssl
|
import ssl
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path, PurePosixPath
|
||||||
from collections import namedtuple, defaultdict
|
from collections import namedtuple, defaultdict
|
||||||
|
|
||||||
from kiwixbuild._global import neutralEnv, option
|
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()
|
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)
|
os.makedirs(cwd, exist_ok=True)
|
||||||
if env is None:
|
if env is None:
|
||||||
env = DefaultEnv()
|
env = DefaultEnv()
|
||||||
log = None
|
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:
|
try:
|
||||||
if not option("verbose"):
|
if not option("verbose"):
|
||||||
log = open(context.log_file, "w")
|
log = open(context.log_file, "w")
|
||||||
print(f"run command '{command}'", file=log)
|
print(f"run command '{command}'", file=log)
|
||||||
print(f"current directory is '{cwd}'", file=log)
|
print(f"current directory is '{cwd}'", file=log)
|
||||||
print("env is :", 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():
|
for k, v in env.items():
|
||||||
print(f" {k} : {v!r}", file=log)
|
print(f" {k} : {v!r}", file=log)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue