summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/MANIFEST.in1
-rw-r--r--src/engine/SCons/Environment.py2
-rw-r--r--src/engine/SCons/Platform/__init__.py4
-rw-r--r--src/engine/SCons/Tool/__init__.py31
-rw-r--r--src/engine/SCons/Tool/ar.py6
-rw-r--r--src/engine/SCons/Tool/default.py44
-rw-r--r--src/engine/SCons/Tool/dvipdf.py4
-rw-r--r--src/engine/SCons/Tool/dvips.py4
-rw-r--r--src/engine/SCons/Tool/g++.py12
-rw-r--r--src/engine/SCons/Tool/g77.py12
-rw-r--r--src/engine/SCons/Tool/gas.py13
-rw-r--r--src/engine/SCons/Tool/gcc.py13
-rw-r--r--src/engine/SCons/Tool/gnulink.py12
-rw-r--r--src/engine/SCons/Tool/icc.py8
-rw-r--r--src/engine/SCons/Tool/ifl.py5
-rw-r--r--src/engine/SCons/Tool/ilink.py4
-rw-r--r--src/engine/SCons/Tool/latex.py4
-rw-r--r--src/engine/SCons/Tool/lex.py4
-rw-r--r--src/engine/SCons/Tool/lib.py4
-rw-r--r--src/engine/SCons/Tool/masm.py4
-rw-r--r--src/engine/SCons/Tool/mslink.py4
-rw-r--r--src/engine/SCons/Tool/msvc.py8
-rw-r--r--src/engine/SCons/Tool/nasm.py4
-rw-r--r--src/engine/SCons/Tool/pdflatex.py4
-rw-r--r--src/engine/SCons/Tool/pdftex.py4
-rw-r--r--src/engine/SCons/Tool/tar.py12
-rw-r--r--src/engine/SCons/Tool/tex.py4
-rw-r--r--src/engine/SCons/Tool/yacc.py4
-rw-r--r--src/engine/SCons/Util.py14
29 files changed, 135 insertions, 114 deletions
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