Use the correct path separator on Windows

This commit is contained in:
Matthieu Gautier 2023-11-28 14:26:30 +01:00
parent be179cb250
commit db6aa2eed2
7 changed files with 55 additions and 42 deletions

View File

@ -123,13 +123,12 @@ class BuildEnv:
def get_env(self, *, cross_comp_flags, cross_compilers, cross_path): def get_env(self, *, cross_comp_flags, cross_compilers, cross_path):
env = self.configInfo.get_env() env = self.configInfo.get_env()
pkgconfig_path = pj(self.install_dir, self.libprefix, "pkgconfig") pkgconfig_path = pj(self.install_dir, self.libprefix, "pkgconfig")
env["PKG_CONFIG_PATH"] = ":".join([env["PKG_CONFIG_PATH"], pkgconfig_path]) env["PKG_CONFIG_PATH"].append(pkgconfig_path)
env["PATH"] = ":".join([escape_path(pj(self.install_dir, "bin")), env["PATH"]]) env["PATH"].insert(0, pj(self.install_dir, "bin"))
env["LD_LIBRARY_PATH"] = ":".join( env["LD_LIBRARY_PATH"].extend(
[ [
env["LD_LIBRARY_PATH"],
pj(self.install_dir, "lib"), pj(self.install_dir, "lib"),
pj(self.install_dir, self.libprefix), pj(self.install_dir, self.libprefix),
] ]
@ -161,7 +160,7 @@ class BuildEnv:
if cross_compilers: if cross_compilers:
self.configInfo.set_compiler(env) self.configInfo.set_compiler(env)
if cross_path: if cross_path:
env["PATH"] = ":".join(self.configInfo.get_bin_dir() + [env["PATH"]]) env["PATH"][0:0] = self.configInfo.get_bin_dir()
return env return env
@property @property

View File

@ -1,6 +1,6 @@
from .base import ConfigInfo, MixedMixin from .base import ConfigInfo, MixedMixin
from kiwixbuild.utils import pj from kiwixbuild.utils import pj, get_separator
from kiwixbuild._global import get_target_step from kiwixbuild._global import get_target_step
@ -76,17 +76,14 @@ class ArmConfigInfo(ConfigInfo):
def get_env(self): def get_env(self):
env = super().get_env() env = super().get_env()
env["LD_LIBRARY_PATH"] = ":".join( env["LD_LIBRARY_PATH"][0:0] = [
[ pj(self.root_path, self.arch_full, "lib64"),
pj(self.root_path, self.arch_full, "lib64"), pj(self.root_path, "lib")
pj(self.root_path, "lib"), ]
env["LD_LIBRARY_PATH"],
]
)
env["PKG_CONFIG_LIBDIR"] = pj(self.root_path, "lib", "pkgconfig") env["PKG_CONFIG_LIBDIR"] = pj(self.root_path, "lib", "pkgconfig")
env["QEMU_LD_PREFIX"] = pj(self.root_path, self.arch_full, "libc") env["QEMU_LD_PREFIX"] = pj(self.root_path, self.arch_full, "libc")
env["QEMU_SET_ENV"] = "LD_LIBRARY_PATH={}".format( env["QEMU_SET_ENV"] = "LD_LIBRARY_PATH={}".format(
":".join( get_separator().join(
[pj(self.root_path, self.arch_full, "lib"), env["LD_LIBRARY_PATH"]] [pj(self.root_path, self.arch_full, "lib"), env["LD_LIBRARY_PATH"]]
) )
) )

View File

@ -161,15 +161,13 @@ def MixedMixin(static_name):
def get_env(self): def get_env(self):
env = super().get_env() env = super().get_env()
env["PATH"] = ":".join( env["PATH"].insert(0, pj(self.static_buildEnv.install_dir, "bin"))
[pj(self.static_buildEnv.install_dir, "bin")] + [env["PATH"]]
)
pkgconfig_path = pj( pkgconfig_path = pj(
self.static_buildEnv.install_dir, self.static_buildEnv.install_dir,
self.static_buildEnv.libprefix, self.static_buildEnv.libprefix,
"pkgconfig", "pkgconfig",
) )
env["PKG_CONFIG_PATH"] = ":".join([env["PKG_CONFIG_PATH"], pkgconfig_path]) env["PKG_CONFIG_PATH"].append(pkgconfig_path)
env["CPPFLAGS"] = " ".join( env["CPPFLAGS"] = " ".join(
[ [
"-I" + pj(self.static_buildEnv.install_dir, "include"), "-I" + pj(self.static_buildEnv.install_dir, "include"),

View File

@ -1,6 +1,6 @@
from .base import ConfigInfo, MixedMixin from .base import ConfigInfo, MixedMixin
from kiwixbuild.utils import pj from kiwixbuild.utils import pj, get_separator
from kiwixbuild._global import get_target_step from kiwixbuild._global import get_target_step
@ -73,17 +73,14 @@ class MuslConfigInfo(ConfigInfo):
def get_env(self): def get_env(self):
env = super().get_env() env = super().get_env()
env["LD_LIBRARY_PATH"] = ":".join( env["LD_LIBRARY_PATH"][0:0] = [
[ pj(self.root_path, self.arch_full, "lib64"),
pj(self.root_path, self.arch_full, "lib64"), pj(self.root_path, "lib")
pj(self.root_path, "lib"), ]
env["LD_LIBRARY_PATH"],
]
)
env["PKG_CONFIG_LIBDIR"] = pj(self.root_path, "lib", "pkgconfig") env["PKG_CONFIG_LIBDIR"] = pj(self.root_path, "lib", "pkgconfig")
env["QEMU_LD_PREFIX"] = pj(self.root_path, self.arch_full, "libc") env["QEMU_LD_PREFIX"] = pj(self.root_path, self.arch_full, "libc")
env["QEMU_SET_ENV"] = "LD_LIBRARY_PATH={}".format( env["QEMU_SET_ENV"] = "LD_LIBRARY_PATH={}".format(
":".join( get_separator().join(
[pj(self.root_path, self.arch_full, "lib"), env["LD_LIBRARY_PATH"]] [pj(self.root_path, self.arch_full, "lib"), env["LD_LIBRARY_PATH"]]
) )
) )
@ -91,9 +88,7 @@ class MuslConfigInfo(ConfigInfo):
def set_comp_flags(self, env): def set_comp_flags(self, env):
super().set_comp_flags(env) super().set_comp_flags(env)
env["LD_LIBRARY_PATH"] = ":".join( env["LD_LIBRARY_PATH"].insert(0, pj(self.root_path, self.arch_full, "lib"))
[pj(self.root_path, self.arch_full, "lib"), env["LD_LIBRARY_PATH"]]
)
env["CFLAGS"] = ( env["CFLAGS"] = (
" -fPIC -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 " " -fPIC -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 "
+ env["CFLAGS"] + env["CFLAGS"]

View File

@ -79,14 +79,11 @@ class WasmConfigInfo(ConfigInfo):
def get_env(self): def get_env(self):
env = super().get_env() env = super().get_env()
env["PATH"] = ":".join( env["PATH"].extend([
[ self.install_path,
env["PATH"], pj(self.install_path, "upstream", "emscripten"),
self.install_path, pj(self.install_path, "node", "14.18.2_64bit", "bin"),
pj(self.install_path, "upstream", "emscripten"), ])
pj(self.install_path, "node", "14.18.2_64bit", "bin"),
]
)
env["EMSDK"] = self.install_path env["EMSDK"] = self.install_path
env["EMSDK_NODE"] = pj( env["EMSDK_NODE"] = pj(
self.install_path, "node", "14.18.2_64bit", "bin", "node" self.install_path, "node", "14.18.2_64bit", "bin", "node"

View File

@ -41,12 +41,15 @@ class LibMagic(Dependency):
if configInfo.build == "native": if configInfo.build == "native":
return super()._compile(context) return super()._compile(context)
context.try_skip(self.build_path) context.try_skip(self.build_path)
command = ["make", "-j4", *self.make_targets, *self.make_options] command = [
"make",
"-j4",
*self.make_targets,
*self.make_options
]
env = self.buildEnv.get_env( env = self.buildEnv.get_env(
cross_comp_flags=True, cross_compilers=True, cross_path=True cross_comp_flags=True, cross_compilers=True, cross_path=True
) )
libmagic_native_builder = get_target_step("libmagic", "native_static") libmagic_native_builder = get_target_step("libmagic", "native_static")
env["PATH"] = ":".join( env["PATH"].insert(0, pj(libmagic_native_builder.build_path, "src"))
[pj(libmagic_native_builder.build_path, "src"), env["PATH"]]
)
run_command(command, self.build_path, context, env=env) run_command(command, self.build_path, context, env=env)

View File

@ -63,8 +63,30 @@ class DefaultEnv(Defaultdict):
def __getitem__(self, name): def __getitem__(self, name):
if name == b"PATH": if name == b"PATH":
raise KeyError raise KeyError
if name in ['PATH', 'PKG_CONFIG_PATH', 'LD_LIBRARY_PATH']:
item = super().__getitem__(name)
if isinstance(item, PathArray):
return item
else:
item = PathArray(item)
self[name] = item
return item
return super().__getitem__(name) return super().__getitem__(name)
def get_separator():
return ';' if neutralEnv('distname') == 'Windows' else ':'
class PathArray(list):
def __init__(self, value):
self.separator = get_separator()
if not value:
super().__init__([])
else:
super().__init__(value.split(self.separator))
def __str__(self):
return self.separator.join(self)
def remove_duplicates(iterable, key_function=None): def remove_duplicates(iterable, key_function=None):
seen = set() seen = set()
@ -297,9 +319,11 @@ def run_command(command, cwd, context, *, env=None, input=None):
print("run command '{}'".format(command), file=log) print("run command '{}'".format(command), file=log)
print("current directory is '{}'".format(cwd), file=log) print("current directory is '{}'".format(cwd), file=log)
print("env is :", file=log) print("env is :", file=log)
env = {k:str(v) for k,v in env.items()}
for k, v in env.items(): for k, v in env.items():
print(" {} : {!r}".format(k, v), file=log) print(" {} : {!r}".format(k, v), file=log)
if log: if log:
log.flush() log.flush()
kwargs = dict() kwargs = dict()