From 246819663b8eaeb130580f4b97990248f26eaadd Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Thu, 5 Sep 2002 00:04:32 +0000 Subject: Fix the tests that broke from the tool auto-detect stuff. (Anthony Roach and SK) --- doc/man/scons.1 | 64 ++++++++--------------------------- rpm/scons.spec | 6 +++- src/engine/MANIFEST.in | 1 + src/engine/SCons/Environment.py | 2 +- src/engine/SCons/Platform/__init__.py | 4 +-- src/engine/SCons/Tool/__init__.py | 31 +++++++++-------- src/engine/SCons/Tool/ar.py | 6 ++-- src/engine/SCons/Tool/default.py | 44 ++++++++++++++++++++++++ src/engine/SCons/Tool/dvipdf.py | 4 +-- src/engine/SCons/Tool/dvips.py | 4 +-- src/engine/SCons/Tool/g++.py | 12 ++----- src/engine/SCons/Tool/g77.py | 12 ++----- src/engine/SCons/Tool/gas.py | 13 ++----- src/engine/SCons/Tool/gcc.py | 13 ++----- src/engine/SCons/Tool/gnulink.py | 12 ++----- src/engine/SCons/Tool/icc.py | 8 ++--- src/engine/SCons/Tool/ifl.py | 5 ++- src/engine/SCons/Tool/ilink.py | 4 +-- src/engine/SCons/Tool/latex.py | 4 +-- src/engine/SCons/Tool/lex.py | 4 +-- src/engine/SCons/Tool/lib.py | 4 +-- src/engine/SCons/Tool/masm.py | 4 +-- src/engine/SCons/Tool/mslink.py | 4 +-- src/engine/SCons/Tool/msvc.py | 8 ++--- src/engine/SCons/Tool/nasm.py | 4 +-- src/engine/SCons/Tool/pdflatex.py | 4 +-- src/engine/SCons/Tool/pdftex.py | 4 +-- src/engine/SCons/Tool/tar.py | 12 ++----- src/engine/SCons/Tool/tex.py | 4 +-- src/engine/SCons/Tool/yacc.py | 4 +-- src/engine/SCons/Util.py | 14 ++++++++ test/CFILESUFFIX.py | 2 +- test/CXXFILESUFFIX.py | 2 +- test/DVIPDF.py | 3 +- test/DVIPDFFLAGS.py | 3 +- test/DVIPS.py | 3 +- test/DVIPSFLAGS.py | 3 +- test/LATEX.py | 2 +- test/LATEXFLAGS.py | 2 +- test/LEX.py | 2 +- test/LEXFLAGS.py | 2 +- test/PDFLATEX.py | 2 +- test/PDFLATEXFLAGS.py | 2 +- test/PDFTEX.py | 2 +- test/PDFTEXFLAGS.py | 2 +- test/TEX.py | 2 +- test/TEXFLAGS.py | 2 +- test/YACC.py | 8 ++++- test/YACCFLAGS.py | 8 +++-- 49 files changed, 188 insertions(+), 183 deletions(-) create mode 100644 src/engine/SCons/Tool/default.py diff --git a/doc/man/scons.1 b/doc/man/scons.1 index eb0954c..dfed6c3 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -711,69 +711,31 @@ def my_tool(env): env = Environment(tools = [my_tool]) .EE -SCons supports the following tool specifications -out of the box on -.B cygwin -and -.B posix -platforms: +If no tool list is specified, then SCons will auto-detect the installed +tools using the PATH variable in the ENV construction variable and the +platform name when the Environment is constructed. Changing the PATH +variable after the Environment is constructed will not cause the tools to +be redetected. +SCons supports the following tool specifications +out of the box on all platforms: .ES ar dvipdf dvips g++ g77 -gas (if the GNU assembler is available) -gcc -gnulink -latex -lex -nasm (if the GNU assembler is not available) -pdflatex -pdftex -tar -tex -yacc -.EE - -SCons supports the following tool specifications out of the box on -.B os2 -platforms: - -.ES -dvipdf -dvips -g77 -icc -ifl -ilink -latex -lex -nasm -pdflatex -pdftex -tex -yacc -.EE - -SCons supports the following tool specifications out of the box on -.B win32 -platforms: - -.ES -dvipdf -dvips -g77 icc ifl ilink +gas +gcc +gnulink latex lex -lib +masm mslink msvc -masm nasm pdflatex pdftex @@ -782,6 +744,10 @@ tex yacc .EE +On posix and cygwin platforms the GNU tools (e.g. gcc) are preferred by SCons, +on win32 the Microsoft tools (e.g. msvc) are preferred by SCons, and in OS/2 the IBM +tools (e.g. icc) are preferred by SCons. + .SS Builder Methods Build rules are specified by calling a construction diff --git a/rpm/scons.spec b/rpm/scons.spec index aae24a6..a4635d9 100644 --- a/rpm/scons.spec +++ b/rpm/scons.spec @@ -1,5 +1,5 @@ %define name scons -%define version 0.08 +%define version 0.09 %define release 1 Summary: an Open Source software construction tool @@ -102,6 +102,8 @@ rm -rf $RPM_BUILD_ROOT /usr/lib/scons/SCons/Tool/__init__.pyc /usr/lib/scons/SCons/Tool/ar.py /usr/lib/scons/SCons/Tool/ar.pyc +/usr/lib/scons/SCons/Tool/default.py +/usr/lib/scons/SCons/Tool/default.pyc /usr/lib/scons/SCons/Tool/dvipdf.py /usr/lib/scons/SCons/Tool/dvipdf.pyc /usr/lib/scons/SCons/Tool/dvips.py @@ -118,6 +120,8 @@ rm -rf $RPM_BUILD_ROOT /usr/lib/scons/SCons/Tool/gnulink.pyc /usr/lib/scons/SCons/Tool/icc.py /usr/lib/scons/SCons/Tool/icc.pyc +/usr/lib/scons/SCons/Tool/ifl.py +/usr/lib/scons/SCons/Tool/ifl.pyc /usr/lib/scons/SCons/Tool/ilink.py /usr/lib/scons/SCons/Tool/ilink.pyc /usr/lib/scons/SCons/Tool/latex.py diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in index 8113904..4441f5a 100644 --- a/src/engine/MANIFEST.in +++ b/src/engine/MANIFEST.in @@ -26,6 +26,7 @@ SCons/Sig/TimeStamp.py SCons/Taskmaster.py SCons/Tool/__init__.py SCons/Tool/ar.py +SCons/Tool/default.py SCons/Tool/dvipdf.py SCons/Tool/dvips.py SCons/Tool/g++.py diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 99927f6..6566427 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -129,7 +129,7 @@ class Environment: platform = SCons.Platform.Platform(platform) platform(self) if tools is None: - tools = SCons.Platform.DefaultToolList(platform) + tools = ['default'] 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 9d73cd7..6401433 100644 --- a/src/engine/SCons/Platform/__init__.py +++ b/src/engine/SCons/Platform/__init__.py @@ -85,10 +85,10 @@ def platform_module(name = platform_default()): file.close() return sys.modules[full_name] -def DefaultToolList(platform): +def DefaultToolList(platform, env): """Select a default tool list for the specified platform. """ - return SCons.Tool.tool_list(platform) + return SCons.Tool.tool_list(platform, env) class PlatformSpec: def __init__(self, name): diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 0095cdf..6b78faf 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -116,29 +116,30 @@ def createCFileBuilders(env): except KeyError: c_file = SCons.Defaults.CFile() env['BUILDERS']['CFile'] = c_file + env['CFILESUFFIX'] = '.c' try: cxx_file = env['BUILDERS']['CXXFile'] except KeyError: cxx_file = SCons.Defaults.CXXFile() env['BUILDERS']['CXXFile'] = cxx_file + env['CXXFILESUFFIX'] = '.cc' return (c_file, cxx_file) -def FindTool(tools): +def FindTool(tools, env): for tool in tools: t = Tool(tool) - if t.exists(): + if t.exists(env): return tool return None -def _ToolExists(tool): - return Tool(tool).exists() - -def FindAllTools(tools): - return filter (_ToolExists, tools) +def FindAllTools(tools, env): + def ToolExists(tool, env=env): + return Tool(tool).exists(env) + return filter (ToolExists, tools) -def tool_list(platform): +def tool_list(platform, env): if str(platform) == 'win32': "prefer Microsoft tools on Windows" linkers = ['mslink', 'gnulink', 'ilink'] @@ -161,22 +162,22 @@ def tool_list(platform): 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) + linker = FindTool(linkers, env) or linkers[0] + c_compiler = FindTool(c_compilers, env) or c_compilers[0] + assembler = FindTool(assemblers, env) or assemblers[0] + fortran_compiler = FindTool(fortran_compilers, env) or fortran_compilers[0] + ar = FindTool(ars, env) or ars[0] # 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++']) + cxx_compiler = FindTool(['g++'], env) other_tools = FindAllTools(['dvipdf', 'dvips', 'latex', 'lex', 'pdflatex', 'pdftex', - 'tar', 'tex', 'yacc']) + 'tar', 'tex', 'yacc'], env) tools = ([linker, c_compiler, cxx_compiler, fortran_compiler, assembler, ar] diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py index da66413..0535b23 100644 --- a/src/engine/SCons/Tool/ar.py +++ b/src/engine/SCons/Tool/ar.py @@ -44,7 +44,7 @@ def generate(env, platform): arcom = '$AR $ARFLAGS $TARGET $SOURCES' ranlib = 'ranlib' - if SCons.Util.WhereIs(ranlib): + if SCons.Util.Detect([ranlib], env): arcom = arcom + '\n$RANLIB $RANLIBFLAGS $TARGET' env['AR'] = 'ar' @@ -56,5 +56,5 @@ def generate(env, platform): env['SHLINKFLAGS'] = '$LINKFLAGS -shared' env['SHLINKCOM'] = '$SHLINK $SHLINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' -def exists(): - return SCons.Util.WhereIs('ar') +def exists(env): + return SCons.Util.Detect(['ar'], env) diff --git a/src/engine/SCons/Tool/default.py b/src/engine/SCons/Tool/default.py new file mode 100644 index 0000000..e72b5b1 --- /dev/null +++ b/src/engine/SCons/Tool/default.py @@ -0,0 +1,44 @@ +"""SCons.Tool.default + +Initialization with a default tool list. + +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 default tools.""" + for t in SCons.Tool.tool_list(platform, env): + SCons.Tool.Tool(t, platform)(env, platform) + +def exists(env): + return 1 diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py index 6de52f1..c99c333 100644 --- a/src/engine/SCons/Tool/dvipdf.py +++ b/src/engine/SCons/Tool/dvipdf.py @@ -48,5 +48,5 @@ def generate(env, platform): env['DVIPDFFLAGS'] = '' env['PDFCOM'] = '$DVIPDF $DVIPDFFLAGS $SOURCES $TARGET' -def exists(): - return SCons.Util.WhereIs('dvipdf') +def exists(env): + return SCons.Util.Detect(['dvipdf'], env) diff --git a/src/engine/SCons/Tool/dvips.py b/src/engine/SCons/Tool/dvips.py index 7da853d..dc8ad0d 100644 --- a/src/engine/SCons/Tool/dvips.py +++ b/src/engine/SCons/Tool/dvips.py @@ -50,5 +50,5 @@ def generate(env, platform): env['DVIPSFLAGS'] = '' env['PSCOM'] = '$DVIPS $DVIPSFLAGS -o $TARGET $SOURCES' -def exists(): - return SCons.Util.WhereIs('dvips') +def exists(env): + return SCons.Util.Detect(['dvips'], env) diff --git a/src/engine/SCons/Tool/g++.py b/src/engine/SCons/Tool/g++.py index 3c6dd36..9dba2c2 100644 --- a/src/engine/SCons/Tool/g++.py +++ b/src/engine/SCons/Tool/g++.py @@ -41,12 +41,6 @@ import SCons.Util compilers = ['c++', 'g++'] -for i in compilers: - if SCons.Util.WhereIs(i): - cxx = i - break - cxx = None - CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++'] if os.path.normcase('.c') != os.path.normcase('.C'): CXXSuffixes.append('.C') @@ -59,7 +53,7 @@ def generate(env, platform): static_obj.add_action(suffix, SCons.Defaults.CXXAction) shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction) - env['CXX'] = cxx + env['CXX'] = SCons.Util.Detect(compilers, env) or 'c++' env['CXXFLAGS'] = '$CCFLAGS' env['CXXCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES' env['SHCXX'] = '$CXX' @@ -70,5 +64,5 @@ def generate(env, platform): env['CXXFILESUFFIX'] = '.cc' -def exists(): - return cxx +def exists(env): + return SCons.Util.Detect(compilers, env) diff --git a/src/engine/SCons/Tool/g77.py b/src/engine/SCons/Tool/g77.py index 1066c0f..c3ddcbf 100644 --- a/src/engine/SCons/Tool/g77.py +++ b/src/engine/SCons/Tool/g77.py @@ -40,12 +40,6 @@ import SCons.Tool import SCons.Util compilers = ['g77', 'f77'] -for i in compilers: - if SCons.Util.WhereIs(i): - compiler = i - break - compiler = None - F77Suffixes = ['.f', '.for', '.FOR'] F77PPSuffixes = ['.fpp', '.FPP'] @@ -66,7 +60,7 @@ def generate(env, platform): static_obj.add_action(suffix, SCons.Defaults.F77PPAction) shared_obj.add_action(suffix, SCons.Defaults.ShF77PPAction) - env['F77'] = 'g77' + env['F77'] = SCons.Util.Detect(compilers, env) or 'g77' env['F77FLAGS'] = '' env['F77COM'] = '$F77 $F77FLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' env['F77PPCOM'] = '$F77 $F77FLAGS $CPPFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' @@ -75,5 +69,5 @@ def generate(env, platform): env['SHF77COM'] = '$SHF77 $SHF77FLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' env['SHF77PPCOM'] = '$SHF77 $SHF77FLAGS $CPPFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' -def exists(): - return compiler +def exists(env): + return SCons.Util.Detect(compilers, env) diff --git a/src/engine/SCons/Tool/gas.py b/src/engine/SCons/Tool/gas.py index 36672a1..a8c2864 100644 --- a/src/engine/SCons/Tool/gas.py +++ b/src/engine/SCons/Tool/gas.py @@ -41,13 +41,6 @@ import SCons.Util assemblers = ['as', 'gas'] -for i in assemblers: - if SCons.Util.WhereIs(i): - as = i - break - as = None - - ASSuffixes = ['.s', '.asm', '.ASM'] ASPPSuffixes = ['.spp', '.SPP'] if os.path.normcase('.s') == os.path.normcase('.S'): @@ -65,10 +58,10 @@ def generate(env, platform): for suffix in ASPPSuffixes: static_obj.add_action(suffix, SCons.Defaults.ASPPAction) - env['AS'] = as + env['AS'] = SCons.Util.Detect(assemblers, env) or 'as' env['ASFLAGS'] = '' env['ASCOM'] = '$AS $ASFLAGS -o $TARGET $SOURCES' env['ASPPCOM'] = '$CC $ASFLAGS $CPPFLAGS -o $TARGET $SOURCES' -def exists(): - return as +def exists(env): + return SCons.Util.Detect(assemblers, env) diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py index 8eae17f..6dbe0af 100644 --- a/src/engine/SCons/Tool/gcc.py +++ b/src/engine/SCons/Tool/gcc.py @@ -41,13 +41,6 @@ import SCons.Util compilers = ['cc', 'gcc'] -for i in compilers: - if SCons.Util.WhereIs(i): - cc = i - break - cc = None - - CSuffixes = ['.c'] if os.path.normcase('.c') == os.path.normcase('.C'): CSuffixes.append('.C') @@ -60,7 +53,7 @@ def generate(env, platform): static_obj.add_action(suffix, SCons.Defaults.CAction) shared_obj.add_action(suffix, SCons.Defaults.ShCAction) - env['CC'] = cc + env['CC'] = SCons.Util.Detect(compilers, env) or 'cc' env['CCFLAGS'] = '' env['CCCOM'] = '$CC $CCFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES' env['SHCC'] = '$CC' @@ -72,5 +65,5 @@ def generate(env, platform): env['CFILESUFFIX'] = '.c' -def exists(): - return cc +def exists(env): + return SCons.Util.Detect(compilers, env) diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py index 3fc78b1..0a6b22e 100644 --- a/src/engine/SCons/Tool/gnulink.py +++ b/src/engine/SCons/Tool/gnulink.py @@ -38,12 +38,6 @@ import SCons.Util linkers = ['c++', 'cc', 'g++', 'gcc'] -for i in linkers: - if SCons.Util.WhereIs(i): - linker = i - break - linker = None - def generate(env, platform): """Add Builders and construction variables for gnulink to an Environment.""" env['BUILDERS']['SharedLibrary'] = SCons.Defaults.SharedLibrary @@ -53,7 +47,7 @@ def generate(env, platform): env['SHLINKFLAGS'] = '$LINKFLAGS -shared' env['SHLINKCOM'] = '$SHLINK $SHLINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' env['SHLIBEMITTER']= None - env['LINK'] = linker + env['LINK'] = SCons.Util.Detect(linkers, env) or 'c++' env['LINKFLAGS'] = '' env['LINKCOM'] = '$LINK $LINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS' env['LIBDIRPREFIX']='-L' @@ -61,5 +55,5 @@ def generate(env, platform): env['LIBLINKPREFIX']='-l' env['LIBLINKSUFFIX']='' -def exists(): - return linker +def exists(env): + return SCons.Util.Detect(linkers, env) diff --git a/src/engine/SCons/Tool/icc.py b/src/engine/SCons/Tool/icc.py index df1eb00..5a09cb8 100644 --- a/src/engine/SCons/Tool/icc.py +++ b/src/engine/SCons/Tool/icc.py @@ -63,9 +63,9 @@ def generate(env, platform): env['CXXCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET' env['INCPREFIX'] = '/I' env['INCSUFFIX'] = '' - + env['CFILESUFFIX'] = '.c' env['CXXFILESUFFIX'] = '.cc' - -def exists(): - return SCons.Util.WhereIs('icc') + +def exists(env): + return SCons.Util.Detect(['icc'], env) diff --git a/src/engine/SCons/Tool/ifl.py b/src/engine/SCons/Tool/ifl.py index 1f4f8f4..69a1ffd 100644 --- a/src/engine/SCons/Tool/ifl.py +++ b/src/engine/SCons/Tool/ifl.py @@ -34,7 +34,6 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path -import string import SCons.Action import SCons.Tool @@ -68,5 +67,5 @@ def generate(env, platform): env['SHF77COM'] = '$SHF77 $SHF77FLAGS $_F77INCFLAGS /c $SOURCES /Fo$TARGET' env['SHF77PPCOM'] = '$SHF77 $SHF77FLAGS $CPPFLAGS $_F77INCFLAGS /c $SOURCES /Fo$TARGET' -def exists(): - return SCons.Util.WhereIs('ifl') +def exists(env): + return SCons.Util.Detect(['ifl'], env) diff --git a/src/engine/SCons/Tool/ilink.py b/src/engine/SCons/Tool/ilink.py index 323f808..f3e5659 100644 --- a/src/engine/SCons/Tool/ilink.py +++ b/src/engine/SCons/Tool/ilink.py @@ -47,5 +47,5 @@ def generate(env, platform): env['LIBLINKPREFIX']='' env['LIBLINKSUFFIX']='$LIBSUFFIX' -def exists(): - return SCons.Util.WhereIs('ilink') +def exists(env): + return SCons.Util.Detect(['ilink'], env) diff --git a/src/engine/SCons/Tool/latex.py b/src/engine/SCons/Tool/latex.py index 6523580..192ccf0 100644 --- a/src/engine/SCons/Tool/latex.py +++ b/src/engine/SCons/Tool/latex.py @@ -54,5 +54,5 @@ def generate(env, platform): env['LATEXFLAGS'] = '' env['LATEXCOM'] = '$LATEX $LATEXFLAGS $SOURCES' -def exists(): - return SCons.Util.WhereIs('latex') +def exists(env): + return SCons.Util.Detect(['latex'], env) diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py index 0dda128..2a936e5 100644 --- a/src/engine/SCons/Tool/lex.py +++ b/src/engine/SCons/Tool/lex.py @@ -47,5 +47,5 @@ def generate(env, platform): env['LEXFLAGS'] = '' env['LEXCOM'] = '$LEX $LEXFLAGS -t $SOURCES > $TARGET' -def exists(): - return SCons.Util.WhereIs('lex') +def exists(env): + return SCons.Util.Detect(['lex'], env) diff --git a/src/engine/SCons/Tool/lib.py b/src/engine/SCons/Tool/lib.py index 477bf9e..7b5e0cd 100644 --- a/src/engine/SCons/Tool/lib.py +++ b/src/engine/SCons/Tool/lib.py @@ -44,5 +44,5 @@ def generate(env, platform): env['ARFLAGS'] = '/nologo' env['ARCOM'] = '$AR $ARFLAGS /OUT:$TARGET $SOURCES' -def exists(): - return SCons.Util.WhereIs('lib') +def exists(env): + return SCons.Util.Detect(['lib'], env) diff --git a/src/engine/SCons/Tool/masm.py b/src/engine/SCons/Tool/masm.py index 9d95913..6581e42 100644 --- a/src/engine/SCons/Tool/masm.py +++ b/src/engine/SCons/Tool/masm.py @@ -60,5 +60,5 @@ def generate(env, platform): env['ASCOM'] = '$AS $ASFLAGS /c /Fo$TARGET $SOURCES' env['ASPPCOM'] = '$CC $ASFLAGS $CPPFLAGS /c /Fo$TARGET $SOURCES' -def exists(): - return SCons.Util.WhereIs('ml') +def exists(env): + return SCons.Util.Detect(['ml'], env) diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index 1bc9ce3..eb8fa26 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -152,5 +152,5 @@ def generate(env, platform): env['ENV']['LIB'] = lib_path env['ENV']['PATH'] = exe_path -def exists(): - return SCons.Util.WhereIs('link') +def exists(env): + return SCons.Util.Detect(['link'], env) diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index 33da2ec..fadebc6 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -217,9 +217,9 @@ def generate(env, platform): 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' - -def exists(): - return SCons.Util.WhereIs('cl') + +def exists(env): + return SCons.Util.Detect(['cl'], env) diff --git a/src/engine/SCons/Tool/nasm.py b/src/engine/SCons/Tool/nasm.py index e341dde..7be7091 100644 --- a/src/engine/SCons/Tool/nasm.py +++ b/src/engine/SCons/Tool/nasm.py @@ -60,5 +60,5 @@ def generate(env, platform): env['ASCOM'] = '$AS $ASFLAGS -o $TARGET $SOURCES' env['ASPPCOM'] = '$CC $ASFLAGS $CPPFLAGS -c -o $TARGET $SOURCES' -def exists(): - return SCons.Util.WhereIs('nasm') +def exists(env): + return SCons.Util.Detect(['nasm'], env) diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py index 1e9e733..2051717 100644 --- a/src/engine/SCons/Tool/pdflatex.py +++ b/src/engine/SCons/Tool/pdflatex.py @@ -53,5 +53,5 @@ def generate(env, platform): env['PDFLATEXFLAGS'] = '' env['PDFLATEXCOM'] = '$PDFLATEX $PDFLATEXFLAGS $SOURCES $TARGET' -def exists(): - return SCons.Util.WhereIs('pdflatex') +def exists(env): + return SCons.Util.Detect(['pdflatex'], env) diff --git a/src/engine/SCons/Tool/pdftex.py b/src/engine/SCons/Tool/pdftex.py index f7dc60c..2d538b7 100644 --- a/src/engine/SCons/Tool/pdftex.py +++ b/src/engine/SCons/Tool/pdftex.py @@ -49,5 +49,5 @@ def generate(env, platform): env['PDFTEXFLAGS'] = '' env['PDFTEXCOM'] = '$PDFTEX $PDFTEXFLAGS $SOURCES $TARGET' -def exists(): - return SCons.Util.WhereIs('pdftex') +def exists(env): + return SCons.Util.Detect(['pdftex'], env) diff --git a/src/engine/SCons/Tool/tar.py b/src/engine/SCons/Tool/tar.py index 0acfd56..4cf88ba 100644 --- a/src/engine/SCons/Tool/tar.py +++ b/src/engine/SCons/Tool/tar.py @@ -39,12 +39,6 @@ import SCons.Util tars = ['gtar', 'tar'] -for i in tars: - if SCons.Util.WhereIs(i): - tar = i - break - tar = None - TarBuilder = SCons.Builder.Builder(action = '$TARCOM', source_factory = SCons.Node.FS.default_fs.Entry, suffix = '$TARSUFFIX', @@ -59,10 +53,10 @@ def generate(env, platform): bld = TarBuilder env['BUILDERS']['Tar'] = bld - env['TAR'] = tar + env['TAR'] = SCons.Util.Detect(tars, env) or 'gtar' env['TARFLAGS'] = '-c' env['TARCOM'] = '$TAR $TARFLAGS -f $TARGET $SOURCES' env['TARSUFFIX'] = '.tar' -def exists(): - return tar +def exists(env): + return SCons.Util.Detect(tars, env) diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index 9e0d962..deed4cb 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -49,5 +49,5 @@ def generate(env, platform): env['TEXFLAGS'] = '' env['TEXCOM'] = '$TEX $TEXFLAGS $SOURCES' -def exists(): - return SCons.Util.WhereIs('tex') +def exists(env): + return SCons.Util.Detect(['tex'], env) diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py index bce4a39..4e63c19 100644 --- a/src/engine/SCons/Tool/yacc.py +++ b/src/engine/SCons/Tool/yacc.py @@ -46,5 +46,5 @@ def generate(env, platform): env['YACCFLAGS'] = '' env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES' -def exists(): - return SCons.Util.WhereIs('yacc') +def exists(env): + return SCons.Util.Detect(['yacc'], env) diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 63c992e..bcf0e14 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -489,3 +489,17 @@ else: if stat.S_IMODE(st[stat.ST_MODE]) & 0111: return f return None + +def Detect(progs, env=None): + "Return the first available program in progs" + path = None + pathext = None + if env and env.has_key('ENV'): + if env['ENV'].has_key('PATH'): + path = env['ENV']['PATH'] + if env['ENV'].has_key('PATHEXT'): + pathext = env['ENV']['PATHEXT'] + for prog in progs: + path = WhereIs(prog, path, pathext) + if path: return prog + return None diff --git a/test/CFILESUFFIX.py b/test/CFILESUFFIX.py index 5c04686..c5eb6cb 100644 --- a/test/CFILESUFFIX.py +++ b/test/CFILESUFFIX.py @@ -46,7 +46,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(LEX = r'%s mylex.py') +env = Environment(LEX = r'%s mylex.py', tools = ['lex']) env.CFile(target = 'foo', source = 'foo.l') env.Copy(CFILESUFFIX = '.xyz').CFile(target = 'bar', source = 'bar.l') """ % python) diff --git a/test/CXXFILESUFFIX.py b/test/CXXFILESUFFIX.py index 48c62a9..e158240 100644 --- a/test/CXXFILESUFFIX.py +++ b/test/CXXFILESUFFIX.py @@ -46,7 +46,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(LEX = r'%s mylex.py') +env = Environment(LEX = r'%s mylex.py', tools = ['lex']) env.CXXFile(target = 'foo', source = 'foo.ll') env.Copy(CXXFILESUFFIX = '.xyz').CXXFile(target = 'bar', source = 'bar.ll') """ % python) diff --git a/test/DVIPDF.py b/test/DVIPDF.py index 25856dc..26b6b94 100644 --- a/test/DVIPDF.py +++ b/test/DVIPDF.py @@ -74,7 +74,8 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(TEX = r'%s mytex.py', LATEX = r'%s mylatex.py', - DVIPDF = r'%s mydvipdf.py') + DVIPDF = r'%s mydvipdf.py', + tools=['latex', 'tex', 'dvipdf']) dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') env.DVI(target = 'test2.dvi', source = 'test2.tex') env.PDF(target = 'test1.pdf', source = dvi) diff --git a/test/DVIPDFFLAGS.py b/test/DVIPDFFLAGS.py index 9962253..1548360 100644 --- a/test/DVIPDFFLAGS.py +++ b/test/DVIPDFFLAGS.py @@ -80,7 +80,8 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(TEX = r'%s mytex.py', LATEX = r'%s mylatex.py', - DVIPDF = r'%s mydvipdf.py', DVIPDFFLAGS = '-x') + DVIPDF = r'%s mydvipdf.py', DVIPDFFLAGS = '-x', + tools = ['tex', 'latex', 'dvipdf']) dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') env.DVI(target = 'test2.dvi', source = 'test2.tex') env.PDF(target = 'test1.pdf', source = dvi) diff --git a/test/DVIPS.py b/test/DVIPS.py index b3bdebc..9cb6d5f 100644 --- a/test/DVIPS.py +++ b/test/DVIPS.py @@ -74,7 +74,8 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(TEX = r'%s mytex.py', LATEX = r'%s mylatex.py', - DVIPS = r'%s mydvips.py') + DVIPS = r'%s mydvips.py', + tools=['tex', 'latex', 'dvips']) dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') env.PostScript(target = 'test1.ps', source = dvi) env.PostScript(target = 'test2.ps', source = 'test2.tex') diff --git a/test/DVIPSFLAGS.py b/test/DVIPSFLAGS.py index 664b532..a67a058 100644 --- a/test/DVIPSFLAGS.py +++ b/test/DVIPSFLAGS.py @@ -81,7 +81,8 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(TEX = r'%s mytex.py', LATEX = r'%s mylatex.py', - DVIPS = r'%s mydvips.py', DVIPSFLAGS = '-x') + DVIPS = r'%s mydvips.py', DVIPSFLAGS = '-x', + tools=['tex', 'latex', 'dvips']) dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') env.PostScript(target = 'test1.ps', source = dvi) env.PostScript(target = 'test2.ps', source = 'test2.tex') diff --git a/test/LATEX.py b/test/LATEX.py index 440054d..7aa8187 100644 --- a/test/LATEX.py +++ b/test/LATEX.py @@ -49,7 +49,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(LATEX = r'%s mylatex.py') +env = Environment(LATEX = r'%s mylatex.py', tools=['latex']) env.DVI(target = 'test1.dvi', source = 'test1.ltx') env.DVI(target = 'test2.dvi', source = 'test2.latex') """ % python) diff --git a/test/LATEXFLAGS.py b/test/LATEXFLAGS.py index 5ad4d95..a441934 100644 --- a/test/LATEXFLAGS.py +++ b/test/LATEXFLAGS.py @@ -55,7 +55,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(LATEX = r'%s mylatex.py', LATEXFLAGS = '-x') +env = Environment(LATEX = r'%s mylatex.py', LATEXFLAGS = '-x', tools=['latex']) env.DVI(target = 'test1.dvi', source = 'test1.ltx') env.Copy(LATEXFLAGS = '-t').DVI(target = 'test2.dvi', source = 'test2.latex') """ % python) diff --git a/test/LEX.py b/test/LEX.py index 88c0a2d..28cbdec 100644 --- a/test/LEX.py +++ b/test/LEX.py @@ -53,7 +53,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(LEX = r'%s mylex.py') +env = Environment(LEX = r'%s mylex.py', tools=['default', 'lex']) env.Program(target = 'aaa', source = 'aaa.l') """ % python) diff --git a/test/LEXFLAGS.py b/test/LEXFLAGS.py index e807774..169ae80 100644 --- a/test/LEXFLAGS.py +++ b/test/LEXFLAGS.py @@ -56,7 +56,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(LEX = r'%s mylex.py', LEXFLAGS = '-x') +env = Environment(LEX = r'%s mylex.py', LEXFLAGS = '-x', tools=['default', 'lex']) env.Program(target = 'aaa', source = 'aaa.l') """ % python) diff --git a/test/PDFLATEX.py b/test/PDFLATEX.py index f665d0f..b49ac89 100644 --- a/test/PDFLATEX.py +++ b/test/PDFLATEX.py @@ -49,7 +49,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(PDFLATEX = r'%s mypdflatex.py') +env = Environment(PDFLATEX = r'%s mypdflatex.py', tools=['pdflatex']) env.PDF(target = 'test1.pdf', source = 'test1.ltx') env.PDF(target = 'test2.pdf', source = 'test2.latex') """ % python) diff --git a/test/PDFLATEXFLAGS.py b/test/PDFLATEXFLAGS.py index 6ddd41a..67e1627 100644 --- a/test/PDFLATEXFLAGS.py +++ b/test/PDFLATEXFLAGS.py @@ -55,7 +55,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(PDFLATEX = r'%s mypdflatex.py', PDFLATEXFLAGS = '-x') +env = Environment(PDFLATEX = r'%s mypdflatex.py', PDFLATEXFLAGS = '-x', tools=['pdflatex']) env.PDF(target = 'test1.pdf', source = 'test1.ltx') env.Copy(PDFLATEXFLAGS = '-t').PDF(target = 'test2.pdf', source = 'test2.latex') """ % python) diff --git a/test/PDFTEX.py b/test/PDFTEX.py index 4fe5341..47fdc9d 100644 --- a/test/PDFTEX.py +++ b/test/PDFTEX.py @@ -49,7 +49,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(PDFTEX = r'%s mypdftex.py') +env = Environment(PDFTEX = r'%s mypdftex.py', tools=['pdftex']) env.PDF(target = 'test.pdf', source = 'test.tex') """ % python) diff --git a/test/PDFTEXFLAGS.py b/test/PDFTEXFLAGS.py index aa5cc9f..34647df 100644 --- a/test/PDFTEXFLAGS.py +++ b/test/PDFTEXFLAGS.py @@ -55,7 +55,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(PDFTEX = r'%s mypdftex.py', PDFTEXFLAGS = '-x') +env = Environment(PDFTEX = r'%s mypdftex.py', PDFTEXFLAGS = '-x', tools=['pdftex']) env.PDF(target = 'test.pdf', source = 'test.tex') """ % python) diff --git a/test/TEX.py b/test/TEX.py index bcdd62e..a5f981e 100644 --- a/test/TEX.py +++ b/test/TEX.py @@ -49,7 +49,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(TEX = r'%s mytex.py') +env = Environment(TEX = r'%s mytex.py', tools=['tex']) env.DVI(target = 'test.dvi', source = 'test.tex') """ % python) diff --git a/test/TEXFLAGS.py b/test/TEXFLAGS.py index 1f7121f..075750c 100644 --- a/test/TEXFLAGS.py +++ b/test/TEXFLAGS.py @@ -55,7 +55,7 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(TEX = r'%s mytex.py', TEXFLAGS = '-x') +env = Environment(TEX = r'%s mytex.py', TEXFLAGS = '-x', tools=['tex']) env.DVI(target = 'test.dvi', source = 'test.tex') """ % python) diff --git a/test/YACC.py b/test/YACC.py index 2868085..1df8cc5 100644 --- a/test/YACC.py +++ b/test/YACC.py @@ -34,8 +34,12 @@ python = sys.executable if sys.platform == 'win32': _exe = '.exe' + compiler = 'msvc' + linker = 'mslink' else: _exe = '' + compiler = 'gcc' + linker = 'gnulink' test = TestSCons.TestSCons() @@ -58,8 +62,10 @@ output.close() sys.exit(0) """) + + test.write('SConstruct', """ -env = Environment(YACC = r'%s myyacc.py') +env = Environment(YACC = r'%s myyacc.py', tools=['default', 'yacc']) env.Program(target = 'aaa', source = 'aaa.y') """ % python) diff --git a/test/YACCFLAGS.py b/test/YACCFLAGS.py index 288696b..ba38209 100644 --- a/test/YACCFLAGS.py +++ b/test/YACCFLAGS.py @@ -34,8 +34,12 @@ python = sys.executable if sys.platform == 'win32': _exe = '.exe' + compiler = 'msvc' + linker = 'mslink' else: _exe = '' + compiler = 'gcc' + linker = 'gnulink' test = TestSCons.TestSCons() @@ -59,9 +63,9 @@ sys.exit(0) """) test.write('SConstruct', """ -env = Environment(YACC = r'%s myyacc.py', YACCFLAGS = '-x') +env = Environment(YACC = r'%s myyacc.py', YACCFLAGS = '-x', tools=['yacc', '%s', '%s']) env.Program(target = 'aaa', source = 'aaa.y') -""" % python) +""" % (python, linker, compiler)) test.write('aaa.y', r""" int -- cgit v0.12