summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/man/scons.110
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/engine/SCons/Defaults.py50
-rw-r--r--test/RANLIB.py96
-rw-r--r--test/RANLIBFLAGS.py97
5 files changed, 241 insertions, 15 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index c32c6f8..9614a0f 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -733,10 +733,10 @@ by the user. The following is a list of the automatically defined construction
variables:
.IP AR
-The static library command.
+The static library archiver.
.IP ARFLAGS
-General options passed to the static library command.
+General options passed to the static library archiver.
.IP ARCOM
The command line used to generate a static library from object files.
@@ -922,6 +922,12 @@ The prefix used for executable file names.
.IP PROGSUFFIX
The suffix used for executable file names.
+.IP RANLIB
+The archive indexer.
+
+.IP RANLIBFLAGS
+General options passed to the archive indexer.
+
.IP SCANNERS
A list of the available implicit dependency scanners. [CScan] by default.
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index cc3db98..5835996 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -20,6 +20,9 @@ RELEASE 0.06 -
- Man page: document LIBS, fix a typo.
+ - Added RANLIB and RANLIBFLAGS construction variables. Only use them
+ in ARCOM if there's a "ranlib" program on the system.
+
RELEASE 0.05 - Thu, 21 Feb 2002 16:50:03 -0600
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index d129838..0a8e4cd 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -4,7 +4,7 @@ Builders and other things for the local site. Here's where we'll
duplicate the functionality of autoconf until we move it into the
installation procedure or use something like qmconf.
-The code that reads the registry to find MSVC components was borrowed
+The code that reads the registry to find MSVC components was borrowed
from distutils.msvccompiler.
"""
@@ -37,6 +37,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
+import stat
import string
import sys
@@ -47,6 +48,22 @@ import SCons.Scanner.Prog
import SCons.Errors
import SCons.Util
+
+
+def whereis(file):
+ for dir in string.split(os.environ['PATH'], os.pathsep):
+ f = os.path.join(dir, file)
+ if os.path.isfile(f):
+ try:
+ st = os.stat(f)
+ except:
+ continue
+ if stat.S_IMODE(st[stat.ST_MODE]) & 0111:
+ return f
+ return None
+
+
+
CFile = SCons.Builder.Builder(name = 'CFile',
action = { '.l' : '$LEXCOM',
'.y' : '$YACCCOM',
@@ -116,10 +133,10 @@ def get_devstudio_versions ():
i = i + 1
except SCons.Util.RegError:
pass
-
+
if not L:
raise SCons.Errors.InternalError, "DevStudio was not found."
-
+
L.sort()
L.reverse()
return L
@@ -127,10 +144,10 @@ def get_devstudio_versions ():
def get_msvc_path (path, version, platform='x86'):
"""
Get a list of devstudio directories (include, lib or path). Return
- a string delimited by ';'. An exception will be raised if unable to
+ a string delimited by ';'. An exception will be raised if unable to
access the registry or appropriate registry keys not found.
"""
-
+
if not SCons.Util.can_read_reg:
raise SCons.Errors.InternalError, "No Windows registry module was found"
@@ -164,7 +181,7 @@ def get_msvc_path (path, version, platform='x86'):
def get_msdev_dir(version):
"""Returns the root directory of the MSDev installation from the
registry if it can be found, otherwise we guess."""
- if SCons.Util.can_read_reg:
+ if SCons.Util.can_read_reg:
K = ('Software\\Microsoft\\Devstudio\\%s\\' +
'Products\\Microsoft Visual C++') % \
version
@@ -176,10 +193,10 @@ def get_msdev_dir(version):
return os.path.split(val)[0]
except SCons.Util.RegError:
pass
-
+
def make_win32_env_from_paths(include, lib, path):
"""
- Build a dictionary of construction variables for a win32 platform.
+ Build a dictionary of construction variables for a win32 platform.
include - include path
lib - library path
path - executable path
@@ -224,20 +241,25 @@ def make_win32_env_from_paths(include, lib, path):
'PATHEXT' : '.COM;.EXE;.BAT;.CMD',
},
}
-
+
def make_win32_env(version):
"""
- Build a dictionary of construction variables for a win32 platform.
+ Build a dictionary of construction variables for a win32 platform.
ver - the version string of DevStudio to use (e.g. "6.0")
"""
return make_win32_env_from_paths(get_msvc_path("include", version),
get_msvc_path("lib", version),
- get_msvc_path("path", version)
+ get_msvc_path("path", version)
+ ";" + os.environ['PATH'])
-
+
if os.name == 'posix':
+ arcom = '$AR $ARFLAGS $TARGET $SOURCES'
+ ranlib = 'ranlib'
+ if whereis(ranlib):
+ arcom = arcom + '\n$RANLIB $RANLIBFLAGS $TARGET'
+
ConstructionEnvironment = {
'CC' : 'cc',
'CCFLAGS' : '',
@@ -250,7 +272,9 @@ if os.name == 'posix':
'LINKCOM' : '$LINK $LINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS',
'AR' : 'ar',
'ARFLAGS' : 'r',
- 'ARCOM' : '$AR $ARFLAGS $TARGET $SOURCES\nranlib $TARGET',
+ 'RANLIB' : ranlib,
+ 'RANLIBFLAGS' : '',
+ 'ARCOM' : arcom,
'LEX' : 'lex',
'LEXFLAGS' : '',
'LEXCOM' : '$LEX $LEXFLAGS -o$TARGET $SOURCES',
diff --git a/test/RANLIB.py b/test/RANLIB.py
new file mode 100644
index 0000000..2e151cd
--- /dev/null
+++ b/test/RANLIB.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+python = sys.executable
+
+if sys.platform == 'win32':
+ _exe = '.exe'
+else:
+ _exe = ''
+
+test = TestSCons.TestSCons()
+
+test.write("wrapper.py",
+"""import os
+import string
+import sys
+open('%s', 'wb').write("wrapper.py\\n")
+os.system(string.join(sys.argv[1:], " "))
+""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
+
+test.write('SConstruct', """
+foo = Environment(LIBS = ['foo'], LIBPATH = ['.'])
+ranlib = foo.Dictionary('RANLIB')
+bar = Environment(LIBS = ['bar'], LIBPATH = ['.'],
+ RANLIB = r'%s wrapper.py ' + ranlib)
+foo.Library(target = 'foo', source = 'foo.c')
+bar.Library(target = 'bar', source = 'bar.c')
+
+foo.Program(target = 'f', source = 'main.c')
+bar.Program(target = 'b', source = 'main.c')
+""" % python)
+
+test.write('foo.c', r"""
+void
+library_function(void)
+{
+ printf("foo.c\n");
+}
+""")
+
+test.write('bar.c', r"""
+void
+library_function(void)
+{
+ printf("bar.c\n");
+}
+""")
+
+test.write('main.c', r"""
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ library_function();
+ exit (0);
+}
+""")
+
+
+test.run(arguments = 'f' + _exe)
+
+test.fail_test(os.path.exists(test.workpath('wrapper.out')))
+
+test.run(arguments = 'b' + _exe)
+
+test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
+
+test.pass_test()
diff --git a/test/RANLIBFLAGS.py b/test/RANLIBFLAGS.py
new file mode 100644
index 0000000..1855af2
--- /dev/null
+++ b/test/RANLIBFLAGS.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+python = sys.executable
+
+if sys.platform == 'win32':
+ _exe = '.exe'
+else:
+ _exe = ''
+
+test = TestSCons.TestSCons()
+
+test.write("wrapper.py",
+"""import os
+import string
+import sys
+open('%s', 'wb').write("wrapper.py\\n")
+os.system(string.join(sys.argv[1:], " "))
+""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
+
+test.write('SConstruct', """
+foo = Environment(LIBS = ['foo'], LIBPATH = ['.'])
+ranlib = foo.Dictionary('RANLIB')
+ranlibflags = foo.Dictionary('RANLIBFLAGS')
+bar = Environment(LIBS = ['bar'], LIBPATH = ['.'], RANLIB = '',
+ RANLIBFLAGS = r'%s wrapper.py ' + ranlib + ' ' + ranlibflags)
+foo.Library(target = 'foo', source = 'foo.c')
+bar.Library(target = 'bar', source = 'bar.c')
+
+foo.Program(target = 'f', source = 'main.c')
+bar.Program(target = 'b', source = 'main.c')
+""" % python)
+
+test.write('foo.c', r"""
+void
+library_function(void)
+{
+ printf("foo.c\n");
+}
+""")
+
+test.write('bar.c', r"""
+void
+library_function(void)
+{
+ printf("bar.c\n");
+}
+""")
+
+test.write('main.c', r"""
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ library_function();
+ exit (0);
+}
+""")
+
+
+test.run(arguments = 'f' + _exe)
+
+test.fail_test(os.path.exists(test.workpath('wrapper.out')))
+
+test.run(arguments = 'b' + _exe)
+
+test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
+
+test.pass_test()