summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-06-15 04:53:49 (GMT)
committerSteven Knight <knight@baldmt.com>2002-06-15 04:53:49 (GMT)
commit77d43537975b406379979d599894971bf4a225f2 (patch)
tree93c8e6987a60b53f5ca0e3bc986bdcb4208893f3
parentcef5b7fa735eb4e405fab5f852df8e7d53c76954 (diff)
downloadSCons-77d43537975b406379979d599894971bf4a225f2.zip
SCons-77d43537975b406379979d599894971bf4a225f2.tar.gz
SCons-77d43537975b406379979d599894971bf4a225f2.tar.bz2
Add LIBS and LIBPATH dependencies for shared libraries. (Charles Crain)
-rw-r--r--doc/man/scons.1116
-rw-r--r--src/CHANGES.txt12
-rw-r--r--src/RELEASE.txt10
-rw-r--r--src/engine/SCons/Action.py4
-rw-r--r--src/engine/SCons/ActionTests.py12
-rw-r--r--src/engine/SCons/Builder.py31
-rw-r--r--src/engine/SCons/BuilderTests.py12
-rw-r--r--src/engine/SCons/Defaults.py251
-rw-r--r--src/engine/SCons/Node/__init__.py4
-rw-r--r--src/engine/SCons/Script/SConscript.py8
-rw-r--r--src/engine/SCons/Script/__init__.py4
-rw-r--r--test/LIBPATH.py32
-rw-r--r--test/SHCC.py13
-rw-r--r--test/SHCCFLAGS.py81
-rw-r--r--test/SHCXX.py13
-rw-r--r--test/SHCXXFLAGS.py88
-rw-r--r--test/SHF77.py83
-rw-r--r--test/SHF77FLAGS.py82
-rw-r--r--test/SHLIBPREFIX.py2
-rw-r--r--test/SHLIBSUFFIX.py2
-rw-r--r--test/SHLINK.py4
-rw-r--r--test/SHLINKFLAGS.py4
-rw-r--r--test/SharedLibrary.py24
-rw-r--r--test/long-lines.py4
24 files changed, 464 insertions, 432 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index 6252267..79ca4b7 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -723,8 +723,9 @@ env.Program('bar', 'bar.c foo.c')
.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
@@ -749,22 +750,32 @@ The target object file prefix and suffix (if any) are automatically
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.
@@ -783,32 +794,47 @@ automatically added to the target. Example:
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
@@ -817,17 +843,18 @@ listed in the targets.
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
@@ -1878,27 +1905,12 @@ builder with the target.
.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
@@ -1971,9 +1983,9 @@ env.MyBuild('foo.out', 'foo.in', my_arg = 'xyzzy')
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
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index e65a5ce..c186d6a 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -26,6 +26,18 @@ RELEASE 0.08 -
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,
diff --git a/src/RELEASE.txt b/src/RELEASE.txt
index 9793e8a..5a16ddd 100644
--- a/src/RELEASE.txt
+++ b/src/RELEASE.txt
@@ -56,6 +56,16 @@ RELEASE 0.08 -
(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
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index f8d37ee..c222d26 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -491,7 +491,7 @@ class ListAction(ActionBase):
def execute(self, **kw):
for l in self.list:
r = apply(l.execute, (), kw)
- if r != 0:
+ if r:
return r
return 0
@@ -501,4 +501,4 @@ class ListAction(ActionBase):
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, "")
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index 1a0ec18..c1425ef 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -287,7 +287,6 @@ class ListActionTestCase(unittest.TestCase):
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
@@ -295,8 +294,15 @@ class ListActionTestCase(unittest.TestCase):
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):
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py
index aa71214..94a8946 100644
--- a/src/engine/SCons/Builder.py
+++ b/src/engine/SCons/Builder.py
@@ -209,24 +209,14 @@ class BuilderBase:
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
@@ -328,21 +318,20 @@ class BuilderBase:
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.
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py
index 4651688..e1fc8fc 100644
--- a/src/engine/SCons/BuilderTests.py
+++ b/src/engine/SCons/BuilderTests.py
@@ -601,8 +601,7 @@ class BuilderTestCase(unittest.TestCase):
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."
@@ -646,8 +645,7 @@ class BuilderTestCase(unittest.TestCase):
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."
@@ -655,8 +653,7 @@ class BuilderTestCase(unittest.TestCase):
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."
@@ -664,8 +661,7 @@ class BuilderTestCase(unittest.TestCase):
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."
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index aa8a643..e7a49b8 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -53,34 +53,6 @@ import SCons.Scanner.Fortran
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.
@@ -104,14 +76,41 @@ CXXFile = SCons.Builder.Builder(action = { '.ll' : '$LEXCOM',
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)
@@ -129,41 +128,39 @@ else:
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
@@ -193,25 +190,16 @@ def win32LinkGenerator(env, target, source, for_signature, **kw):
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:
@@ -235,47 +223,46 @@ 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,
- 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')
@@ -480,8 +467,12 @@ def make_win32_env_from_paths(include, lib, path):
'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 },
@@ -589,8 +580,12 @@ if os.name == 'posix':
'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 },
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 483de10..22d6072 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -37,7 +37,7 @@ import copy
import sys
import SCons.Sig
-from SCons.Errors import BuildError
+from SCons.Errors import BuildError, UserError
import SCons.Util
# Node states
@@ -116,6 +116,8 @@ class Node:
self.generate_build_args())
except KeyboardInterrupt:
raise
+ except UserError:
+ raise
except:
raise BuildError(self, "Exception",
sys.exc_type,
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 44ec7ce..7fcdf77 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -259,8 +259,12 @@ def BuildDefaultGlobals():
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
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 89d26b2..879f6d1 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -93,6 +93,10 @@ class BuildTask(SCons.Taskmaster.Task):
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
diff --git a/test/LIBPATH.py b/test/LIBPATH.py
index d0bb065..0176c07 100644
--- a/test/LIBPATH.py
+++ b/test/LIBPATH.py
@@ -31,29 +31,32 @@ import time
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)
""")
@@ -65,6 +68,15 @@ f1(void)
}
""")
+test.write('shlib.c', r"""
+void f1(void);
+int
+test()
+{
+ f1();
+}
+""")
+
test.write('prog.c', r"""
void f1(void);
int
@@ -81,8 +93,6 @@ test.run(arguments = '.')
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)
@@ -103,23 +113,21 @@ f1(void)
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)
""")
@@ -136,8 +144,6 @@ f1(void)
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 = '.')
diff --git a/test/SHCC.py b/test/SHCC.py
index 1313272..1d01663 100644
--- a/test/SHCC.py
+++ b/test/SHCC.py
@@ -31,11 +31,6 @@ import TestSCons
python = sys.executable
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
-
test = TestSCons.TestSCons()
test.write("wrapper.py",
@@ -50,8 +45,8 @@ test.write('SConstruct', """
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"""
@@ -75,11 +70,11 @@ main(int argc, char *argv[])
""")
-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")
diff --git a/test/SHCCFLAGS.py b/test/SHCCFLAGS.py
index fc881a3..8b5a984 100644
--- a/test/SHCCFLAGS.py
+++ b/test/SHCCFLAGS.py
@@ -26,6 +26,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import sys
import TestSCons
+import os
if sys.platform == 'win32':
_obj = '.obj'
@@ -35,50 +36,92 @@ else:
_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()
diff --git a/test/SHCXX.py b/test/SHCXX.py
index 5825491..e8fb2b3 100644
--- a/test/SHCXX.py
+++ b/test/SHCXX.py
@@ -31,11 +31,6 @@ import TestSCons
python = sys.executable
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
-
test = TestSCons.TestSCons()
test.write("wrapper.py",
@@ -50,8 +45,8 @@ test.write('SConstruct', """
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"""
@@ -79,11 +74,11 @@ main(int argc, char *argv[])
""")
-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")
diff --git a/test/SHCXXFLAGS.py b/test/SHCXXFLAGS.py
index 5623795..def3391 100644
--- a/test/SHCXXFLAGS.py
+++ b/test/SHCXXFLAGS.py
@@ -1,4 +1,3 @@
-
#!/usr/bin/env python
#
# Copyright (c) 2001, 2002 Steven Knight
@@ -27,6 +26,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import sys
import TestSCons
+import os
if sys.platform == 'win32':
_obj = '.obj'
@@ -36,52 +36,94 @@ else:
_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()
diff --git a/test/SHF77.py b/test/SHF77.py
index cffd94d..86f1087 100644
--- a/test/SHF77.py
+++ b/test/SHF77.py
@@ -32,9 +32,9 @@ import TestSCons
python = sys.executable
if sys.platform == 'win32':
- _exe = '.exe'
+ _obj = '.obj'
else:
- _exe = ''
+ _obj = '.o'
test = TestSCons.TestSCons()
@@ -42,24 +42,6 @@ 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:]
@@ -82,20 +64,6 @@ sys.exit(0)
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
@@ -113,59 +81,52 @@ sys.exit(0)
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")
@@ -185,8 +146,8 @@ os.system(string.join(sys.argv[1:], " "))
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"""
@@ -204,15 +165,11 @@ bar.Program(target = 'bar', source = 'bar.f', shared = 1)
""")
- 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")
diff --git a/test/SHF77FLAGS.py b/test/SHF77FLAGS.py
index 231fea2..3034c3e 100644
--- a/test/SHF77FLAGS.py
+++ b/test/SHF77FLAGS.py
@@ -32,9 +32,9 @@ import TestSCons
python = sys.executable
if sys.platform == 'win32':
- _exe = '.exe'
+ _obj = '.obj'
else:
- _exe = ''
+ _obj = '.o'
test = TestSCons.TestSCons()
@@ -42,28 +42,8 @@ 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:]
@@ -91,24 +71,8 @@ sys.exit(0)
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
@@ -131,57 +95,51 @@ sys.exit(0)
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)
@@ -201,8 +159,8 @@ os.system(string.join(sys.argv[1:], " "))
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"""
@@ -220,15 +178,11 @@ bar.Program(target = 'bar', source = 'bar.f', shared = 1)
""")
- 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")
diff --git a/test/SHLIBPREFIX.py b/test/SHLIBPREFIX.py
index 30b422e..5325846 100644
--- a/test/SHLIBPREFIX.py
+++ b/test/SHLIBPREFIX.py
@@ -37,7 +37,7 @@ test = TestSCons.TestSCons()
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"""
diff --git a/test/SHLIBSUFFIX.py b/test/SHLIBSUFFIX.py
index e626e7c..abb92b0 100644
--- a/test/SHLIBSUFFIX.py
+++ b/test/SHLIBSUFFIX.py
@@ -37,7 +37,7 @@ test = TestSCons.TestSCons()
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"""
diff --git a/test/SHLINK.py b/test/SHLINK.py
index 4d28e04..2812afd 100644
--- a/test/SHLINK.py
+++ b/test/SHLINK.py
@@ -52,8 +52,8 @@ test.write('SConstruct', """
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"""
diff --git a/test/SHLINKFLAGS.py b/test/SHLINKFLAGS.py
index 6494ad5..2b4d60a 100644
--- a/test/SHLINKFLAGS.py
+++ b/test/SHLINKFLAGS.py
@@ -54,8 +54,8 @@ shlink = foo.Dictionary('SHLINK')
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"""
diff --git a/test/SharedLibrary.py b/test/SharedLibrary.py
index dfe05af..56738c7 100644
--- a/test/SharedLibrary.py
+++ b/test/SharedLibrary.py
@@ -34,16 +34,22 @@ test.write('SConstruct', """
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"""
@@ -182,8 +188,12 @@ 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\..* 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: .*
'''
)
diff --git a/test/long-lines.py b/test/long-lines.py
index d42b570..f2dc9fc 100644
--- a/test/long-lines.py
+++ b/test/long-lines.py
@@ -47,8 +47,8 @@ while len(linkflags) <= 8100:
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"""