diff options
-rw-r--r-- | src/engine/SCons/Defaults.py | 4 | ||||
-rw-r--r-- | test/SharedLibrary.py | 27 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index a7b0dc0..2259f40 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -69,7 +69,7 @@ class SharedCmdGenerator: for src in source: try: if src.attributes.shared != shared: - raise UserError("Source file: %s must be built with shared=%s in order to be compatible with the selected target." % (src, str(shared))) + raise SCons.Errors.UserError("Source file: %s must be built with shared=%s in order to be compatible with the selected target." % (src, str(shared))) except AttributeError: pass for t in target: @@ -247,7 +247,7 @@ def win32LibEmitter(target, source, env, shared=0, dll = tgt break if not dll: - raise UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")) + 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 \ diff --git a/test/SharedLibrary.py b/test/SharedLibrary.py index d00f595..8675c4b 100644 --- a/test/SharedLibrary.py +++ b/test/SharedLibrary.py @@ -25,9 +25,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import TestCmd import os -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match=TestCmd.match_re) test.write('SConstruct', """ env=Environment(WIN32_INSERT_DEF=1) @@ -39,6 +40,24 @@ env.Library(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'], shared=1) env2.Program(target = 'prog', source = 'prog.c') """) +test.write('SConstructFoo', """ +env=Environment() +obj = env.Object('foo', 'foo.c', shared=0) +Default(env.Library(target = 'foo', source = obj, shared=1)) +""") + +test.write('foo.c', r""" +#include <stdio.h> + +void +f1(void) +{ + printf("foo.c\n"); + fflush(stdout); +} +""") + + test.write('f1.c', r""" #include <stdio.h> @@ -162,4 +181,10 @@ if os.name == 'posix': test.run(program = test.workpath('prog'), stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.c\nprog.c\n") +test.run(arguments = '-f SConstructFoo', status=2, stderr=''' +SCons error: Source file: foo.o must be built with shared=1 in order to be compatible with the selected target. +File ".*", line .*, in .* +''' +) + test.pass_test() |