Skip to content

bpo-31904: add library search path by wr-cc in add_cross_compiling_paths() #24191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add library search path by wr-cc in add_cross_compiling_paths() for VxWorks.
48 changes: 48 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,51 @@ def add_multiarch_paths(self):
finally:
os.unlink(tmpfile)

def add_wrcc_search_dirs(self):
# add library search path by wr-cc, the compiler wrapper

def convert_mixed_path(path):
# convert path like C:\folder1\folder2/folder3/folder4
# to msys style /c/folder1/folder2/folder3/folder4
drive = path[0].lower()
left = path[2:].replace("\\", "/")
return "/" + drive + left

def add_search_path(line):
# On Windows building machine, VxWorks does
# cross builds under msys2 environment.
pathsep = (";" if sys.platform == "msys" else ":")
for d in line.strip().split("=")[1].split(pathsep):
d = d.strip()
if sys.platform == "msys":
# On Windows building machine, compiler
# returns mixed style path like:
# C:\folder1\folder2/folder3/folder4
d = convert_mixed_path(d)
d = os.path.normpath(d)
add_dir_to_list(self.compiler.library_dirs, d)

cc = sysconfig.get_config_var('CC')
tmpfile = os.path.join(self.build_temp, 'wrccpaths')
os.makedirs(self.build_temp, exist_ok=True)
try:
ret = run_command('%s --print-search-dirs >%s' % (cc, tmpfile))
if ret:
return
with open(tmpfile) as fp:
# Parse paths in libraries line. The line is like:
# On Linux, "libraries: = path1:path2:path3"
# On Windows, "libraries: = path1;path2;path3"
for line in fp:
if not line.startswith("libraries"):
continue
add_search_path(line)
finally:
try:
os.unlink(tmpfile)
except OSError:
pass

def add_cross_compiling_paths(self):
cc = sysconfig.get_config_var('CC')
tmpfile = os.path.join(self.build_temp, 'ccpaths')
Expand Down Expand Up @@ -704,6 +749,9 @@ def add_cross_compiling_paths(self):
finally:
os.unlink(tmpfile)

if VXWORKS:
self.add_wrcc_search_dirs()

def add_ldflags_cppflags(self):
# Add paths specified in the environment variables LDFLAGS and
# CPPFLAGS for header and library files.
Expand Down