Rewrote 'find_library_file()' much more cleanly (and consistently with

MSVCCompiler's version, to aid in factoring common code out of the two
classes when the time comes).
This commit is contained in:
Greg Ward 2000-08-04 01:30:03 +00:00
parent d142564821
commit 5db2c3ae24
1 changed files with 17 additions and 19 deletions

View File

@ -357,28 +357,26 @@ def library_option (self, lib):
def find_library_file (self, dirs, lib, debug=0): def find_library_file (self, dirs, lib, debug=0):
# find library file # List of effective library names to try, in order of preference:
# bcpp_xxx.lib is better than xxx.lib # bcpp_xxx.lib is better than xxx.lib
# and xxx_d.lib is better than xxx.lib if debug is set # and xxx_d.lib is better than xxx.lib if debug is set
for dir in dirs: #
if debug: # The "bcpp_" prefix is to handle a Python installation for people
libfile = os.path.join ( # with multiple compilers (primarily Distutils hackers, I suspect
dir, self.library_filename ("bcpp_" + lib + "_d")) # ;-). The idea is they'd have one static library for each
if os.path.exists (libfile): # compiler they care about, since (almost?) every Windows compiler
return libfile # seems to have a different format for static libraries.
libfile = os.path.join ( if debug:
dir, self.library_filename ("bcpp_" + lib)) dlib = (lib + "_d")
if os.path.exists (libfile): try_names = ("bcpp_" + dlib, "bcpp_" + lib, dlib, lib)
return libfile else:
if debug: try_names = ("bcpp_" + lib, lib)
libfile = os.path.join (
dir, self.library_filename(lib + '_d'))
if os.path.exists (libfile):
return libfile
libfile = os.path.join (dir, self.library_filename (lib))
if os.path.exists (libfile):
return libfile
for dir in dirs:
for name in try_names:
libfile = os.path.join(dir, self.library_filename(name))
if os.path.exists(libfile):
return libfile
else: else:
# Oops, didn't find it in *any* of 'dirs' # Oops, didn't find it in *any* of 'dirs'
return None return None