SCons/Tool/gcc.py
SCons/Tool/gnulink.py
SCons/Tool/icc.py
+SCons/Tool/ifl.py
SCons/Tool/ilink.py
SCons/Tool/latex.py
SCons/Tool/lex.py
def __init__(self,
platform=SCons.Platform.Platform(),
- tools=SCons.Platform.DefaultToolList(),
+ tools=None,
**kw):
self.fs = SCons.Node.FS.default_fs
self._dict = our_deepcopy(SCons.Defaults.ConstructionEnvironment)
if SCons.Util.is_String(platform):
platform = SCons.Platform.Platform(platform)
platform(self)
+ if tools is None:
+ tools = SCons.Platform.DefaultToolList(platform)
for tool in tools:
if SCons.Util.is_String(tool):
tool = SCons.Tool.Tool(tool)
file.close()
return sys.modules[full_name]
-def DefaultToolList(name = platform_default()):
+def DefaultToolList(platform):
"""Select a default tool list for the specified platform.
"""
- module = platform_module(name)
- return SCons.Tool.tool_list()
+ return SCons.Tool.tool_list(platform)
class PlatformSpec:
def __init__(self, name):
import SCons.Util
-def tool_list():
- as = SCons.Util.WhereIs('as')
- nasm = SCons.Util.WhereIs('nasm')
- if nasm and not as:
- assembler = 'nasm'
- else:
- assembler = 'gas'
- return ['ar', 'dvipdf', 'dvips',
- 'g++', 'g77', 'gcc', 'gnulink',
- 'latex', 'lex',
- 'pdflatex', 'pdftex', 'tar', 'tex', 'yacc',
- assembler]
-
def generate(env):
if not env.has_key('ENV'):
env['ENV'] = {}
import SCons.Util
-def tool_list():
- list = ['dvipdf', 'dvips', 'g77',
- 'icc', 'ilink', 'latex', 'lex',
- 'pdflatex', 'pdftex', 'tex', 'yacc']
- if SCons.Util.WhereIs('nasm'):
- list.append('nasm')
- return list
-
def generate(env):
if not env.has_key('ENV'):
env['ENV'] = {}
import SCons.Util
-def tool_list():
- as = SCons.Util.WhereIs('as')
- nasm = SCons.Util.WhereIs('nasm')
- if nasm and not as:
- assembler = 'nasm'
- else:
- assembler = 'gas'
- return ['ar', 'dvipdf', 'dvips',
- 'g++', 'g77', 'gcc', 'gnulink',
- 'latex', 'lex',
- 'pdflatex', 'pdftex', 'tar', 'tex', 'yacc',
- assembler]
-
def generate(env):
if not env.has_key('ENV'):
env['ENV'] = {}
import SCons.Util
-def tool_list():
- masm = SCons.Util.WhereIs('ml')
- nasm = SCons.Util.WhereIs('nasm')
- if nasm and not masm:
- assembler = 'nasm'
- else:
- assembler = 'masm'
- return ['dvipdf', 'dvips', 'g77',
- 'latex', 'lex', 'lib', 'mslink', 'msvc',
- 'pdflatex', 'pdftex', 'tar', 'tex', 'yacc',
- assembler]
-
def generate(env):
if not env.has_key('ENV'):
env['ENV'] = {}
return (c_file, cxx_file)
-linkers = ['gnulink', 'mslink', 'ilink']
-c_compilers = ['gcc', 'msvc', 'icc']
-cxx_compilers = ['g++'] # only those that are seperate from the c compiler
-fortran_compilers = ['g77', 'ifl']
-assemblers = ['gas', 'nasm', 'masm']
-other_tools = ['ar', 'dvipdf', 'dvips',
- 'latex', 'lex', 'lib',
- 'pdflatex', 'pdftex',
- 'tar', 'tex', 'yacc']
-
def FindTool(tools):
for tool in tools:
t = Tool(tool)
def FindAllTools(tools):
return filter (_ToolExists, tools)
-def tool_list():
- tools = [FindTool(linkers),
- FindTool(c_compilers),
- FindTool(cxx_compilers),
- FindTool(fortran_compilers),
- FindTool(assemblers)
- ] + FindAllTools(other_tools)
+def tool_list(platform):
+ if str(platform) == 'win32':
+ "prefer Microsoft tools on Windows"
+ linkers = ['mslink', 'gnulink', 'ilink']
+ c_compilers = ['msvc', 'gcc', 'icc']
+ assemblers = ['nasm', 'masm', 'gas']
+ fortran_compilers = ['g77', 'ifl']
+ ars = ['lib', 'ar']
+ elif str(platform) == 'os2':
+ "prefer IBM tools on OS/2"
+ linkers = ['ilink', 'gnulink', 'mslink']
+ c_compilers = ['icc', 'gcc', 'msvc']
+ assemblers = ['nasm', 'masm', 'gas']
+ fortran_compilers = ['ifl', 'g77']
+ ars = ['ar', 'lib']
+ else:
+ "prefer GNU tools on all other platforms"
+ linkers = ['gnulink', 'mslink', 'ilink']
+ c_compilers = ['gcc', 'msvc', 'icc']
+ assemblers = ['gas', 'nasm', 'masm']
+ fortran_compilers = ['g77', 'ifl']
+ ars = ['ar', 'lib']
+
+ linker = FindTool(linkers)
+ c_compiler = FindTool(c_compilers)
+ assembler = FindTool(assemblers)
+ fortran_compiler = FindTool(fortran_compilers)
+ ar = FindTool(ars)
+
+ # Don't use g++ if the C compiler has built-in C++ support:
+ if c_compiler and (c_compiler == 'msvc' or c_compiler == 'icc'):
+ cxx_compiler = None
+ else:
+ cxx_compiler = FindTool(['g++'])
+
+ other_tools = FindAllTools(['dvipdf', 'dvips',
+ 'latex', 'lex',
+ 'pdflatex', 'pdftex',
+ 'tar', 'tex', 'yacc'])
+
+ tools = ([linker, c_compiler, cxx_compiler,
+ fortran_compiler, assembler, ar]
+ + other_tools)
+
return filter(lambda x: x, tools)
test = TestSCons.TestSCons()
-test.write('SConstruct', "print Environment()['F77']\n")
+test.write('SConstruct', """
+try:
+ print Environment()['F77']
+except:
+ print 'There is no fortran compiler.'
+""")
test.run()
f77 = test.where_is(test.stdout()[:-1])
test.unlink('SConstruct')
env.Program(target='foo2', source='f2.c')
env.Program(target='foo1', source='f1.c')
-if WhereIs(env['F77']):
+try:
+ f77 = env['F77']
+except:
+ f77 = None
+
+if f77 and WhereIs(env['F77']):
env.Command(target='b2.f', source='b2.in', action=buildIt)
env.Copy(LIBS = 'g2c').Program(target='bar2', source='b2.f')
env.Copy(LIBS = 'g2c').Program(target='bar1', source='b1.f')