summaryrefslogtreecommitdiff
path: root/engine/SCons/Tool/yacc.py
diff options
context:
space:
mode:
Diffstat (limited to 'engine/SCons/Tool/yacc.py')
-rw-r--r--engine/SCons/Tool/yacc.py56
1 files changed, 27 insertions, 29 deletions
diff --git a/engine/SCons/Tool/yacc.py b/engine/SCons/Tool/yacc.py
index d328d20..6857574 100644
--- a/engine/SCons/Tool/yacc.py
+++ b/engine/SCons/Tool/yacc.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/yacc.py a56bbd8c09fb219ab8a9673330ffcd55279219d0 2019-03-26 23:16:31 bdeegan"
+__revision__ = "src/engine/SCons/Tool/yacc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
@@ -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)
@@ -100,25 +105,26 @@ 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.
- """
- # save existing path to reset if we don't want to append any paths
- envPath = env['ENV']['PATH']
- bins = ['bison', 'yacc', 'win_bison']
+ 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
- for prog in bins:
+ :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
+ """
+ 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 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."""
@@ -140,29 +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')
+ # ignore the return, all we need is for the path to be added
+ _ = get_yacc_path(env, append_paths=True)
- if sys.platform == 'win32':
- 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):
- return env.Detect(['bison', 'yacc'])
+ if sys.platform == 'win32':
+ return get_yacc_path(env)
+ else:
+ return env.Detect(BINS)
# Local Variables:
# tab-width:4