diff options
author | Steven Knight <knight@baldmt.com> | 2002-06-20 00:17:18 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-06-20 00:17:18 (GMT) |
commit | 01bba4cf479f99c67dcac6bc50603feccc89c457 (patch) | |
tree | a07099be95dddcfdb438e7b08b780063c8853831 /src/engine/SCons/Tool | |
parent | 81953156f0c5075d21b9d1573ead1f2e482482a6 (diff) | |
download | SCons-01bba4cf479f99c67dcac6bc50603feccc89c457.zip SCons-01bba4cf479f99c67dcac6bc50603feccc89c457.tar.gz SCons-01bba4cf479f99c67dcac6bc50603feccc89c457.tar.bz2 |
Check in the Tool() interface. (SK and Charles Crain)
Diffstat (limited to 'src/engine/SCons/Tool')
-rw-r--r-- | src/engine/SCons/Tool/ToolTests.py | 60 | ||||
-rw-r--r-- | src/engine/SCons/Tool/__init__.py | 125 | ||||
-rw-r--r-- | src/engine/SCons/Tool/ar.py | 59 | ||||
-rw-r--r-- | src/engine/SCons/Tool/dvipdf.py | 49 | ||||
-rw-r--r-- | src/engine/SCons/Tool/dvips.py | 51 | ||||
-rw-r--r-- | src/engine/SCons/Tool/g++.py | 62 | ||||
-rw-r--r-- | src/engine/SCons/Tool/g77.py | 67 | ||||
-rw-r--r-- | src/engine/SCons/Tool/gcc.py | 63 | ||||
-rw-r--r-- | src/engine/SCons/Tool/gnulink.py | 54 | ||||
-rw-r--r-- | src/engine/SCons/Tool/latex.py | 55 | ||||
-rw-r--r-- | src/engine/SCons/Tool/lex.py | 48 | ||||
-rw-r--r-- | src/engine/SCons/Tool/lib.py | 46 | ||||
-rw-r--r-- | src/engine/SCons/Tool/mslink.py | 151 | ||||
-rw-r--r-- | src/engine/SCons/Tool/msvc.py | 223 | ||||
-rw-r--r-- | src/engine/SCons/Tool/pdflatex.py | 54 | ||||
-rw-r--r-- | src/engine/SCons/Tool/pdftex.py | 50 | ||||
-rw-r--r-- | src/engine/SCons/Tool/tex.py | 50 | ||||
-rw-r--r-- | src/engine/SCons/Tool/yacc.py | 47 |
18 files changed, 1314 insertions, 0 deletions
diff --git a/src/engine/SCons/Tool/ToolTests.py b/src/engine/SCons/Tool/ToolTests.py new file mode 100644 index 0000000..a7e03e8 --- /dev/null +++ b/src/engine/SCons/Tool/ToolTests.py @@ -0,0 +1,60 @@ +# +# 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 sys +import unittest + +import SCons.Errors +import SCons.Tool + +class ToolTestCase(unittest.TestCase): + def test_Tool(self): + """Test the Tool() function""" + t = SCons.Tool.Tool('g++') + env= { 'BUILDERS' : {}, 'ENV' : {} } + t(env, 'foo') + assert env['CXX'] == 'c++', env['CXX'] + assert env['CXXFLAGS'] == '$CCFLAGS', env['CXXFLAGS'] + assert env['INCPREFIX'] == '-I', env['INCPREFIX'] + + try: + SCons.Tool.Tool() + except TypeError: + pass + else: + raise + + try: + p = SCons.Tool.Tool('_does_not_exist_') + except SCons.Errors.UserError: + pass + else: + raise + + +if __name__ == "__main__": + suite = unittest.makeSuite(ToolTestCase, 'test_') + if not unittest.TextTestRunner().run(suite).wasSuccessful(): + sys.exit(1) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py new file mode 100644 index 0000000..08ab5c2 --- /dev/null +++ b/src/engine/SCons/Tool/__init__.py @@ -0,0 +1,125 @@ +"""SCons.Tool + +SCons tool selection. + +This looks for modules that define a callable object that can modify +a construction environment as appropriate for a given tool (or tool +chain). + +Note that because this subsysem just *selects* a callable that can +modify a construction environment, it's possible for people to define +their own "tool specification" in an arbitrary callable function. No +one needs to use or tie in to this subsystem in order to roll their own +tool definition. +""" + +# +# 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 imp +import os +import sys + +import SCons.Errors +import SCons.Defaults + +class ToolSpec: + def __init__(self, name): + self.name = name + + def __str__(self): + return self.name + +def Tool(name, platform = None): + """Select a canned Tool specification. + """ + full_name = 'SCons.Tool.' + name + if not sys.modules.has_key(full_name): + try: + file, path, desc = imp.find_module(name, + sys.modules['SCons.Tool'].__path__) + imp.load_module(full_name, file, path, desc) + except ImportError: + raise SCons.Errors.UserError, "No tool named '%s'" % name + if file: + file.close() + spec = ToolSpec(name) + spec.__call__ = sys.modules[full_name].generate + return spec + +def createObjBuilders(env): + """This is a utility function that creates the Object + and SharedObject Builders in an Environment if they + are not there already. + + If they are there already, we return the existing ones. + + This is a separate function because soooo many Tools + use this functionality. + + The return is a 2-tuple of (StaticObject, SharedObject) + """ + + try: + static_obj = env['BUILDERS']['Object'] + except KeyError: + static_obj = SCons.Defaults.StaticObject() + env['BUILDERS']['Object'] = static_obj + env['BUILDERS']['StaticObject'] = static_obj + + try: + shared_obj = env['BUILDERS']['SharedObject'] + except KeyError: + shared_obj = SCons.Defaults.SharedObject() + env['BUILDERS']['SharedObject'] = shared_obj + + return (static_obj, shared_obj) + +def createCFileBuilders(env): + """This is a utility function that creates the CFile/CXXFile + Builders in an Environment if they + are not there already. + + If they are there already, we return the existing ones. + + This is a separate function because soooo many Tools + use this functionality. + + The return is a 2-tuple of (CFile, CXXFile) + """ + + try: + c_file = env['BUILDERS']['CFile'] + except KeyError: + c_file = SCons.Defaults.CFile() + env['BUILDERS']['CFile'] = c_file + + try: + cxx_file = env['BUILDERS']['CXXFile'] + except KeyError: + cxx_file = SCons.Defaults.CXXFile() + env['BUILDERS']['CXXFile'] = cxx_file + + return (c_file, cxx_file) diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py new file mode 100644 index 0000000..ab870b6 --- /dev/null +++ b/src/engine/SCons/Tool/ar.py @@ -0,0 +1,59 @@ +"""SCons.Tool.ar + +Tool-specific initialization for ar (library archive). + +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 (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 SCons.Defaults +import SCons.Util + +def generate(env, platform): + """Add Builders and construction variables for ar to an Environment.""" + bld = SCons.Defaults.StaticLibrary + env['BUILDERS']['Library'] = bld + env['BUILDERS']['StaticLibrary'] = bld + + arcom = '$AR $ARFLAGS $TARGET $SOURCES' + ranlib = 'ranlib' + if SCons.Util.WhereIs(ranlib): + arcom = arcom + '\n$RANLIB $RANLIBFLAGS $TARGET' + + env['AR'] = 'ar' + env['ARFLAGS'] = 'r' + env['RANLIB'] = ranlib + env['RANLIBFLAGS'] = '' + env['ARCOM'] = arcom + env['SHLINK'] = '$LINK' + env['SHLINKFLAGS'] = '$LINKFLAGS -shared' + env['SHLINKCOM'] = '$SHLINK $SHLINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' + + diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py new file mode 100644 index 0000000..230ce92 --- /dev/null +++ b/src/engine/SCons/Tool/dvipdf.py @@ -0,0 +1,49 @@ +"""SCons.Tool.dvipdf + +Tool-specific initialization for dvipdf. + +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 (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 SCons.Defaults + +def generate(env, platform): + """Add Builders and construction variables for dvipdf to an Environment.""" + try: + bld = env['BUILDERS']['PDF'] + except KeyError: + bld = SCons.Defaults.PDF() + env['BUILDERS']['PDF'] = bld + bld.add_action('.dvi', '$PDFCOM') + + env['DVIPDF'] = 'dvipdf' + env['DVIPDFFLAGS'] = '' + env['PDFCOM'] = '$DVIPDF $DVIPDFFLAGS $SOURCES $TARGET' diff --git a/src/engine/SCons/Tool/dvips.py b/src/engine/SCons/Tool/dvips.py new file mode 100644 index 0000000..098cba7 --- /dev/null +++ b/src/engine/SCons/Tool/dvips.py @@ -0,0 +1,51 @@ +"""SCons.Tool.dvips + +Tool-specific initialization for dvips. + +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 (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 SCons.Action +import SCons.Defaults + +PostScript = SCons.Builder.Builder(action = '$PSCOM', + prefix = '$PSPREFIX', + suffix = '$PSSUFFIX', + src_suffix = '.dvi', + src_builder = 'DVI') + +def generate(env, platform): + """Add Builders and construction variables for dvips to an Environment.""" + env['BUILDERS']['PostScript'] = PostScript + + env['DVIPS'] = 'dvips' + env['DVIPSFLAGS'] = '' + env['PSCOM'] = '$DVIPS $DVIPSFLAGS -o $TARGET $SOURCES' diff --git a/src/engine/SCons/Tool/g++.py b/src/engine/SCons/Tool/g++.py new file mode 100644 index 0000000..a903b0a --- /dev/null +++ b/src/engine/SCons/Tool/g++.py @@ -0,0 +1,62 @@ +"""SCons.Tool.g++ + +Tool-specific initialization for g++. + +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 (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.path + +import SCons.Defaults +import SCons.Tool + +CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++'] +if os.path.normcase('.c') != os.path.normcase('.C'): + CXXSuffixes.append('.C') + +def generate(env, platform): + """Add Builders and construction variables for g++ to an Environment.""" + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + + for suffix in CXXSuffixes: + static_obj.add_action(suffix, SCons.Defaults.CXXAction) + shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction) + + env['CXX'] = 'c++' + env['CXXFLAGS'] = '$CCFLAGS' + env['CXXCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES' + env['SHCXX'] = '$CXX' + env['SHCXXFLAGS'] = '$CXXFLAGS -fPIC' + env['SHCXXCOM'] = '$SHCXX $SHCXXFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES' + env['INCPREFIX'] = '-I' + env['INCSUFFIX'] = '' + + env['CXXFILESUFFIX'] = '.cc' diff --git a/src/engine/SCons/Tool/g77.py b/src/engine/SCons/Tool/g77.py new file mode 100644 index 0000000..dbafcf2 --- /dev/null +++ b/src/engine/SCons/Tool/g77.py @@ -0,0 +1,67 @@ +"""engine.SCons.Tool.g77 + +Tool-specific initialization for g77. + +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 (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.path + +import SCons.Defaults +import SCons.Tool + +F77Suffixes = ['.f', '.for', '.FOR'] +F77PPSuffixes = ['.fpp', '.FPP'] +if os.path.normcase('.f') == os.path.normcase('.F'): + F77Suffixes.append('.F') +else: + F77PPSuffixes.append('.F') + +def generate(env, platform): + """Add Builders and construction variables for g77 to an Environment.""" + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + + for suffix in F77Suffixes: + static_obj.add_action(suffix, SCons.Defaults.F77Action) + shared_obj.add_action(suffix, SCons.Defaults.ShF77Action) + + for suffix in F77PPSuffixes: + static_obj.add_action(suffix, SCons.Defaults.F77PPAction) + shared_obj.add_action(suffix, SCons.Defaults.ShF77PPAction) + + env['F77'] = 'g77' + env['F77FLAGS'] = '' + env['F77COM'] = '$F77 $F77FLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' + env['F77PPCOM'] = '$F77 $F77FLAGS $CPPFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' + env['SHF77'] = '$F77' + env['SHF77FLAGS'] = '$F77FLAGS -fPIC' + env['SHF77COM'] = '$SHF77 $SHF77FLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' + env['SHF77PPCOM'] = '$SHF77 $SHF77FLAGS $CPPFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py new file mode 100644 index 0000000..c5a1e91 --- /dev/null +++ b/src/engine/SCons/Tool/gcc.py @@ -0,0 +1,63 @@ +"""SCons.Tool.gcc + +Tool-specific initialization for gcc. + +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 (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.path + +import SCons.Tool +import SCons.Defaults + +CSuffixes = ['.c'] +if os.path.normcase('.c') == os.path.normcase('.C'): + CSuffixes.append('.C') + +def generate(env, platform): + """Add Builders and construction variables for gcc to an Environment.""" + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + + for suffix in CSuffixes: + static_obj.add_action(suffix, SCons.Defaults.CAction) + shared_obj.add_action(suffix, SCons.Defaults.ShCAction) + + env['CC'] = 'gcc' + env['CCFLAGS'] = '' + env['CCCOM'] = '$CC $CCFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES' + env['SHCC'] = '$CC' + env['SHCCFLAGS'] = '$CCFLAGS -fPIC' + env['SHCCCOM'] = '$SHCC $SHCCFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES' + + env['INCPREFIX'] = '-I' + env['INCSUFFIX'] = '' + + env['CFILESUFFIX'] = '.c' diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py new file mode 100644 index 0000000..630d95a --- /dev/null +++ b/src/engine/SCons/Tool/gnulink.py @@ -0,0 +1,54 @@ +"""SCons.Tool.gnulink + +Tool-specific initialization for the gnu 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 (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 SCons.Defaults +import SCons.Util + +def generate(env, platform): + """Add Builders and construction variables for ar to an Environment.""" + env['BUILDERS']['SharedLibrary'] = SCons.Defaults.SharedLibrary + env['BUILDERS']['Program'] = SCons.Defaults.Program + + env['SHLINK'] = '$LINK' + env['SHLINKFLAGS'] = '$LINKFLAGS -shared' + env['SHLINKCOM'] = '$SHLINK $SHLINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' + env['SHLIBEMITTER']= None + env['LINK'] = 'c++' + env['LINKFLAGS'] = '' + env['LINKCOM'] = '$LINK $LINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' + env['LIBDIRPREFIX']='-L' + env['LIBDIRSUFFIX']='' + env['LIBLINKPREFIX']='-l' + env['LIBLINKSUFFIX']='' diff --git a/src/engine/SCons/Tool/latex.py b/src/engine/SCons/Tool/latex.py new file mode 100644 index 0000000..cb53ccf --- /dev/null +++ b/src/engine/SCons/Tool/latex.py @@ -0,0 +1,55 @@ +"""SCons.Tool.latex + +Tool-specific initialization for LaTeX. + +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 (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 SCons.Action +import SCons.Defaults + +LaTeXAction = SCons.Action.Action('$LATEXCOM') + +def generate(env, platform): + """Add Builders and construction variables for LaTeX to an Environment.""" + + try: + bld = env['BUILDERS']['DVI'] + except KeyError: + bld = SCons.Defaults.DVI() + env['BUILDERS']['DVI'] = bld + + bld.add_action('.ltx', LaTeXAction) + bld.add_action('.latex', LaTeXAction) + + env['LATEX'] = 'latex' + env['LATEXFLAGS'] = '' + env['LATEXCOM'] = '$LATEX $LATEXFLAGS $SOURCES' diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py new file mode 100644 index 0000000..c8851e2 --- /dev/null +++ b/src/engine/SCons/Tool/lex.py @@ -0,0 +1,48 @@ +"""SCons.Tool.lex + +Tool-specific initialization for lex. + +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 (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 SCons.Defaults +import SCons.Tool + +def generate(env, platform): + """Add Builders and construction variables for lex to an Environment.""" + c_file, cxx_file = SCons.Tool.createCFileBuilders(env) + + c_file.add_action('.l', '$LEXCOM') + cxx_file.add_action('.ll', '$LEXCOM') + + env['LEX'] = 'lex' + env['LEXFLAGS'] = '' + env['LEXCOM'] = '$LEX $LEXFLAGS -t $SOURCES > $TARGET' diff --git a/src/engine/SCons/Tool/lib.py b/src/engine/SCons/Tool/lib.py new file mode 100644 index 0000000..9683abf --- /dev/null +++ b/src/engine/SCons/Tool/lib.py @@ -0,0 +1,46 @@ +"""SCons.Tool.lib + +Tool-specific initialization for lib (MicroSoft library archiver). + +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 (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 SCons.Defaults + +def generate(env, platform): + """Add Builders and construction variables for lib to an Environment.""" + env['BUILDERS']['Library'] = SCons.Defaults.StaticLibrary + env['BUILDERS']['StaticLibrary'] = SCons.Defaults.StaticLibrary + + env['AR'] = 'lib' + env['ARFLAGS'] = '/nologo' + env['ARCOM'] = '$AR $ARFLAGS /OUT:$TARGET $SOURCES' + diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py new file mode 100644 index 0000000..2f05b46 --- /dev/null +++ b/src/engine/SCons/Tool/mslink.py @@ -0,0 +1,151 @@ +"""SCons.Tool.mslink + +Tool-specific initialization for the Microsoft 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 (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.path + +import SCons.Defaults +import SCons.Errors +import SCons.Action + +from SCons.Tool.msvc import get_msdev_paths + +def win32TempFileMunge(env, cmd_list, for_signature): + """Given a list of command line arguments, see if it is too + long to pass to the win32 command line interpreter. If so, + create a temp file, then pass "@tempfile" as the sole argument + to the supplied command (which is the first element of cmd_list). + Otherwise, just return [cmd_list].""" + cmd = env.subst_list(cmd_list)[0] + if for_signature or \ + (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= 2048: + return [cmd_list] + else: + import tempfile + # We do a normpath because mktemp() has what appears to be + # a bug in Win32 that will use a forward slash as a path + # delimiter. Win32's link mistakes that for a command line + # switch and barfs. + tmp = os.path.normpath(tempfile.mktemp()) + args = map(SCons.Util.quote_spaces, cmd[1:]) + open(tmp, 'w').write(string.join(args, " ") + "\n") + return [ [cmd[0], '@' + tmp], + ['del', tmp] ] + +def win32LinkGenerator(env, target, source, for_signature, **kw): + args = [ '$LINK', '$LINKFLAGS', '/OUT:%s' % target[0], + '$(', '$_LIBDIRFLAGS', '$)', '$_LIBFLAGS' ] + args.extend(map(SCons.Util.to_String, source)) + return win32TempFileMunge(env, args, for_signature) + +def win32LibGenerator(target, source, env, for_signature, no_import_lib=0): + listCmd = [ "$SHLINK", "$SHLINKFLAGS" ] + + for tgt in target: + ext = os.path.splitext(str(tgt))[1] + if ext == env.subst("$LIBSUFFIX"): + # Put it on the command line as an import library. + if no_import_lib: + raise SCons.Errors.UserError, "%s: You cannot specify a .lib file as a target of a shared library build if no_import_library is nonzero." % tgt + listCmd.append("${WIN32IMPLIBPREFIX}%s" % tgt) + else: + listCmd.append("${WIN32DLLPREFIX}%s" % tgt) + + listCmd.extend([ '$_LIBDIRFLAGS', '$_LIBFLAGS' ]) + for src in source: + ext = os.path.splitext(str(src))[1] + if ext == env.subst("$WIN32DEFSUFFIX"): + # Treat this source as a .def file. + listCmd.append("${WIN32DEFPREFIX}%s" % src) + else: + # Just treat it as a generic source file. + listCmd.append(str(src)) + return win32TempFileMunge(env, listCmd, for_signature) + +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"))) + return (target, source) + +ShLibAction = SCons.Action.CommandGenerator(win32LibGenerator) +LinkAction = SCons.Action.CommandGenerator(win32LinkGenerator) + +def generate(env, platform): + """Add Builders and construction variables for ar to an Environment.""" + env['BUILDERS']['SharedLibrary'] = SCons.Defaults.SharedLibrary + env['BUILDERS']['Program'] = SCons.Defaults.Program + + env['SHLINK'] = '$LINK' + env['SHLINKFLAGS'] = '$LINKFLAGS /dll' + env['SHLINKCOM'] = ShLibAction + env['SHLIBEMITTER']= win32LibEmitter + env['LINK'] = 'link' + env['LINKFLAGS'] = '/nologo' + env['LINKCOM'] = LinkAction + env['LIBDIRPREFIX']='/LIBPATH:' + env['LIBDIRSUFFIX']='' + env['LIBLINKPREFIX']='' + env['LIBLINKSUFFIX']='$LIBSUFFIX' + + env['WIN32DEFPREFIX'] = '/def:' + env['WIN32DEFSUFFIX'] = '.def' + env['WIN32DLLPREFIX'] = '/out:' + env['WIN32IMPLIBPREFIX'] = '/implib:' + env['WIN32_INSERT_DEF'] = 0 + + include_path, lib_path, exe_path = get_msdev_paths() + env['ENV']['LIB'] = lib_path + env['ENV']['PATH'] = exe_path diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py new file mode 100644 index 0000000..54796e3 --- /dev/null +++ b/src/engine/SCons/Tool/msvc.py @@ -0,0 +1,223 @@ +"""engine.SCons.Tool.msvc + +Tool-specific initialization for Microsoft Visual C/C++. + +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 (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.path +import string + +import SCons.Action +import SCons.Tool +import SCons.Errors + +CSuffixes = ['.c', '.C'] +CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++'] + +def get_devstudio_versions(): + """ + Get list of devstudio versions from the Windows registry. Return a + list of strings containing version numbers; an exception will be raised + if we were unable to access the registry (eg. couldn't import + a registry-access module) or the appropriate registry keys weren't + found. + """ + + if not SCons.Util.can_read_reg: + raise SCons.Errors.InternalError, "No Windows registry module was found" + + K = 'Software\\Microsoft\\Devstudio' + L = [] + for base in (SCons.Util.HKEY_CLASSES_ROOT, + SCons.Util.HKEY_LOCAL_MACHINE, + SCons.Util.HKEY_CURRENT_USER, + SCons.Util.HKEY_USERS): + try: + k = SCons.Util.RegOpenKeyEx(base,K) + i = 0 + while 1: + try: + p = SCons.Util.RegEnumKey(k,i) + if p[0] in '123456789' and p not in L: + L.append(p) + except SCons.Util.RegError: + break + 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 + +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 + 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" + + if path=='lib': + path= 'Library' + path = string.upper(path + ' Dirs') + K = ('Software\\Microsoft\\Devstudio\\%s\\' + + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ + (version,platform) + for base in (SCons.Util.HKEY_CLASSES_ROOT, + SCons.Util.HKEY_LOCAL_MACHINE, + SCons.Util.HKEY_CURRENT_USER, + SCons.Util.HKEY_USERS): + try: + k = SCons.Util.RegOpenKeyEx(base,K) + i = 0 + while 1: + try: + (p,v,t) = SCons.Util.RegEnumValue(k,i) + if string.upper(p) == path: + return v + i = i + 1 + except SCons.Util.RegError: + break + except SCons.Util.RegError: + pass + + # if we got here, then we didn't find the registry entries: + raise SCons.Errors.InternalError, "%s was not found in the registry."%path + +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: + K = ('Software\\Microsoft\\Devstudio\\%s\\' + + 'Products\\Microsoft Visual C++') % \ + version + for base in (SCons.Util.HKEY_LOCAL_MACHINE, + SCons.Util.HKEY_CURRENT_USER): + try: + k = SCons.Util.RegOpenKeyEx(base,K) + val, tok = SCons.Util.RegQueryValueEx(k, 'ProductDir') + return os.path.split(val)[0] + except SCons.Util.RegError: + pass + +def get_msdev_paths(version=None): + """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values + of those three environment variables that should be set + in order to execute the MSVC tools properly.""" + exe_path = '' + lib_path = '' + include_path = '' + try: + if not version: + version = get_devstudio_versions()[0] #use highest version + include_path = get_msvc_path("include", version) + lib_path = get_msvc_path("lib", version) + exe_path = get_msvc_path("path", version) + ";" + os.environ['PATH'] + except (SCons.Util.RegError, SCons.Errors.InternalError): + # Could not get the configured directories from the registry. + # However, the configured directories only appear if the user + # changes them from the default. Therefore, we'll see if + # we can get the path to the MSDev base installation from + # the registry and deduce the default directories. + MVSdir = None + if version: + MVSdir = get_msdev_dir(version) + if MVSdir: + MVSVCdir = r'%s\VC98' % MVSdir + MVSCommondir = r'%s\Common' % MVSdir + include_path = r'%s\atl\include;%s\mfc\include;%s\include' % (MVSVCdir, MVSVCdir, MVSVCdir) + lib_path = r'%s\mfc\lib;%s\lib' % (MVSVCdir, MVSVCdir) + try: + extra_path = os.pathsep + os.environ['PATH'] + except KeyError: + extra_path = '' + exe_path = (r'%s\MSDev98\Bin;%s\Bin' % (MVSCommondir, MVSVCdir)) + extra_path + else: + # The DevStudio environment variables don't exist, + # so just use the variables from the source environment. + MVSdir = r'C:\Program Files\Microsoft Visual Studio' + MVSVCdir = r'%s\VC98' % MVSdir + MVSCommondir = r'%s\Common' % MVSdir + try: + include_path = os.environ['INCLUDE'] + except KeyError: + include_path = '' + try: + lib_path = os.environ['LIB'] + except KeyError: + lib_path = '' + try: + exe_path = os.environ['PATH'] + except KeyError: + exe_path = '' + return (include_path, lib_path, exe_path) + +def generate(env, platform): + """Add Builders and construction variables for MSVC++ to an Environment.""" + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + + for suffix in CSuffixes: + static_obj.add_action(suffix, SCons.Defaults.CAction) + shared_obj.add_action(suffix, SCons.Defaults.ShCAction) + + for suffix in CXXSuffixes: + static_obj.add_action(suffix, SCons.Defaults.CXXAction) + shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction) + + env['CC'] = 'cl' + env['CCFLAGS'] = '/nologo' + env['CCCOM'] = '$CC $CCFLAGS $CPPFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET' + env['SHCC'] = '$CC' + env['SHCCFLAGS'] = '$CCFLAGS' + env['SHCCCOM'] = '$SHCC $SHCCFLAGS $CPPFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET' + env['CXX'] = '$CC' + env['CXXFLAGS'] = '$CCFLAGS' + env['CXXCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET' + env['SHCXX'] = '$CXX' + env['SHCXXFLAGS'] = '$CXXFLAGS' + env['SHCXXCOM'] = '$SHCXX $SHCXXFLAGS $CPPFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET' + env['INCPREFIX'] = '/I' + env['INCSUFFIX'] = '' + + include_path, lib_path, exe_path = get_msdev_paths() + env['ENV']['INCLUDE'] = include_path + env['ENV']['PATH'] = exe_path + + env['CFILESUFFIX'] = '.c' + env['CXXFILESUFFIX'] = '.cc' + diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py new file mode 100644 index 0000000..340622c --- /dev/null +++ b/src/engine/SCons/Tool/pdflatex.py @@ -0,0 +1,54 @@ +"""SCons.Tool.pdflatex + +Tool-specific initialization for pdflatex. + +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 (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 SCons.Action +import SCons.Defaults + +PDFLaTeXAction = SCons.Action.Action('$PDFLATEXCOM') + +def generate(env, platform): + """Add Builders and construction variables for pdflatex to an Environment.""" + try: + bld = env['BUILDERS']['PDF'] + except KeyError: + bld = SCons.Defaults.PDF() + env['BUILDERS']['PDF'] = bld + + bld.add_action('.ltx', PDFLaTeXAction) + bld.add_action('.latex', PDFLaTeXAction) + + env['PDFLATEX'] = 'pdflatex' + env['PDFLATEXFLAGS'] = '' + env['PDFLATEXCOM'] = '$PDFLATEX $PDFLATEXFLAGS $SOURCES $TARGET' diff --git a/src/engine/SCons/Tool/pdftex.py b/src/engine/SCons/Tool/pdftex.py new file mode 100644 index 0000000..1acc9ce --- /dev/null +++ b/src/engine/SCons/Tool/pdftex.py @@ -0,0 +1,50 @@ +"""SCons.Tool.pdftex + +Tool-specific initialization for pdftex. + +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 (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 SCons.Defaults + +def generate(env, platform): + """Add Builders and construction variables for pdftex to an Environment.""" + try: + bld = env['BUILDERS']['PDF'] + except KeyError: + bld = SCons.Defaults.PDF() + env['BUILDERS']['PDF'] = bld + + bld.add_action('.tex', '$PDFTEXCOM') + + env['PDFTEX'] = 'pdftex' + env['PDFTEXFLAGS'] = '' + env['PDFTEXCOM'] = '$PDFTEX $PDFTEXFLAGS $SOURCES $TARGET' diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py new file mode 100644 index 0000000..10413aa --- /dev/null +++ b/src/engine/SCons/Tool/tex.py @@ -0,0 +1,50 @@ +"""SCons.Tool.tex + +Tool-specific initialization for TeX. + +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 (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 SCons.Defaults + +def generate(env, platform): + """Add Builders and construction variables for TeX to an Environment.""" + try: + bld = env['BUILDERS']['DVI'] + except KeyError: + bld = SCons.Defaults.DVI() + env['BUILDERS']['DVI'] = bld + + bld.add_action('.tex', '$TEXCOM') + + env['TEX'] = 'tex' + env['TEXFLAGS'] = '' + env['TEXCOM'] = '$TEX $TEXFLAGS $SOURCES' diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py new file mode 100644 index 0000000..34abe77 --- /dev/null +++ b/src/engine/SCons/Tool/yacc.py @@ -0,0 +1,47 @@ +"""SCons.Tool.yacc + +Tool-specific initialization for yacc. + +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 (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 SCons.Tool + +def generate(env, platform): + """Add Builders and construction variables for yacc to an Environment.""" + c_file, cxx_file = SCons.Tool.createCFileBuilders(env) + + c_file.add_action('.y', '$YACCCOM') + cxx_file.add_action('.yy', '$YACCCOM') + + env['YACC'] = 'yacc' + env['YACCFLAGS'] = '' + env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES' |