@@ -682,6 +682,51 @@ def add_multiarch_paths(self):
682682 finally :
683683 os .unlink (tmpfile )
684684
685+  def  add_wrcc_search_dirs (self ):
686+  # add library search path by wr-cc, the compiler wrapper 
687+ 
688+  def  convert_mixed_path (path ):
689+  # convert path like C:\folder1\folder2/folder3/folder4 
690+  # to msys style /c/folder1/folder2/folder3/folder4 
691+  drive  =  path [0 ].lower ()
692+  left  =  path [2 :].replace ("\\ " , "/" )
693+  return  "/"  +  drive  +  left 
694+ 
695+  def  add_search_path (line ):
696+  # On Windows building machine, VxWorks does 
697+  # cross builds under msys2 environment. 
698+  pathsep  =  (";"  if  sys .platform  ==  "msys"  else  ":" )
699+  for  d  in  line .strip ().split ("=" )[1 ].split (pathsep ):
700+  d  =  d .strip ()
701+  if  sys .platform  ==  "msys" :
702+  # On Windows building machine, compiler 
703+  # returns mixed style path like: 
704+  # C:\folder1\folder2/folder3/folder4 
705+  d  =  convert_mixed_path (d )
706+  d  =  os .path .normpath (d )
707+  add_dir_to_list (self .compiler .library_dirs , d )
708+ 
709+  cc  =  sysconfig .get_config_var ('CC' )
710+  tmpfile  =  os .path .join (self .build_temp , 'wrccpaths' )
711+  os .makedirs (self .build_temp , exist_ok = True )
712+  try :
713+  ret  =  run_command ('%s --print-search-dirs >%s'  %  (cc , tmpfile ))
714+  if  ret :
715+  return 
716+  with  open (tmpfile ) as  fp :
717+  # Parse paths in libraries line. The line is like: 
718+  # On Linux, "libraries: = path1:path2:path3" 
719+  # On Windows, "libraries: = path1;path2;path3" 
720+  for  line  in  fp :
721+  if  not  line .startswith ("libraries" ):
722+  continue 
723+  add_search_path (line )
724+  finally :
725+  try :
726+  os .unlink (tmpfile )
727+  except  OSError :
728+  pass 
729+ 
685730 def  add_cross_compiling_paths (self ):
686731 cc  =  sysconfig .get_config_var ('CC' )
687732 tmpfile  =  os .path .join (self .build_temp , 'ccpaths' )
@@ -715,6 +760,9 @@ def add_cross_compiling_paths(self):
715760 finally :
716761 os .unlink (tmpfile )
717762
763+  if  VXWORKS :
764+  self .add_wrcc_search_dirs ()
765+ 
718766 def  add_ldflags_cppflags (self ):
719767 # Add paths specified in the environment variables LDFLAGS and 
720768 # CPPFLAGS for header and library files. 
0 commit comments