.B scons
provides the following builders:
-.IP Object
-Builds an object file from one or more C, C++, or Fortran source files.
+.IP StaticObject
+Builds a static object file
+from one or more C, C++, or Fortran source files.
Source files must have one of the following extensions:
.ES
.c C file
added. Examples:
.ES
-env.Object(target = 'aaa', source = 'aaa.c')
-env.Object(target = 'bbb.o', source = 'bbb.c++')
-env.Object(target = 'ccc.obj', source = 'ccc.f')
+env.StaticObject(target = 'aaa', source = 'aaa.c')
+env.StaticObject(target = 'bbb.o', source = 'bbb.c++')
+env.StaticObject(target = 'ccc.obj', source = 'ccc.f')
.EE
-.IP
-The
-.B Object
-builder accepts an optional "shared" keyword that, when non-zero,
-specifies that the object file should be built for
+.IP SharedObject
+Builds an object file for
inclusion in a shared library
-(that is, built with the '-fPIC' option when using gcc):
+(that is, built with the '-fPIC' option when using gcc).
+Source files must have one of the same set of extensions
+specified above for the
+.B StaticObject
+builder.
+The target object file prefix and suffix (if any) are automatically
+added. Examples:
.ES
-env.Object(target = 'ddd.obj', source = 'ddd.c', shared = 1)
+env.SharedObject(target = 'ddd', source = 'ddd.c')
+env.SharedObject(target = 'eee.o', source = 'eee.cpp')
+env.SharedObject(target = 'fff.obj', source = 'fff.for')
.EE
+.IP Object
+A synonym for the
+.B StaticObject
+builder.
+
.IP Program
Builds an executable given one or more object files or C, C++
or Fortran source files.
env.Program(target = 'foo', source = 'foo.o bar.c baz.f')
.EE
-.IP Library
-Builds a static or shared library given one or more object files
+.IP StaticLibrary
+Builds a static library given one or more object files
or C, C++ or Fortran source files.
If any source files are given,
then they will be automatically
-compiled to object files. The library prefix and suffix (if any) are
-automatically added to the target. Example:
+compiled to object files.
+The library prefix and suffix (if any)
+are automatically added to the target.
+Example:
.ES
-env.Library(target = 'bar', source = 'bar.c foo.o')
+env.StaticLibrary(target = 'bar', source = 'bar.c foo.o')
.EE
-.IP
-By default,
-.B Library
-builds a static library.
-A shared library (.so on a POSIX system, .dll on WIN32)
-may be specified by setting the
-.B shared
-keyword argument to non-zero:
+
+Any object files listed in the
+.B source
+must have been built for a static library
+(that is, using the
+.B StaticObject
+builder).
+.B scons
+will raise an error if there is any mismatch.
+
+.IP SharedLibrary
+Builds a shared library
+(.so on a POSIX system, .dll on WIN32)
+given one or more object files
+or C, C++ or Fortran source files.
+If any source files are given,
+then they will be automatically
+compiled to object files.
+The library prefix and suffix (if any)
+are automatically added to the target.
+Example:
.ES
-env.Library(target = 'bar', source = 'bar.c foo.o', shared = 1)
+env.SharedLibrary(target = 'bar', source = 'bar.c foo.o')
.EE
.IP
On WIN32 systems, the
-.B Library
+.B SharedLibrary
builder will always build an import (.lib) library
in addition to the shared (.dll) library,
adding a .lib library with the same basename
Any object files listed in the
.B source
-list for a shared library
must have been built for a shared library
-(that is, using a non-zero
-.B shared
-keyword argument).
-Conversely, object files built into a static library must
-.I not
-have been built for a shared library.
+(that is, using the
+.B SharedObject
+builder).
.B scons
will raise an error if there is any mismatch.
+.IP Library
+A synonym for the
+.B StaticLibrary
+builder.
+
.IP CFile
Builds a C source file given a lex (.l) or yacc (.y) input file.
The suffix specified by the $CFILESUFFIX construction variable
.IP prefix
The prefix that will be prepended to the target file name.
-The value may also be a function call
-that returns the prefix.
-The function will be passed the environment
-and any extra keyword arguments
-supplied when the Builder is called.
.IP suffix
The suffix that will be appended to the target file name.
-The value may also be a function call
-that returns the suffix.
-The function will be passed the environment
-and any extra keyword arguments
-supplied when the Builder is called.
.IP src_suffix
The expected source file name suffix.
-The value may also be a function call
-that returns the source file name suffix.
-The function will be passed the environment
-and any extra keyword arguments
-supplied when the Builder is called.
.IP src_builder
Specifies a builder to use when a source file name suffix does not match
These extra keyword arguments are passed to the
following functions:
-command generator functions, funcion Actions,
-emitter functions,
-and functions that generate prefix, suffix or src_suffix.
+command generator functions,
+function Actions,
+and emitter functions.
.SS Action Objects
and the Builder name= keyword argument, generate warnings
about use of deprecated features.
+ - Removed the "shared" keyword argument from the Object and
+ Library builders.
+
+ - Added separated StaticObject, SharedObject, StaticLibrary and
+ SharedLibrary builders. Made Object and Library synonyms for
+ StaticObject and StaticLibrary, respectively.
+
+ - Add LIBS and LIBPATH dependencies for shared libraries.
+
+ - Removed support for the prefix, suffix and src_suffix arguments
+ to Builder() to be callable functions.
+
From Steven Knight:
- Add a "platform=" keyword argument to Environment instantiation,
(You may, of course, also use the string.split() function from
the standard Python library to convert your strings.)
+ - The Object and Library builders no longer use the "shared"
+ keyword argument to specify if the target object or library is a
+ shared library. Instead, separate StaticObject, SharedObject,
+ StaticLibrary and SharedLibrary builders exist to explicitly build
+ the appropriate target. The Object and Library buidlers are now
+ synonyms for StaticObject and StaticLibrary, respecitvely.
+
+ - The prefix, suffix, and src_suffix keyword arguments to the
+ Builder() function may no longer be callable functions.
+
Please note the following important changes since release 0.06:
- The functionality of the -U option has changed. It now works
def execute(self, **kw):
for l in self.list:
r = apply(l.execute, (), kw)
- if r != 0:
+ if r:
return r
return 0
Simple concatenation of the signatures of the elements.
"""
- return reduce(lambda x, y: x + str(y.get_contents()), self.list, "")
+ return reduce(lambda x, y, kw=kw: x + str(apply(y.get_contents, (), kw)), self.list, "")
self.inc = 0
def f(s):
s.inc = s.inc + 1
- return 0
a = SCons.Action.ListAction([f, f, f])
a.execute(s = self)
assert self.inc == 3, self.inc
def test_get_contents(self):
"""Test fetching the contents of a list of subsidiary Actions
"""
- a = SCons.Action.ListAction(["x", "y", "z"])
- c = a.get_contents(target=[], source=[])
+ self.foo=0
+ def gen(target, source, s, for_signature):
+ s.foo=1
+ return "y"
+ a = SCons.Action.ListAction(["x",
+ SCons.Action.CommandGenerator(gen),
+ "z"])
+ c = a.get_contents(target=[], source=[], s=self)
+ assert self.foo==1, self.foo
assert c == "xyz", c
class LazyActionTestCase(unittest.TestCase):
self.name = name
self.action = SCons.Action.Action(action)
self.multi = multi
+ self.prefix = prefix
+ self.suffix = suffix
- if callable(prefix):
- self.prefix = prefix
+ if SCons.Util.is_String(src_suffix):
+ self.src_suffix = [ src_suffix ]
else:
- self.prefix = _callable_adaptor(str(prefix))
-
- if callable(suffix):
- self.suffix = suffix
- else:
- self.suffix = _callable_adaptor(str(suffix))
-
- if callable(src_suffix):
self.src_suffix = src_suffix
- elif SCons.Util.is_String(src_suffix):
- self.src_suffix = _callable_adaptor([ str(src_suffix) ])
- else:
- self.src_suffix = _callable_adaptor(src_suffix)
-
+
self.target_factory = target_factory or node_factory
self.source_factory = source_factory or node_factory
self.scanner = scanner
def src_suffixes(self, env, args):
return map(lambda x, e=env: e.subst(_adjust_suffix(x)),
- apply(self.src_suffix, (), args))
+ self.src_suffix)
def get_src_suffix(self, env, args):
"""Get the first src_suffix in the list of src_suffixes."""
- ret = self.src_suffixes(env, args)
- if not ret:
+ if not self.src_suffix:
return ''
else:
- return ret[0]
+ return self.src_suffix[0]
def get_suffix(self, env, args):
- return env.subst(_adjust_suffix(apply(self.suffix, (), args)))
+ return env.subst(_adjust_suffix(self.suffix))
def get_prefix(self, env, args):
- return env.subst(apply(self.prefix, (), args))
+ return env.subst(self.prefix)
def targets(self, node):
"""Return the list of targets for this builder instance.
tgt = builder(env, target='test2', source=['test2.bar', 'test1.foo'])
try:
tgt.build()
- except SCons.Errors.BuildError, e:
- assert e.args[0] == SCons.Errors.UserError
+ except SCons.Errors.UserError:
flag = 1
assert flag, "UserError should be thrown when we build targets with files of different suffixes."
tgt = builder(env, target='t5', source='test5a.foo test5b.inb')
try:
tgt.build()
- except SCons.Errors.BuildError, e:
- assert e.args[0] == SCons.Errors.UserError
+ except SCons.Errors.UserError:
flag = 1
assert flag, "UserError should be thrown when we build targets with files of different suffixes."
tgt = builder(env, target='t6', source='test6a.bar test6b.ina')
try:
tgt.build()
- except SCons.Errors.BuildError, e:
- assert e.args[0] == SCons.Errors.UserError
+ except SCons.Errors.UserError:
flag = 1
assert flag, "UserError should be thrown when we build targets with files of different suffixes."
tgt = builder(env, target='t4', source='test4a.ina test4b.inb')
try:
tgt.build()
- except SCons.Errors.BuildError, e:
- assert e.args[0] == SCons.Errors.UserError
+ except SCons.Errors.UserError:
flag = 1
assert flag, "UserError should be thrown when we build targets with files of different suffixes."
import SCons.Scanner.Prog
import SCons.Util
-class SharedCmdGenerator:
- """A callable class that acts as a command generator.
- It is designed to hold on to 2 actions, and return
- one if the shared=1 keyword arg is supplied to the
- Builder method, and the other if not.
-
- Also, all target nodes will have the shared attribute
- set to match the vaue of the shared keyword argument,
- zero by default."""
- def __init__(self, static, shared):
- self.action_static = static
- self.action_shared = shared
-
- def __call__(self, target, source, env, shared=0, **kw):
- for src in source:
- try:
- if (src.attributes.shared and not shared) or \
- (shared and not src.attributes.shared):
- raise SCons.Errors.UserError("Source file: %s must be built with shared=%s in order to be compatible with target: %s" % (src, str(shared), target[0]))
- except AttributeError:
- pass
- for t in target:
- t.attributes.shared = shared
- if shared:
- return self.action_shared
- else:
- return self.action_static
-
def yaccEmitter(target, source, env, **kw):
# Yacc can be configured to emit a .h file as well
# as a .c file, if -d is specified on the command line.
emitter = yaccEmitter,
suffix = '$CXXFILESUFFIX')
-CAction = SCons.Action.Action("$CCCOM")
-ShCAction = SCons.Action.Action("$SHCCCOM")
-CXXAction = SCons.Action.Action("$CXXCOM")
-ShCXXAction = SCons.Action.Action("$SHCXXCOM")
-F77Action = SCons.Action.Action("$F77COM")
-ShF77Action = SCons.Action.Action("$SHF77COM")
-F77PPAction = SCons.Action.Action("$F77PPCOM")
-ShF77PPAction = SCons.Action.Action("$SHF77PPCOM")
+class SharedFlagChecker:
+ """This is a callable class that is used as
+ a build action for all objects, libraries, and programs.
+ Its job is to run before the "real" action that builds the
+ file, to make sure we aren't trying to link shared objects
+ into a static library/program, or static objects into a
+ shared library."""
+
+ def __init__(self, shared):
+ self.shared = shared
+
+ def __call__(self, source, target, env, **kw):
+ if kw.has_key('shared'):
+ raise SCons.Errors.UserError, "The shared= parameter to Library() or Object() no longer works.\nUse SharedObject() or SharedLibrary() instead."
+ for tgt in target:
+ tgt.attributes.shared = self.shared
+
+ for src in source:
+ if hasattr(src.attributes, 'shared'):
+ if self.shared and not src.attributes.shared:
+ raise SCons.Errors.UserError, "Source file: %s is static and is not compatible with shared target: %s" % (src, target[0])
+ elif not self.shared and src.attributes.shared:
+ raise SCons.Errors.UserError, "Source file: %s is shared and is not compatible with static target: %s" % (src, target[0])
+
+SharedCheck = SharedFlagChecker(1)
+StaticCheck = SharedFlagChecker(0)
+
+CAction = SCons.Action.Action([ StaticCheck, "$CCCOM" ])
+ShCAction = SCons.Action.Action([ SharedCheck, "$SHCCCOM" ])
+CXXAction = SCons.Action.Action([ StaticCheck, "$CXXCOM" ])
+ShCXXAction = SCons.Action.Action([ SharedCheck, "$SHCXXCOM" ])
+F77Action = SCons.Action.Action([ StaticCheck, "$F77COM" ])
+ShF77Action = SCons.Action.Action([ SharedCheck, "$SHF77COM" ])
+F77PPAction = SCons.Action.Action([ StaticCheck, "$F77PPCOM" ])
+ShF77PPAction = SCons.Action.Action([ SharedCheck, "$SHF77PPCOM" ])
if os.path.normcase('.c') == os.path.normcase('.C'):
# We're on a case-insensitive system, so .[CF] (upper case)
F_static = F77PPAction
F_shared = ShF77PPAction
-shared_obj = SCons.Builder.DictCmdGenerator({ ".C" : C_shared,
- ".cc" : ShCXXAction,
- ".cpp" : ShCXXAction,
- ".cxx" : ShCXXAction,
- ".c++" : ShCXXAction,
- ".C++" : ShCXXAction,
- ".c" : ShCAction,
- ".f" : ShF77Action,
- ".for" : ShF77Action,
- ".FOR" : ShF77Action,
- ".F" : F_shared,
- ".fpp" : ShF77PPAction,
- ".FPP" : ShF77PPAction })
-
-static_obj = SCons.Builder.DictCmdGenerator({ ".C" : C_static,
- ".cc" : CXXAction,
- ".cpp" : CXXAction,
- ".cxx" : CXXAction,
- ".c++" : CXXAction,
- ".C++" : CXXAction,
- ".c" : CAction,
- ".f" : F77Action,
- ".for" : F77Action,
- ".F" : F_static,
- ".FOR" : F77Action,
- ".fpp" : F77PPAction,
- ".FPP" : F77PPAction })
-
-Object = SCons.Builder.Builder(generator = \
- SharedCmdGenerator(static=SCons.Action.CommandGeneratorAction(static_obj),
- shared=SCons.Action.CommandGeneratorAction(shared_obj)),
- prefix = '$OBJPREFIX',
- suffix = '$OBJSUFFIX',
- src_suffix = static_obj.src_suffixes(),
- src_builder = [CFile, CXXFile])
+StaticObject = SCons.Builder.Builder(action = { ".C" : C_static,
+ ".cc" : CXXAction,
+ ".cpp" : CXXAction,
+ ".cxx" : CXXAction,
+ ".c++" : CXXAction,
+ ".C++" : CXXAction,
+ ".c" : CAction,
+ ".f" : F77Action,
+ ".for" : F77Action,
+ ".F" : F_static,
+ ".FOR" : F77Action,
+ ".fpp" : F77PPAction,
+ ".FPP" : F77PPAction },
+ prefix = '$OBJPREFIX',
+ suffix = '$OBJSUFFIX',
+ src_builder = [CFile, CXXFile])
+
+SharedObject = SCons.Builder.Builder(action = { ".C" : C_shared,
+ ".cc" : ShCXXAction,
+ ".cpp" : ShCXXAction,
+ ".cxx" : ShCXXAction,
+ ".c++" : ShCXXAction,
+ ".C++" : ShCXXAction,
+ ".c" : ShCAction,
+ ".f" : ShF77Action,
+ ".for" : ShF77Action,
+ ".FOR" : ShF77Action,
+ ".F" : F_shared,
+ ".fpp" : ShF77PPAction,
+ ".FPP" : ShF77PPAction },
+ prefix = '$OBJPREFIX',
+ suffix = '$OBJSUFFIX',
+ src_builder = [CFile, CXXFile])
def win32TempFileMunge(env, cmd_list, for_signature):
"""Given a list of command line arguments, see if it is too
args.extend(map(SCons.Util.to_String, source))
return win32TempFileMunge(env, args, for_signature)
-Program = SCons.Builder.Builder(action='$LINKCOM',
+ProgScan = SCons.Scanner.Prog.ProgScan()
+
+Program = SCons.Builder.Builder(action=[ StaticCheck, '$LINKCOM' ],
prefix='$PROGPREFIX',
suffix='$PROGSUFFIX',
src_suffix='$OBJSUFFIX',
- src_builder=Object,
- scanner = SCons.Scanner.Prog.ProgScan())
-
-class LibAffixGenerator:
- def __init__(self, static, shared):
- self.static_affix = static
- self.shared_affix = shared
-
- def __call__(self, shared=0, **kw):
- if shared:
- return self.shared_affix
- return self.static_affix
+ src_builder=StaticObject,
+ scanner = ProgScan)
-def win32LibGenerator(target, source, env, for_signature, shared=1,
- no_import_lib=0):
+def win32LibGenerator(target, source, env, for_signature, no_import_lib=0):
listCmd = [ "$SHLINK", "$SHLINKFLAGS" ]
for tgt in target:
listCmd.append(str(src))
return win32TempFileMunge(env, listCmd, for_signature)
-def win32LibEmitter(target, source, env, shared=0,
- no_import_lib=0):
- if shared:
- dll = None
- for tgt in target:
- ext = os.path.splitext(str(tgt))[1]
- if ext == env.subst("$SHLIBSUFFIX"):
- dll = tgt
- break
- if not dll:
- raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX"))
+def win32LibEmitter(target, source, env, no_import_lib=0):
+ dll = None
+ for tgt in target:
+ ext = os.path.splitext(str(tgt))[1]
+ if ext == env.subst("$SHLIBSUFFIX"):
+ dll = tgt
+ 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],
- source):
-
- # append a def file to the list of sources
- source.append("%s%s" % (os.path.splitext(str(dll))[0],
- env.subst("$WIN32DEFSUFFIX")))
- 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"),
- os.path.splitext(str(dll))[0],
- env.subst("$LIBSUFFIX")))
+ 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],
+ source):
+
+ # append a def file to the list of sources
+ source.append("%s%s" % (os.path.splitext(str(dll))[0],
+ env.subst("$WIN32DEFSUFFIX")))
+ 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"),
+ os.path.splitext(str(dll))[0],
+ env.subst("$LIBSUFFIX")))
return (target, source)
-Library = SCons.Builder.Builder(generator = \
- SharedCmdGenerator(shared="$SHLINKCOM",
- static="$ARCOM"),
- emitter="$LIBEMITTER",
- prefix = \
- LibAffixGenerator(static='$LIBPREFIX',
- shared='$SHLIBPREFIX'),
- suffix = \
- LibAffixGenerator(static='$LIBSUFFIX',
- shared='$SHLIBSUFFIX'),
- src_suffix = '$OBJSUFFIX',
- src_builder = Object)
+StaticLibrary = SCons.Builder.Builder(action=[ StaticCheck, "$ARCOM" ],
+ prefix = '$LIBPREFIX',
+ suffix = '$LIBSUFFIX',
+ src_suffix = '$OBJSUFFIX',
+ src_builder = StaticObject)
+
+SharedLibrary = SCons.Builder.Builder(action=[ SharedCheck, "$SHLINKCOM" ],
+ emitter="$LIBEMITTER",
+ prefix = '$SHLIBPREFIX',
+ suffix = '$SHLIBSUFFIX',
+ scanner = ProgScan,
+ src_suffix = '$OBJSUFFIX',
+ src_builder = SharedObject)
LaTeXAction = SCons.Action.Action('$LATEXCOM')
'CFile' : CFile,
'CXXFile' : CXXFile,
'DVI' : DVI,
- 'Library' : Library,
- 'Object' : Object,
+ 'Library' : StaticLibrary,
+ 'StaticLibrary' : StaticLibrary,
+ 'SharedLibrary' : SharedLibrary,
+ 'Object' : StaticObject,
+ 'StaticObject' : StaticObject,
+ 'SharedObject' : SharedObject,
'PDF' : PDF,
'PostScript' : PostScript,
'Program' : Program },
'CFile' : CFile,
'CXXFile' : CXXFile,
'DVI' : DVI,
- 'Library' : Library,
- 'Object' : Object,
+ 'Library' : StaticLibrary,
+ 'StaticLibrary' : StaticLibrary,
+ 'SharedLibrary' : SharedLibrary,
+ 'Object' : StaticObject,
+ 'StaticObject' : StaticObject,
+ 'SharedObject' : SharedObject,
'PDF' : PDF,
'PostScript' : PostScript,
'Program' : Program },
import sys
import SCons.Sig
-from SCons.Errors import BuildError
+from SCons.Errors import BuildError, UserError
import SCons.Util
# Node states
self.generate_build_args())
except KeyboardInterrupt:
raise
+ except UserError:
+ raise
except:
raise BuildError(self, "Exception",
sys.exc_type,
globals['GetCommandHandler'] = SCons.Action.GetCommandHandler
globals['Help'] = Help
globals['Import'] = Import
- globals['Library'] = SCons.Defaults.Library
- globals['Object'] = SCons.Defaults.Object
+ globals['Library'] = SCons.Defaults.StaticLibrary
+ globals['Object'] = SCons.Defaults.StaticObject
+ globals['StaticLibrary'] = SCons.Defaults.StaticLibrary
+ globals['StaticObject'] = SCons.Defaults.StaticObject
+ globals['SharedLibrary'] = SCons.Defaults.SharedLibrary
+ globals['SharedObject'] = SCons.Defaults.SharedObject
globals['Platform'] = SCons.Platform.Platform
globals['Program'] = SCons.Defaults.Program
globals['Return'] = Return
traceback.print_exception(e.args[0], e.args[1],
e.args[2])
raise
+ except UserError, e:
+ # We aren't being called out of a user frame, so
+ # don't try to walk the stack, just print the error.
+ sys.stderr.write("\nSCons error: %s\n" % e)
except:
sys.stderr.write("scons: *** %s\n" % sys.exc_value)
raise
if sys.platform == 'win32':
_exe = '.exe'
+ _dll = '.dll'
+ lib_ = ''
else:
_exe = ''
+ _dll = '.so'
+ lib_ = 'lib'
test = TestSCons.TestSCons()
test.subdir('lib1', 'lib2')
prog1 = test.workpath('prog') + _exe
-prog2 = test.workpath('prog2') + _exe
+prog2 = test.workpath(lib_ + 'shlib') + _dll
test.write('SConstruct', """
env1 = Environment(LIBS = [ 'foo1' ],
LIBPATH = [ './lib1' ])
-prog = env1.Object('prog', 'prog.c')
f1 = env1.Object('f1', 'f1.c')
-env1.Program(target = 'prog', source = prog)
+env1.Program(target = 'prog', source = 'prog.c')
env1.Library(target = './lib1/foo1', source = f1)
env2 = Environment(LIBS = 'foo2',
LIBPATH = '.')
-env2.Program(target = 'prog2', source = prog)
+env2.SharedLibrary(target = 'shlib', source = 'shlib.c')
env2.Library(target = 'foo2', source = f1)
""")
}
""")
+test.write('shlib.c', r"""
+void f1(void);
+int
+test()
+{
+ f1();
+}
+""")
+
test.write('prog.c', r"""
void f1(void);
int
test.run(program = prog1,
stdout = "f1.c\nprog.c\n")
-test.run(program = prog2,
- stdout = "f1.c\nprog.c\n")
oldtime1 = os.path.getmtime(prog1)
oldtime2 = os.path.getmtime(prog2)
test.run(arguments = '.')
test.run(program = prog1,
stdout = "f1.c 1\nprog.c\n")
-test.run(program = prog2,
- stdout = "f1.c 1\nprog.c\n")
+test.fail_test(oldtime2 == os.path.getmtime(prog2))
#test.up_to_date(arguments = '.')
# Change LIBPATH and make sure we don't rebuild because of it.
test.write('SConstruct', """
env1 = Environment(LIBS = [ 'foo1' ],
LIBPATH = [ './lib1', './lib2' ])
-prog = env1.Object('prog', 'prog.c')
f1 = env1.Object('f1', 'f1.c')
-env1.Program(target = 'prog', source = prog)
+env1.Program(target = 'prog', source = 'prog.c')
env1.Library(target = './lib1/foo1', source = f1)
env2 = Environment(LIBS = 'foo2',
LIBPATH = Split('. ./lib2'))
-env2.Program(target = 'prog2', source = prog)
+env2.SharedLibrary(target = 'shlib', source = 'shlib.c')
env2.Library(target = 'foo2', source = f1)
""")
test.run(arguments = '.')
test.run(program = prog1,
stdout = "f1.c 2\nprog.c\n")
-test.run(program = prog2,
- stdout = "f1.c 2\nprog.c\n")
test.up_to_date(arguments = '.')
python = sys.executable
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
-
test = TestSCons.TestSCons()
test.write("wrapper.py",
foo = Environment()
shcc = foo.Dictionary('SHCC')
bar = Environment(SHCC = r'%s wrapper.py ' + shcc)
-foo.Program(target = 'foo', source = 'foo.c', shared = 1)
-bar.Program(target = 'bar', source = 'bar.c', shared = 1)
+foo.SharedObject(target = 'foo/foo', source = 'foo.c')
+bar.SharedObject(target = 'bar/bar', source = 'bar.c')
""" % python)
test.write('foo.c', r"""
""")
-test.run(arguments = 'foo' + _exe)
+test.run(arguments = 'foo')
test.fail_test(os.path.exists(test.workpath('wrapper.out')))
-test.run(arguments = 'bar' + _exe)
+test.run(arguments = 'bar')
test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
import sys
import TestSCons
+import os
if sys.platform == 'win32':
_obj = '.obj'
_obj = '.o'
fooflags = '-DFOO'
barflags = '-DBAR'
+
+if os.name == 'posix':
+ os.environ['LD_LIBRARY_PATH'] = '.'
test = TestSCons.TestSCons()
test.write('SConstruct', """
-foo = Environment(SHCCFLAGS = '%s')
-bar = Environment(SHCCFLAGS = '%s')
-foo.Object(target = 'foo%s', source = 'prog.c', shared = 1)
-bar.Object(target = 'bar%s', source = 'prog.c', shared = 1)
-foo.Program(target = 'foo', source = 'foo%s', shared = 1)
-bar.Program(target = 'bar', source = 'bar%s', shared = 1)
+foo = Environment(SHCCFLAGS = '%s', WIN32_INSERT_DEF=1)
+bar = Environment(SHCCFLAGS = '%s', WIN32_INSERT_DEF=1)
+foo.SharedObject(target = 'foo%s', source = 'prog.c')
+bar.SharedObject(target = 'bar%s', source = 'prog.c')
+foo.SharedLibrary(target = 'foo', source = 'foo%s')
+bar.SharedLibrary(target = 'bar', source = 'bar%s')
+
+fooMain = foo.Copy(LIBS='foo', LIBPATH='.')
+foo_obj = fooMain.Object(target='foomain', source='main.c')
+fooMain.Program(target='fooprog', source=foo_obj)
+
+barMain = bar.Copy(LIBS='bar', LIBPATH='.')
+bar_obj = barMain.Object(target='barmain', source='main.c')
+barMain.Program(target='barprog', source=bar_obj)
""" % (fooflags, barflags, _obj, _obj, _obj, _obj))
+test.write('foo.def', r"""
+LIBRARY "foo"
+DESCRIPTION "Foo Shared Library"
+
+EXPORTS
+ doIt
+""")
+
+test.write('bar.def', r"""
+LIBRARY "foo"
+DESCRIPTION "Foo Shared Library"
+
+EXPORTS
+ doIt
+""")
+
test.write('prog.c', r"""
-int
-main(int argc, char *argv[])
+void
+doIt()
{
- argv[argc++] = "--";
#ifdef FOO
printf("prog.c: FOO\n");
#endif
#ifdef BAR
printf("prog.c: BAR\n");
#endif
- exit (0);
}
""")
+test.write('main.c', r"""
+
+void doIt();
+
+int
+main(int argc, char* argv[])
+{
+ doIt();
+ return 0;
+}
+""")
test.run(arguments = '.')
-test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n")
-test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n")
+test.run(program = test.workpath('fooprog'), stdout = "prog.c: FOO\n")
+test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n")
test.write('SConstruct', """
-bar = Environment(SHCCFLAGS = '%s')
-bar.Object(target = 'foo%s', source = 'prog.c', shared = 1)
-bar.Object(target = 'bar%s', source = 'prog.c', shared = 1)
-bar.Program(target = 'foo', source = 'foo%s', shared = 1)
-bar.Program(target = 'bar', source = 'bar%s', shared = 1)
+bar = Environment(SHCCFLAGS = '%s', WIN32_INSERT_DEF=1)
+bar.SharedObject(target = 'foo%s', source = 'prog.c')
+bar.SharedObject(target = 'bar%s', source = 'prog.c')
+bar.SharedLibrary(target = 'foo', source = 'foo%s')
+bar.SharedLibrary(target = 'bar', source = 'bar%s')
+
+barMain = bar.Copy(LIBS='bar', LIBPATH='.')
+foo_obj = barMain.Object(target='foomain', source='main.c')
+bar_obj = barMain.Object(target='barmain', source='main.c')
+barMain.Program(target='barprog', source=foo_obj)
+barMain.Program(target='fooprog', source=bar_obj)
""" % (barflags, _obj, _obj, _obj, _obj))
test.run(arguments = '.')
-test.run(program = test.workpath('foo'), stdout = "prog.c: BAR\n")
-test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n")
+test.run(program = test.workpath('fooprog'), stdout = "prog.c: BAR\n")
+test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n")
test.pass_test()
python = sys.executable
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
-
test = TestSCons.TestSCons()
test.write("wrapper.py",
foo = Environment()
shcxx = foo.Dictionary('SHCXX')
bar = Environment(SHCXX = r'%s wrapper.py ' + shcxx)
-foo.Program(target = 'foo', source = 'foo.cpp', shared = 1)
-bar.Program(target = 'bar', source = 'bar.cpp', shared = 1)
+foo.SharedObject(target = 'foo/foo', source = 'foo.cpp')
+bar.SharedObject(target = 'bar/bar', source = 'bar.cpp')
""" % python)
test.write('foo.cpp', r"""
""")
-test.run(arguments = 'foo' + _exe)
+test.run(arguments = 'foo')
test.fail_test(os.path.exists(test.workpath('wrapper.out')))
-test.run(arguments = 'bar' + _exe)
+test.run(arguments = 'bar')
test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
-
#!/usr/bin/env python
#
# Copyright (c) 2001, 2002 Steven Knight
import sys
import TestSCons
+import os
if sys.platform == 'win32':
_obj = '.obj'
_obj = '.o'
fooflags = '-DFOO'
barflags = '-DBAR'
+
+if os.name == 'posix':
+ os.environ['LD_LIBRARY_PATH'] = '.'
test = TestSCons.TestSCons()
test.write('SConstruct', """
-foo = Environment(SHCXXFLAGS = '%s')
-bar = Environment(SHCXXFLAGS = '%s')
-foo.Object(target = 'foo%s', source = 'prog.cpp', shared = 1)
-bar.Object(target = 'bar%s', source = 'prog.cpp', shared = 1)
-foo.Program(target = 'foo', source = 'foo%s', shared = 1)
-bar.Program(target = 'bar', source = 'bar%s', shared = 1)
+foo = Environment(SHCXXFLAGS = '%s', WIN32_INSERT_DEF=1)
+bar = Environment(SHCXXFLAGS = '%s', WIN32_INSERT_DEF=1)
+foo.SharedObject(target = 'foo%s', source = 'prog.cpp')
+bar.SharedObject(target = 'bar%s', source = 'prog.cpp')
+foo.SharedLibrary(target = 'foo', source = 'foo%s')
+bar.SharedLibrary(target = 'bar', source = 'bar%s')
+
+fooMain = foo.Copy(LIBS='foo', LIBPATH='.')
+foo_obj = fooMain.Object(target='foomain', source='main.c')
+fooMain.Program(target='fooprog', source=foo_obj)
+
+barMain = bar.Copy(LIBS='bar', LIBPATH='.')
+bar_obj = barMain.Object(target='barmain', source='main.c')
+barMain.Program(target='barprog', source=bar_obj)
""" % (fooflags, barflags, _obj, _obj, _obj, _obj))
+test.write('foo.def', r"""
+LIBRARY "foo"
+DESCRIPTION "Foo Shared Library"
+
+EXPORTS
+ doIt
+""")
+
+test.write('bar.def', r"""
+LIBRARY "foo"
+DESCRIPTION "Foo Shared Library"
+
+EXPORTS
+ doIt
+""")
+
test.write('prog.cpp', r"""
#include <stdio.h>
-#include <stdlib.h>
-int
-main(int argc, char *argv[])
+
+extern "C" void
+doIt()
{
- argv[argc++] = "--";
#ifdef FOO
- printf("prog.c: FOO\n");
+ printf("prog.cpp: FOO\n");
#endif
#ifdef BAR
- printf("prog.c: BAR\n");
+ printf("prog.cpp: BAR\n");
#endif
- exit (0);
}
""")
+test.write('main.c', r"""
+
+void doIt();
+
+int
+main(int argc, char* argv[])
+{
+ doIt();
+ return 0;
+}
+""")
test.run(arguments = '.')
-test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n")
-test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n")
+test.run(program = test.workpath('fooprog'), stdout = "prog.cpp: FOO\n")
+test.run(program = test.workpath('barprog'), stdout = "prog.cpp: BAR\n")
test.write('SConstruct', """
-bar = Environment(SHCXXFLAGS = '%s')
-bar.Object(target = 'foo%s', source = 'prog.cpp', shared = 1)
-bar.Object(target = 'bar%s', source = 'prog.cpp', shared = 1)
-bar.Program(target = 'foo', source = 'foo%s', shared = 1)
-bar.Program(target = 'bar', source = 'bar%s', shared = 1)
+bar = Environment(SHCXXFLAGS = '%s', WIN32_INSERT_DEF=1)
+bar.SharedObject(target = 'foo%s', source = 'prog.cpp')
+bar.SharedObject(target = 'bar%s', source = 'prog.cpp')
+bar.SharedLibrary(target = 'foo', source = 'foo%s')
+bar.SharedLibrary(target = 'bar', source = 'bar%s')
+
+barMain = bar.Copy(LIBS='bar', LIBPATH='.')
+foo_obj = barMain.Object(target='foomain', source='main.c')
+bar_obj = barMain.Object(target='barmain', source='main.c')
+barMain.Program(target='barprog', source=foo_obj)
+barMain.Program(target='fooprog', source=bar_obj)
""" % (barflags, _obj, _obj, _obj, _obj))
test.run(arguments = '.')
-test.run(program = test.workpath('foo'), stdout = "prog.c: BAR\n")
-test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n")
+test.run(program = test.workpath('fooprog'), stdout = "prog.cpp: BAR\n")
+test.run(program = test.workpath('barprog'), stdout = "prog.cpp: BAR\n")
test.pass_test()
python = sys.executable
if sys.platform == 'win32':
- _exe = '.exe'
+ _obj = '.obj'
else:
- _exe = ''
+ _obj = '.o'
test = TestSCons.TestSCons()
if sys.platform == 'win32':
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
test.write('myg77.py', r"""
import sys
args = sys.argv[1:]
else:
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
test.write('myg77.py', r"""
import getopt
import sys
test.write('SConstruct', """
-env = Environment(LINK = r'%s mylink.py',
- SHF77 = r'%s myg77.py')
-env.Program(target = 'test1', source = 'test1.f', shared = 1)
-env.Program(target = 'test2', source = 'test2.for', shared = 1)
-env.Program(target = 'test3', source = 'test3.FOR', shared = 1)
-env.Program(target = 'test4', source = 'test4.F', shared = 1)
-env.Program(target = 'test5', source = 'test5.fpp', shared = 1)
-env.Program(target = 'test6', source = 'test6.FPP', shared = 1)
-""" % (python, python))
+env = Environment(SHF77 = r'%s myg77.py')
+env.SharedObject(target = 'test1', source = 'test1.f')
+env.SharedObject(target = 'test2', source = 'test2.for')
+env.SharedObject(target = 'test3', source = 'test3.FOR')
+env.SharedObject(target = 'test4', source = 'test4.F')
+env.SharedObject(target = 'test5', source = 'test5.fpp')
+env.SharedObject(target = 'test6', source = 'test6.FPP')
+""" % python)
test.write('test1.f', r"""This is a .f file.
#g77
-#link
""")
test.write('test2.for', r"""This is a .for file.
#g77
-#link
""")
test.write('test3.FOR', r"""This is a .FOR file.
#g77
-#link
""")
test.write('test4.F', r"""This is a .F file.
#g77
-#link
""")
test.write('test5.fpp', r"""This is a .fpp file.
#g77
-#link
""")
test.write('test6.FPP', r"""This is a .FPP file.
#g77
-#link
""")
test.run(arguments = '.', stderr = None)
-test.fail_test(test.read('test1' + _exe) != "This is a .f file.\n")
+test.fail_test(test.read('test1' + _obj) != "This is a .f file.\n")
-test.fail_test(test.read('test2' + _exe) != "This is a .for file.\n")
+test.fail_test(test.read('test2' + _obj) != "This is a .for file.\n")
-test.fail_test(test.read('test3' + _exe) != "This is a .FOR file.\n")
+test.fail_test(test.read('test3' + _obj) != "This is a .FOR file.\n")
-test.fail_test(test.read('test4' + _exe) != "This is a .F file.\n")
+test.fail_test(test.read('test4' + _obj) != "This is a .F file.\n")
-test.fail_test(test.read('test5' + _exe) != "This is a .fpp file.\n")
+test.fail_test(test.read('test5' + _obj) != "This is a .fpp file.\n")
-test.fail_test(test.read('test6' + _exe) != "This is a .FPP file.\n")
+test.fail_test(test.read('test6' + _obj) != "This is a .FPP file.\n")
foo = Environment(LIBS = 'g2c')
shf77 = foo.Dictionary('SHF77')
bar = foo.Copy(SHF77 = r'%s wrapper.py ' + shf77)
-foo.Program(target = 'foo', source = 'foo.f', shared = 1)
-bar.Program(target = 'bar', source = 'bar.f', shared = 1)
+foo.SharedObject(target = 'foo/foo', source = 'foo.f')
+bar.SharedObject(target = 'bar/bar', source = 'bar.f')
""" % python)
test.write('foo.f', r"""
""")
- test.run(arguments = 'foo' + _exe, stderr = None)
-
- test.run(program = test.workpath('foo'), stdout = " foo.f\n")
+ test.run(arguments = 'foo', stderr = None)
test.fail_test(os.path.exists(test.workpath('wrapper.out')))
- test.run(arguments = 'bar' + _exe)
-
- test.run(program = test.workpath('bar'), stdout = " bar.f\n")
+ test.run(arguments = 'bar')
test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
python = sys.executable
if sys.platform == 'win32':
- _exe = '.exe'
+ _obj = '.obj'
else:
- _exe = ''
+ _obj = '.o'
test = TestSCons.TestSCons()
if sys.platform == 'win32':
- _exe = '.exe'
-
o = ' -x /c'
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
test.write('myg77.py', r"""
import sys
args = sys.argv[1:]
else:
- _exe = ''
-
o = ' -x -c'
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
test.write('myg77.py', r"""
import getopt
import sys
test.write('SConstruct', """
env = Environment(LINK = r'%s mylink.py',
SHF77 = r'%s myg77.py', SHF77FLAGS = '-x')
-env.Program(target = 'test1', source = 'test1.f', shared = 1)
-env.Program(target = 'test2', source = 'test2.for', shared = 1)
-env.Program(target = 'test3', source = 'test3.FOR', shared = 1)
-env.Program(target = 'test4', source = 'test4.F', shared = 1)
-env.Program(target = 'test5', source = 'test5.fpp', shared = 1)
-env.Program(target = 'test6', source = 'test6.FPP', shared = 1)
+env.SharedObject(target = 'test1', source = 'test1.f')
+env.SharedObject(target = 'test2', source = 'test2.for')
+env.SharedObject(target = 'test3', source = 'test3.FOR')
+env.SharedObject(target = 'test4', source = 'test4.F')
+env.SharedObject(target = 'test5', source = 'test5.fpp')
+env.SharedObject(target = 'test6', source = 'test6.FPP')
""" % (python, python))
test.write('test1.f', r"""This is a .f file.
#g77
-#link
""")
test.write('test2.for', r"""This is a .for file.
#g77
-#link
""")
test.write('test3.FOR', r"""This is a .FOR file.
#g77
-#link
""")
test.write('test4.F', r"""This is a .F file.
#g77
-#link
""")
test.write('test5.fpp', r"""This is a .fpp file.
#g77
-#link
""")
test.write('test6.FPP', r"""This is a .FPP file.
#g77
-#link
""")
test.run(arguments = '.', stderr = None)
-test.fail_test(test.read('test1' + _exe) != "%s\nThis is a .f file.\n" % o)
+test.fail_test(test.read('test1' + _obj) != "%s\nThis is a .f file.\n" % o)
-test.fail_test(test.read('test2' + _exe) != "%s\nThis is a .for file.\n" % o)
+test.fail_test(test.read('test2' + _obj) != "%s\nThis is a .for file.\n" % o)
-test.fail_test(test.read('test3' + _exe) != "%s\nThis is a .FOR file.\n" % o)
+test.fail_test(test.read('test3' + _obj) != "%s\nThis is a .FOR file.\n" % o)
-test.fail_test(test.read('test4' + _exe) != "%s\nThis is a .F file.\n" % o)
+test.fail_test(test.read('test4' + _obj) != "%s\nThis is a .F file.\n" % o)
-test.fail_test(test.read('test5' + _exe) != "%s\nThis is a .fpp file.\n" % o)
+test.fail_test(test.read('test5' + _obj) != "%s\nThis is a .fpp file.\n" % o)
-test.fail_test(test.read('test6' + _exe) != "%s\nThis is a .FPP file.\n" % o)
+test.fail_test(test.read('test6' + _obj) != "%s\nThis is a .FPP file.\n" % o)
foo = Environment(LIBS = 'g2c')
shf77 = foo.Dictionary('SHF77')
bar = foo.Copy(SHF77 = r'%s wrapper.py ' + shf77, SHF77FLAGS = '-Ix')
-foo.Program(target = 'foo', source = 'foo.f', shared = 1)
-bar.Program(target = 'bar', source = 'bar.f', shared = 1)
+foo.SharedLibrary(target = 'foo/foo', source = 'foo.f')
+bar.SharedLibrary(target = 'bar/bar', source = 'bar.f')
""" % python)
test.write('foo.f', r"""
""")
- test.run(arguments = 'foo' + _exe, stderr = None)
-
- test.run(program = test.workpath('foo'), stdout = " foo.f\n")
+ test.run(arguments = 'foo', stderr = None)
test.fail_test(os.path.exists(test.workpath('wrapper.out')))
- test.run(arguments = 'bar' + _exe)
-
- test.run(program = test.workpath('bar'), stdout = " bar.f\n")
+ test.run(arguments = 'bar')
test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
test.write('SConstruct', """
env = Environment(SHLIBPREFIX = 'shlib-')
-env.Library(target = 'foo', source = 'foo.c', shared = 1)
+env.SharedLibrary(target = 'foo', source = 'foo.c')
""")
test.write('foo.c', r"""
test.write('SConstruct', """
env = Environment(SHLIBSUFFIX = '.shlib')
-env.Library (target = 'foo', source = 'foo.c', shared = 1)
+env.SharedLibrary(target = 'foo', source = 'foo.c')
""")
test.write('foo.c', r"""
foo = Environment()
shlink = foo.Dictionary('SHLINK')
bar = Environment(SHLINK = r'%s wrapper.py ' + shlink)
-foo.Library(target = 'foo', source = 'foo.c', shared = 1)
-bar.Library(target = 'bar', source = 'bar.c', shared = 1)
+foo.SharedLibrary(target = 'foo', source = 'foo.c')
+bar.SharedLibrary(target = 'bar', source = 'bar.c')
""" % python)
test.write('foo.c', r"""
shlinkflags = foo.Dictionary('SHLINKFLAGS')
bar = Environment(SHLINK = '',
SHLINKFLAGS = r'%s wrapper.py ' + shlink + ' ' + shlinkflags)
-foo.Library(target = 'foo', source = 'foo.c', shared = 1)
-bar.Library(target = 'bar', source = 'bar.c', shared = 1)
+foo.SharedLibrary(target = 'foo', source = 'foo.c')
+bar.SharedLibrary(target = 'bar', source = 'bar.c')
""" % python)
test.write('foo.c', r"""
env=Environment(WIN32_INSERT_DEF=1)
env2 = Environment(LIBS = [ 'foo1', 'foo2', 'foo3' ],
LIBPATH = [ '.' ])
-env.Library(target = 'foo1', source = 'f1.c', shared=1)
-env.Library(target = 'foo2', source = Split('f2a.c f2b.c f2c.c'), shared=1)
-env.Library(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'], shared=1)
+env.SharedLibrary(target = 'foo1', source = 'f1.c')
+env.SharedLibrary(target = 'foo2', source = Split('f2a.c f2b.c f2c.c'))
+env.SharedLibrary(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'])
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))
+obj = env.Object('foo', 'foo.c')
+Default(env.SharedLibrary(target = 'foo', source = obj))
+""")
+
+test.write('SConstructFoo2', """
+env=Environment()
+obj = env.SharedObject('foo', 'foo.c')
+Default(env.Library(target = 'foo', source = obj))
""")
test.write('foo.c', r"""
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\..* must be built with shared=1 in order to be compatible with target: .*
-File ".*", line .*, in .*
+SCons error: Source file: foo\..* is static and is not compatible with shared target: .*
+'''
+)
+
+test.run(arguments = '-f SConstructFoo2', status=2, stderr='''
+SCons error: Source file: foo\..* is shared and is not compatible with static target: .*
'''
)
linkflags = linkflags + r' %s'
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 = 'bar.c', shared=1, no_import_lib=1)
+# SharedLibrary() uses $LINKFLAGS by default.
+env.SharedLibrary(target = 'bar', source = 'bar.c', no_import_lib=1)
""" % (linkflag, linkflag))
test.write('foo.c', r"""