Use the correct path separator on Windows

This commit is contained in:
Matthieu Gautier
2023-11-28 14:26:30 +01:00
parent 858cbed9d4
commit 897508defa
4 changed files with 32 additions and 13 deletions

View File

@ -132,13 +132,12 @@ class BuildEnv:
def get_env(self, *, cross_comp_flags, cross_compilers, cross_path):
env = self.configInfo.get_env()
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, self.libprefix),
]
@ -170,7 +169,7 @@ class BuildEnv:
if cross_compilers:
self.configInfo.set_compiler(env)
if cross_path:
env["PATH"] = ":".join(self.configInfo.get_bin_dir() + [env["PATH"]])
env["PATH"].insert(0, self.configInfo.get_bin_dir())
return env
@property

View File

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

View File

@ -46,7 +46,5 @@ class LibMagic(Dependency):
cross_comp_flags=True, cross_compilers=True, cross_path=True
)
libmagic_native_builder = get_target_step("libmagic", "native_static")
env["PATH"] = ":".join(
[pj(libmagic_native_builder.build_path, "src"), env["PATH"]]
)
env["PATH"].insert(0, pj(libmagic_native_builder.build_path, "src"))
run_command(command, self.build_path, context, env=env)

View File

@ -63,8 +63,30 @@ class DefaultEnv(Defaultdict):
def __getitem__(self, name):
if name == b"PATH":
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)
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):
seen = set()
@ -302,9 +324,11 @@ def run_command(command, cwd, context, *, env=None, input=None):
print("run command '{}'".format(command), file=log)
print("current directory is '{}'".format(cwd), file=log)
print("env is :", file=log)
env = {k:str(v) for k,v in env.items()}
for k, v in env.items():
print(" {} : {!r}".format(k, v), file=log)
if log:
log.flush()
kwargs = dict()