build: account for msys2's duplicity in path schemes
This commit is contained in:
parent
1e0191eda6
commit
6305a57a73
@ -76,12 +76,41 @@ defaults = {
|
|||||||
env = defaults.copy()
|
env = defaults.copy()
|
||||||
env.update(os.environ)
|
env.update(os.environ)
|
||||||
|
|
||||||
|
# MinGW pretends to be its own platform. Try to work around their deception by
|
||||||
|
# testing if the platform string looks like something that's actually useful.
|
||||||
|
def is_really_windows() -> bool:
|
||||||
|
name = platform.system()
|
||||||
|
|
||||||
|
if name == 'Windows':
|
||||||
|
return True
|
||||||
|
if name.startswith('MINGW'):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
# MSYS2 wants to fuck us over by supplying a CMake that gives something
|
||||||
|
# approximating native paths, and by _also_ providing an environment that
|
||||||
|
# cannot use these paths in places like PATH.
|
||||||
|
#
|
||||||
|
# Break the paths to conform to their expectations if we're under Windows.
|
||||||
|
def break_path_for_msys2(path):
|
||||||
|
if not is_really_windows():
|
||||||
|
return path
|
||||||
|
|
||||||
|
# Test if we have a path of the form "C:/foo" (as opposed to a
|
||||||
|
# relative path, or an MSYS2 path like "/c/foo")
|
||||||
|
if path[1] != ':':
|
||||||
|
return path
|
||||||
|
|
||||||
|
return '/' + path[0] + path[2:]
|
||||||
|
|
||||||
|
|
||||||
# Windows has its own unique rules for library lookups. We record the
|
# Windows has its own unique rules for library lookups. We record the
|
||||||
# environment variable which effects path lookups and the separator and the
|
# environment variable which effects path lookups and the separator and the
|
||||||
# target directory for Windows and for every single other system we're likely
|
# target directory for Windows and for every single other system we're likely
|
||||||
# to ever deal with...
|
# to ever deal with...
|
||||||
if platform.system() == 'Windows':
|
if is_really_windows():
|
||||||
separator = ';'
|
separator = ':'
|
||||||
depsdir = ['bin']
|
depsdir = ['bin']
|
||||||
searchvar = 'PATH'
|
searchvar = 'PATH'
|
||||||
else:
|
else:
|
||||||
@ -92,7 +121,7 @@ else:
|
|||||||
|
|
||||||
# append the in-tree dependencies to the library path
|
# append the in-tree dependencies to the library path
|
||||||
search = separator.join(
|
search = separator.join(
|
||||||
"@CMAKE_CURRENT_BINARY_DIR@/deps/" + i for i in depsdir
|
break_path_for_msys2("@CMAKE_CURRENT_BINARY_DIR@/deps/") + i for i in depsdir
|
||||||
)
|
)
|
||||||
|
|
||||||
if searchvar in env:
|
if searchvar in env:
|
||||||
|
Loading…
Reference in New Issue
Block a user