Skip to content
Merged
Changes from 1 commit
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
Next Next commit
add library search path by wr-cc in add_cross_compiling_paths()
  • Loading branch information
pxinwr committed Jan 11, 2021
commit 0b70bfc6c98779798bc883c42c67a6a48fc696b5
38 changes: 38 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,41 @@ 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

cc = sysconfig.get_config_var('CC')
tmpfile = os.path.join(self.build_temp, 'wrccpaths')
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
Comment thread
vstinner marked this conversation as resolved.
Outdated
ret = os.system('%s --print-search-dirs >%s' % (cc, tmpfile))
Comment thread
vstinner marked this conversation as resolved.
Outdated
try:
Comment thread
pxinwr marked this conversation as resolved.
if ret >> 8 == 0:
Comment thread
vstinner marked this conversation as resolved.
Outdated
with open(tmpfile) as fp:
for line in fp.readlines():
Comment thread
vstinner marked this conversation as resolved.
Outdated
if line.startswith("libraries"):
Comment thread
vstinner marked this conversation as resolved.
Outdated
# On Windows building machine, VxWorks does
# cross builds under msys2 environment.
sep=";" if sys.platform == "msys" else ":"
Comment thread
vstinner marked this conversation as resolved.
Outdated
for d in line.strip().split("=")[1].split(sep):
Comment thread
vstinner marked this conversation as resolved.
Outdated
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)
finally:
os.unlink(tmpfile)

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 +739,9 @@ def add_cross_compiling_paths(self):
finally:
os.unlink(tmpfile)

if VXWORKS:
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