summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Tool/yacc.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-23 16:55:05 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-23 16:55:05 +0200
commitd240a76169c685e488fe7352adec69d39c60ef9f (patch)
tree144aeb4702d258b0cfaf99cffb9f21e94b026459 /src/engine/SCons/Tool/yacc.py
parent6ca68f29862bc7cbe5428426eee600cb1f3c05c1 (diff)
parentc2d9eaeffe9d77d8d5087fb21a3256fde32047d4 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'src/engine/SCons/Tool/yacc.py')
-rw-r--r--src/engine/SCons/Tool/yacc.py56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py
index d397de1..6857574 100644
--- a/src/engine/SCons/Tool/yacc.py
+++ b/src/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 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__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