summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-03-28 11:17:52 (GMT)
committerMats Wichmann <mats@linux.com>2019-04-13 17:43:49 (GMT)
commitfd4a8f7c9383095a0e508bac937b6122dd5317d6 (patch)
treecfabafa7df9fc28b1d7bee08c6350834702f9499
parentdd1f5a85f85098b6fdfb12e6585f466ad599b48c (diff)
downloadSCons-fd4a8f7c9383095a0e508bac937b6122dd5317d6.zip
SCons-fd4a8f7c9383095a0e508bac937b6122dd5317d6.tar.gz
SCons-fd4a8f7c9383095a0e508bac937b6122dd5317d6.tar.bz2
[#3336] do not add not-found tool paths
When tool modules initialize, they check paths to decide if the underlying tool is actually present. The current checker adds any "default paths" the caller may have supplied (locations like mingw, cygwin, chocolatey install locations, etc.); if there is match from this list, any previous default paths are also kept. To avoid keeping these non-matching paths, restore the original PATH; the caller is responsible for adding to PATH if necessary. Docstring now says so. Note lex and yacc tool modules seem to expect the path-modifying behavior that's being gotten rid of - so they preseve the path first and restore it after. The change here won't break those, but makes the extra behavior unneeded - could remove it. Signed-off-by: Mats Wichmann <mats@linux.com>
-rwxr-xr-xsrc/CHANGES.txt2
-rw-r--r--src/engine/SCons/Tool/__init__.py25
-rw-r--r--src/engine/SCons/Tool/swig.py3
3 files changed, 18 insertions, 12 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 84a8056..d07b4ad 100755
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -13,6 +13,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Use importlib to dynamically load tool and platform modules instead of imp module
- sconsign: default to .sconsign.dblite if no filename is specified.
Be more informative in case of unsupported pickle protocol (py2 only).
+ - Fix issue #3336 - on Windows, paths were being added to PATH even if
+ tools were not found in those paths.
From John Doe:
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index 8fbd587..152e186 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -1318,28 +1318,31 @@ def tool_list(platform, env):
def find_program_path(env, key_program, default_paths=[]):
"""
- Find the location of key_program and then return the path it was located at.
- Checking the default install locations.
- Mainly for windows where tools aren't all installed in /usr/bin,etc
- :param env: Current Environment()
- :param key_program: Program we're using to locate the directory to add to PATH.
+ Find the location of a tool using various means.
+
+ Mainly for windows where tools aren't all installed in /usr/bin, etc.
+
+ :param env: Current Construction Environment.
+ :param key_program: Tool to locate.
+ :param default_paths: List of additional paths this tool might be found in.
"""
# First search in the SCons path
path = env.WhereIs(key_program)
- if (path):
+ if path:
return path
- # then the OS path:
+
+ # Then in the OS path
path = SCons.Util.WhereIs(key_program)
- if (path):
+ if path:
return path
- # If that doesn't work try default location for mingw
+ # Finally, add the defaults and check again. Do not change
+ # ['ENV']['PATH'] permananetly, the caller can do that if needed.
save_path = env['ENV']['PATH']
for p in default_paths:
env.AppendENVPath('PATH', p)
path = env.WhereIs(key_program)
- if not path:
- env['ENV']['PATH'] = save_path
+ env['ENV']['PATH'] = save_path
return path
# Local Variables:
diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py
index c6abefb..6ed9d82 100644
--- a/src/engine/SCons/Tool/swig.py
+++ b/src/engine/SCons/Tool/swig.py
@@ -184,9 +184,10 @@ def generate(env):
from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
+ from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
if sys.platform == 'win32':
- swig = SCons.Tool.find_program_path(env, 'swig', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS + [r'C:\ProgramData\chocolatey\bin'] )
+ swig = SCons.Tool.find_program_path(env, 'swig', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS + CHOCO_DEFAULT_PATH)
if swig:
swig_bin_dir = os.path.dirname(swig)
env.AppendENVPath('PATH', swig_bin_dir)