summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-01-07 14:24:10 (GMT)
committerSteven Knight <knight@baldmt.com>2005-01-07 14:24:10 (GMT)
commita30529bf7d9361a44490126666d0cc71d98410aa (patch)
treef239e765d1b35f6b65f517c576ab036b0b3481b6 /src/engine
parent4e17c7182977812c7751523ef08f7b221ae6aa61 (diff)
downloadSCons-a30529bf7d9361a44490126666d0cc71d98410aa.zip
SCons-a30529bf7d9361a44490126666d0cc71d98410aa.tar.gz
SCons-a30529bf7d9361a44490126666d0cc71d98410aa.tar.bz2
Add LoadableModule support. (Michael McCracken)
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/MANIFEST.in1
-rw-r--r--src/engine/SCons/Defaults.py1
-rw-r--r--src/engine/SCons/Tool/__init__.py31
-rw-r--r--src/engine/SCons/Tool/applelink.py60
-rw-r--r--src/engine/SCons/Tool/link.py11
5 files changed, 104 insertions, 0 deletions
diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in
index 5c329bd..133ccad 100644
--- a/src/engine/MANIFEST.in
+++ b/src/engine/MANIFEST.in
@@ -55,6 +55,7 @@ SCons/Tool/aixc++.py
SCons/Tool/aixcc.py
SCons/Tool/aixf77.py
SCons/Tool/aixlink.py
+SCons/Tool/applelink.py
SCons/Tool/ar.py
SCons/Tool/as.py
SCons/Tool/bcc32.py
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index b3312f7..644dadf 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -131,6 +131,7 @@ ASPPAction = SCons.Action.Action("$ASPPCOM", "$ASPPCOMSTR")
LinkAction = SCons.Action.Action("$LINKCOM", "$LINKCOMSTR")
ShLinkAction = SCons.Action.Action("$SHLINKCOM", "$SHLINKCOMSTR")
+LdModuleLinkAction = SCons.Action.Action("$LDMODULECOM", "$LDMODULECOMSTR")
ArAction = SCons.Action.Action("$ARCOM", "$ARCOMSTR")
LexAction = SCons.Action.Action("$LEXCOM", "$LEXCOMSTR")
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index 2c793d9..5513f5e 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -171,6 +171,29 @@ def createSharedLibBuilder(env):
return shared_lib
+def createLoadableModuleBuilder(env):
+ """This is a utility function that creates the LoadableModule
+ Builder in an Environment if it is not there already.
+
+ If it is already there, we return the existing one.
+ """
+
+ try:
+ loadable_module = env['BUILDERS']['LoadableModule']
+ except KeyError:
+ action_list = [ SCons.Defaults.SharedCheck,
+ SCons.Defaults.LdModuleLinkAction ]
+ ld_module = SCons.Builder.Builder(action = action_list,
+ emitter = "$SHLIBEMITTER",
+ prefix = '$LDMODULEPREFIX',
+ suffix = '$LDMODULESUFFIX',
+ target_scanner = SCons.Defaults.ProgScan,
+ src_suffix = '$SHOBJSUFFIX',
+ src_builder = 'SharedObject')
+ env['BUILDERS']['LoadableModule'] = ld_module
+
+ return ld_module
+
def createObjBuilders(env):
"""This is a utility function that creates the StaticObject
and SharedObject Builders in an Environment if they
@@ -309,6 +332,14 @@ def tool_list(platform, env):
assemblers = ['as', 'gas']
fortran_compilers = ['aixf77', 'g77', 'fortran']
ars = ['ar']
+ elif str(platform) == 'darwin':
+ "prefer GNU tools on Mac OS X, except for some linkers and IBM tools"
+ linkers = ['applelink', 'gnulink']
+ c_compilers = ['gcc', 'cc']
+ cxx_compilers = ['g++', 'c++']
+ assemblers = ['as']
+ fortran_compilers = ['g77']
+ ars = ['ar']
else:
"prefer GNU tools on all other platforms"
linkers = ['gnulink', 'mslink', 'ilink']
diff --git a/src/engine/SCons/Tool/applelink.py b/src/engine/SCons/Tool/applelink.py
new file mode 100644
index 0000000..87c92d4
--- /dev/null
+++ b/src/engine/SCons/Tool/applelink.py
@@ -0,0 +1,60 @@
+"""SCons.Tool.applelink
+
+Tool-specific initialization for the Apple gnu-like linker.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# __COPYRIGHT__
+#
+# 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 SCons.Util
+
+import gnulink
+
+def generate(env):
+ """Add Builders and construction variables for applelink to an
+ Environment."""
+ gnulink.generate(env)
+
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -dynamiclib')
+
+ # override the default for loadable modules, which are different
+ # on OS X than dynamic shared libs. echoing what XCode does for
+ # pre/suffixes:
+ env['LDMODULEPREFIX'] = ''
+ env['LDMODULESUFFIX'] = ''
+ env['LDMODULE'] = '$SHLINK'
+ env['LDMODULEFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -bundle')
+ env['LDMODULECOM'] = '$LDMODULE $LDMODULEFLAGS -o ${TARGET} $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $FRAMEWORKSFLAGS'
+
+
+
+def exists(env):
+ import sys
+ return sys.platform == 'darwin'
diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py
index 8248be9..5188634 100644
--- a/src/engine/SCons/Tool/link.py
+++ b/src/engine/SCons/Tool/link.py
@@ -70,6 +70,17 @@ def generate(env):
elif env['PLATFORM'] == 'aix':
env['SHLIBSUFFIX'] = '.a'
+ # For most platforms, a loadable module is the same as a shared
+ # library. Platforms which are different can override these, but
+ # setting them the same means that LoadableModule works everywhere.
+ SCons.Tool.createLoadableModuleBuilder(env)
+ env['LDMODULE'] = '$SHLINK'
+ env['LDMODULEPREFIX'] = '$SHLIBPREFIX'
+ env['LDMODULESUFFIX'] = '$SHLIBSUFFIX'
+ env['LDMODULEFLAGS'] = '$SHLINKFLAGS'
+ env['LDMODULECOM'] = '$SHLINKCOM'
+
+
def exists(env):
# This module isn't really a Tool on its own, it's common logic for