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:
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 \
__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)
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>
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()