From: stevenknight Date: Fri, 30 Aug 2002 05:06:27 +0000 (+0000) Subject: Make SCons/Tool/ifl.py get included in the win32 package, make Microsoft tools be... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=549d6ed057f1d1c10fdf999ff7d819176ff35822;p=scons.git Make SCons/Tool/ifl.py get included in the win32 package, make Microsoft tools be prefered on win32, and get rid of some cruft in the Platform files. (Anthony Roach) git-svn-id: http://scons.tigris.org/svn/scons/trunk@454 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in index 118b4ba8..81139044 100644 --- a/src/engine/MANIFEST.in +++ b/src/engine/MANIFEST.in @@ -34,6 +34,7 @@ SCons/Tool/gas.py 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 diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 47ab58b3..99927f6f 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -121,13 +121,15 @@ class Environment: 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) diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py index 2b35a2ea..9d73cd72 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -85,11 +85,10 @@ def platform_module(name = platform_default()): 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): diff --git a/src/engine/SCons/Platform/cygwin.py b/src/engine/SCons/Platform/cygwin.py index b5a73f6f..c01c022d 100644 --- a/src/engine/SCons/Platform/cygwin.py +++ b/src/engine/SCons/Platform/cygwin.py @@ -34,19 +34,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" 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'] = {} diff --git a/src/engine/SCons/Platform/os2.py b/src/engine/SCons/Platform/os2.py index 74df430d..d56150c0 100644 --- a/src/engine/SCons/Platform/os2.py +++ b/src/engine/SCons/Platform/os2.py @@ -34,14 +34,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" 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'] = {} diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py index a45dce1d..ab3fb7fc 100644 --- a/src/engine/SCons/Platform/posix.py +++ b/src/engine/SCons/Platform/posix.py @@ -34,19 +34,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" 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'] = {} diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 96404396..ea6a23b5 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -34,18 +34,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" 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'] = {} diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index f4a79125..0095cdf8 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -125,16 +125,6 @@ def createCFileBuilders(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) @@ -148,11 +138,48 @@ def _ToolExists(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) diff --git a/test/BuildDir.py b/test/BuildDir.py index d70ab7ad..c2ad4af0 100644 --- a/test/BuildDir.py +++ b/test/BuildDir.py @@ -36,7 +36,12 @@ else: 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') @@ -110,7 +115,12 @@ env.Command(target='f2.c', source='f2.in', action=buildIt) 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')