Don't rebuild WIN32 libraries when there's no import library created. (Charles Crain)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 2 May 2002 17:30:58 +0000 (17:30 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 2 May 2002 17:30:58 +0000 (17:30 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@357 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Defaults.py
test/long-lines.py

index db93a670691a08effcd23e39c57ecf4acc8f24a8..cb21d8128dcc835693152f575a3173a33ffb9734 100644 (file)
@@ -64,7 +64,7 @@ class SharedCmdGenerator:
         self.action_static = static
         self.action_shared = shared
         
-    def __call__(self, target, source, env, shared=0, for_signature=0):
+    def __call__(self, target, source, env, shared=0, **kw):
         for src in source:
             try:
                 if src.attributes.shared != shared:
@@ -206,18 +206,21 @@ class LibAffixGenerator:
         self.static_affix = static
         self.shared_affix = shared
 
-    def __call__(self, shared=0, win32=0):
+    def __call__(self, shared=0, **kw):
         if shared:
             return self.shared_affix
         return self.static_affix
 
-def win32LibGenerator(target, source, env, for_signature, shared=1):
+def win32LibGenerator(target, source, env, for_signature, shared=1,
+                      no_import_lib=0):
     listCmd = [ "$SHLINK", "$SHLINKFLAGS" ]
 
     for tgt in target:
         ext = os.path.splitext(str(tgt))[1]
         if ext == env.subst("$LIBSUFFIX"):
             # Put it on the command line as an import library.
+            if no_import_lib:
+                raise SCons.Errors.UserError, "%s: You cannot specify a .lib file as a target of a shared library build if no_import_library is nonzero." % tgt
             listCmd.append("${WIN32IMPLIBPREFIX}%s" % tgt)
         else:
             listCmd.append("${WIN32DLLPREFIX}%s" % tgt)
@@ -233,7 +236,8 @@ def win32LibGenerator(target, source, env, for_signature, shared=1):
             listCmd.append(str(src))
     return win32TempFileMunge(env, listCmd, for_signature)
 
-def win32LibEmitter(target, source, env, shared=0):
+def win32LibEmitter(target, source, env, shared=0,
+                    no_import_lib=0):
     if shared:
         dll = None
         for tgt in target:
@@ -252,7 +256,8 @@ def win32LibEmitter(target, source, env, shared=0):
             # append a def file to the list of sources
             source.append("%s%s" % (os.path.splitext(str(dll))[0],
                                     env.subst("$WIN32DEFSUFFIX")))
-        if not env.subst("$LIBSUFFIX") in \
+        if not no_import_lib and \
+           not env.subst("$LIBSUFFIX") in \
            map(lambda x: os.path.split(str(x))[1], target):
             # Append an import library to the list of targets.
             target.append("%s%s%s" % (env.subst("$LIBPREFIX"),
index 521ed2c4db8180f37d63886ccb9476a21f0a3b23..a199a164b7575c10ea19fce5094908591ccd5804 100644 (file)
@@ -35,12 +35,10 @@ test = TestSCons.TestSCons()
 if sys.platform == 'win32':
     lib_=''
     _dll = '.dll'
-    _export = '__declspec(dllexport) '
     linkflag = '/LIBPATH:' + test.workpath()
 else:
     lib_='lib'
     _dll='.so'
-    _export=''
     linkflag = '-L' + test.workpath()
 
 test.write('SConstruct', """
@@ -50,12 +48,10 @@ while len(linkflags) <= 8100:
 env = Environment(LINKFLAGS = '$LINKXXX', LINKXXX = linkflags)
 env.Program(target = 'foo', source = 'foo.c')
 # Library(shared=1) uses $LINKFLAGS by default.
-env.Library(target = 'bar', source = 'foo.c', shared=1)
+env.Library(target = 'bar', source = 'foo.c', shared=1, no_import_lib=1)
 """ % (linkflag, linkflag))
 
 test.write('foo.c', r"""
-%svoid foo() { }
-
 int
 main(int argc, char *argv[])
 {
@@ -63,7 +59,7 @@ main(int argc, char *argv[])
        printf("foo.c\n");
        exit (0);
 }
-""" % _export)
+""")
 
 test.run(arguments = '.')