diff options
author | Mats Wichmann <mats@linux.com> | 2019-04-13 17:38:28 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2019-04-13 17:43:49 (GMT) |
commit | 77f302bcc7cff7faca0944ac6848de1c82c487d9 (patch) | |
tree | c4cd13c379dd56c8f4e051f424da831388c08fa2 /src | |
parent | fd4a8f7c9383095a0e508bac937b6122dd5317d6 (diff) | |
download | SCons-77f302bcc7cff7faca0944ac6848de1c82c487d9.zip SCons-77f302bcc7cff7faca0944ac6848de1c82c487d9.tar.gz SCons-77f302bcc7cff7faca0944ac6848de1c82c487d9.tar.bz2 |
[PR #3337] clean up lex and yacc tools
Remove now unneeded code to save/restore the path, since
the routine now does not modify the path.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/Tool/lex.py | 19 | ||||
-rw-r--r-- | src/engine/SCons/Tool/yacc.py | 27 |
2 files changed, 28 insertions, 18 deletions
diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py index a63ddc9..91d50fd 100644 --- a/src/engine/SCons/Tool/lex.py +++ b/src/engine/SCons/Tool/lex.py @@ -70,11 +70,15 @@ def lexEmitter(target, source, env): def get_lex_path(env, append_paths=False): """ - Find the a path containing the lex or flex binaries. If a construction - environment is passed in then append the path to the ENV PATH. + Find the path to the lex tool, searching several possible names + + Only called in the Windows case, so the default_path + can be Windows-specific + + :param env: current construction environment + :param append_paths: if set, add the path to the tool to PATH + :return: path to lex tool, if found """ - # save existing path to reset if we don't want to append any paths - envPath = env['ENV']['PATH'] bins = ['flex', 'lex', 'win_flex'] for prog in bins: @@ -83,9 +87,7 @@ def get_lex_path(env, append_paths=False): prog, default_paths=CHOCO_DEFAULT_PATH + MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS ) if bin_path: - if not append_paths: - env['ENV']['PATH'] = envPath - else: + if append_paths: env.AppendENVPath('PATH', os.path.dirname(bin_path)) return bin_path SCons.Warnings.Warning('lex tool requested, but lex or flex binary not found in ENV PATH') @@ -113,7 +115,8 @@ def generate(env): env["LEXFLAGS"] = SCons.Util.CLVar("") if sys.platform == 'win32': - get_lex_path(env, append_paths=True) + # ignore the return - we do not need the full path here + _ = get_lex_path(env, append_paths=True) env["LEX"] = env.Detect(['flex', 'lex', 'win_flex']) if not env.get("LEXUNISTD"): env["LEXUNISTD"] = SCons.Util.CLVar("") diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py index 5db49d3..07ba8da 100644 --- a/src/engine/SCons/Tool/yacc.py +++ b/src/engine/SCons/Tool/yacc.py @@ -100,11 +100,15 @@ def yyEmitter(target, source, env): def get_yacc_path(env, append_paths=False): """ - Find the a path containing the lex or flex binaries. If a construction - environment is passed in then append the path to the ENV PATH. + Find the path to the yacc tool, searching several possible names + + Only called in the Windows case, so the default_path + can be Windows-specific + + :param env: current construction environment + :param append_paths: if set, add the path to the tool to PATH + :return: path to yacc tool, if found """ - # save existing path to reset if we don't want to append any paths - envPath = env['ENV']['PATH'] bins = ['bison', 'yacc', 'win_bison'] for prog in bins: @@ -113,12 +117,11 @@ def get_yacc_path(env, append_paths=False): prog, default_paths=CHOCO_DEFAULT_PATH + MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS ) if bin_path: - if not append_paths: - env['ENV']['PATH'] = envPath - else: + if append_paths: env.AppendENVPath('PATH', os.path.dirname(bin_path)) return bin_path - SCons.Warnings.Warning('lex tool requested, but lex or flex binary not found in ENV PATH') + SCons.Warnings.Warning('yacc tool requested, but yacc or bison binary not found in ENV PATH') + def generate(env): """Add Builders and construction variables for yacc to an Environment.""" @@ -148,7 +151,8 @@ def generate(env): SCons.Warnings.Warning('yacc tool requested, but bison binary not found in ENV PATH') if sys.platform == 'win32': - get_yacc_path(env, append_paths=True) + # ignore the return - we do not need the full path here + _ = get_yacc_path(env, append_paths=True) env["YACC"] = env.Detect(['bison', 'yacc', 'win_bison']) else: env["YACC"] = env.Detect(["bison", "yacc"]) @@ -162,7 +166,10 @@ def generate(env): env['YACCVCGFILESUFFIX'] = '.vcg' def exists(env): - return env.Detect(['bison', 'yacc']) + if sys.platform == 'win32': + return get_yacc_path(env) + else: + return env.Detect(['bison', 'yacc']) # Local Variables: # tab-width:4 |