From: stevenknight Date: Mon, 25 Nov 2002 05:45:38 +0000 (+0000) Subject: Fix the Win32 checks for an explicit import library and .def file. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0091934ff63b9bed28ad72cae18803de9a288d62;p=scons.git Fix the Win32 checks for an explicit import library and .def file. git-svn-id: http://scons.tigris.org/svn/scons/trunk@504 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index 391cbfe5..79bf1d86 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -118,10 +118,10 @@ def win32LibEmitter(target, source, env): break if not dll: raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX") - + if env.has_key("WIN32_INSERT_DEF") and \ env["WIN32_INSERT_DEF"] and \ - not '.def' in map(lambda x: os.path.split(str(x))[1], + not '.def' in map(lambda x: os.path.splitext(str(x))[1], source): # append a def file to the list of sources @@ -131,10 +131,10 @@ def win32LibEmitter(target, source, env): if env.has_key('PDB') and env['PDB']: env.SideEffect(env['PDB'], target) env.Precious(env['PDB']) - + if not no_import_lib and \ not env.subst("$LIBSUFFIX") in \ - map(lambda x: os.path.split(str(x))[1], target): + map(lambda x: os.path.splitext(str(x))[1], target): # Append an import library to the list of targets. target.append("%s%s%s" % (env.subst("$LIBPREFIX"), os.path.splitext(str(dll))[0], diff --git a/test/SharedLibrary.py b/test/SharedLibrary.py index 6dcb7798..d54dba42 100644 --- a/test/SharedLibrary.py +++ b/test/SharedLibrary.py @@ -24,9 +24,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import TestSCons -import TestCmd import os +import string +import sys + +import TestCmd +import TestSCons test = TestSCons.TestSCons(match=TestCmd.match_re) @@ -184,6 +187,7 @@ test.run(arguments = '.') if os.name == 'posix': os.environ['LD_LIBRARY_PATH'] = '.' + test.run(program = test.workpath('prog'), stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.c\nprog.c\n") @@ -197,4 +201,58 @@ SCons error: Source file: bar\..* is shared and is not compatible with static ta ''' ) +if sys.platform == 'win32': + # Make sure we don't insert a .def source file (when + # WIN32_INSERT_DEF is set) and a .lib target file if + # they're specified explicitly. + + test.write('SConstructBar', ''' +env = Environment(WIN32_INSERT_DEF=1) +env2 = Environment(LIBS = [ 'foo4' ], + LIBPATH = [ '.' ]) +env.SharedLibrary(target = ['foo4', 'foo4.lib'], source = ['f4.c', 'foo4.def']) +env2.Program(target = 'progbar', source = 'progbar.c') +''') + + test.write('f4.c', r""" +#include + +f4(void) +{ + printf("f4.c\n"); + fflush(stdout); +} +""") + + test.write("foo4.def", r""" +LIBRARY "foo4" +DESCRIPTION "Foo4 Shared Library" + +EXPORTS + f4 +""") + + test.write('progbar.c', r""" +void f4(void); +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + f4(); + printf("progbar.c\n"); + return 0; +} +""") + + test.run(arguments = '-f SConstructBar .') + + # Make sure there is (at most) one mention each of the + # appropriate .def and .lib files per line. + for line in string.split(test.stdout(), '\n'): + test.fail_test(string.count(line, 'foo4.def') > 1) + test.fail_test(string.count(line, 'foo4.lib') > 1) + + test.run(program = test.workpath('progbar'), + stdout = "f4.c\nprogbar.c\n") + test.pass_test()