summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-04-15 14:08:53 (GMT)
committerMats Wichmann <mats@linux.com>2019-04-16 16:48:49 (GMT)
commitb9859740b1253ec58e5ab43ae345432dbeadd3ae (patch)
treeb96362038aaa32c48676246c7a7681282ab1e835 /src/engine
parent77f302bcc7cff7faca0944ac6848de1c82c487d9 (diff)
downloadSCons-b9859740b1253ec58e5ab43ae345432dbeadd3ae.zip
SCons-b9859740b1253ec58e5ab43ae345432dbeadd3ae.tar.gz
SCons-b9859740b1253ec58e5ab43ae345432dbeadd3ae.tar.bz2
[PR #3337] centralize definition of candidates
A list of possible executable names are provided in several places in yacc and lex tools, make it a little cleaner by defining once, at the top. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Tool/lex.py19
-rw-r--r--src/engine/SCons/Tool/yacc.py33
2 files changed, 23 insertions, 29 deletions
diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py
index 91d50fd..6b83aa9 100644
--- a/src/engine/SCons/Tool/lex.py
+++ b/src/engine/SCons/Tool/lex.py
@@ -45,6 +45,11 @@ from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
LexAction = SCons.Action.Action("$LEXCOM", "$LEXCOMSTR")
+if sys.platform == 'win32':
+ BINS = ['flex', 'lex', 'win_flex']
+else:
+ BINS = ["flex", "lex"]
+
def lexEmitter(target, source, env):
sourceBase, sourceExt = os.path.splitext(SCons.Util.to_String(source[0]))
@@ -79,12 +84,10 @@ def get_lex_path(env, append_paths=False):
:param append_paths: if set, add the path to the tool to PATH
:return: path to lex tool, if found
"""
- bins = ['flex', 'lex', 'win_flex']
-
- for prog in bins:
+ for prog in BINS:
bin_path = SCons.Tool.find_program_path(
- env,
- prog,
+ env,
+ prog,
default_paths=CHOCO_DEFAULT_PATH + MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
if bin_path:
if append_paths:
@@ -117,19 +120,19 @@ def generate(env):
if sys.platform == 'win32':
# 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'])
+ env["LEX"] = env.Detect(BINS)
if not env.get("LEXUNISTD"):
env["LEXUNISTD"] = SCons.Util.CLVar("")
env["LEXCOM"] = "$LEX $LEXUNISTD $LEXFLAGS -t $SOURCES > $TARGET"
else:
- env["LEX"] = env.Detect(["flex", "lex"])
+ env["LEX"] = env.Detect(BINS)
env["LEXCOM"] = "$LEX $LEXFLAGS -t $SOURCES > $TARGET"
def exists(env):
if sys.platform == 'win32':
return get_lex_path(env)
else:
- return env.Detect(["flex", "lex"])
+ return env.Detect(BINS)
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py
index 07ba8da..2a5ffd8 100644
--- a/src/engine/SCons/Tool/yacc.py
+++ b/src/engine/SCons/Tool/yacc.py
@@ -45,6 +45,11 @@ from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
YaccAction = SCons.Action.Action("$YACCCOM", "$YACCCOMSTR")
+if sys.platform == 'win32':
+ BINS = ['bison', 'yacc', 'win_bison']
+else:
+ BINS = ["bison", "yacc"]
+
def _yaccEmitter(target, source, env, ysuf, hsuf):
yaccflags = env.subst("$YACCFLAGS", target=target, source=source)
flags = SCons.Util.CLVar(yaccflags)
@@ -109,12 +114,10 @@ def get_yacc_path(env, append_paths=False):
:param append_paths: if set, add the path to the tool to PATH
:return: path to yacc tool, if found
"""
- bins = ['bison', 'yacc', 'win_bison']
-
- for prog in bins:
+ for prog in BINS:
bin_path = SCons.Tool.find_program_path(
- env,
- prog,
+ env,
+ prog,
default_paths=CHOCO_DEFAULT_PATH + MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
if bin_path:
if append_paths:
@@ -143,33 +146,21 @@ def generate(env):
cxx_file.add_emitter('.yy', yyEmitter)
if sys.platform == 'win32':
- bison = SCons.Tool.find_program_path(env, 'bison', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
- if bison:
- bison_bin_dir = os.path.dirname(bison)
- env.AppendENVPath('PATH', bison_bin_dir)
- else:
- SCons.Warnings.Warning('yacc tool requested, but bison binary not found in ENV PATH')
-
- if sys.platform == 'win32':
- # ignore the return - we do not need the full path here
+ # ignore the return, all we need is for the path to be added
_ = get_yacc_path(env, append_paths=True)
- env["YACC"] = env.Detect(['bison', 'yacc', 'win_bison'])
- else:
- env["YACC"] = env.Detect(["bison", "yacc"])
-
+
+ env["YACC"] = env.Detect(BINS)
env['YACCFLAGS'] = SCons.Util.CLVar('')
env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES'
env['YACCHFILESUFFIX'] = '.h'
-
env['YACCHXXFILESUFFIX'] = '.hpp'
-
env['YACCVCGFILESUFFIX'] = '.vcg'
def exists(env):
if sys.platform == 'win32':
return get_yacc_path(env)
else:
- return env.Detect(['bison', 'yacc'])
+ return env.Detect(BINS)
# Local Variables:
# tab-width:4