summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDaniel <dmoody256@gmail.com>2019-02-16 17:10:29 (GMT)
committerDaniel <dmoody256@gmail.com>2019-02-16 17:10:29 (GMT)
commit9eb21f94e0490e8e7811f1033ea146acac0b7c34 (patch)
tree6079fea4ffb2bc0040d13c152107dc04ff1a06b1 /src/engine
parentf296600dd858fa07ef144fbcbf4ee36bc308abf3 (diff)
downloadSCons-9eb21f94e0490e8e7811f1033ea146acac0b7c34.zip
SCons-9eb21f94e0490e8e7811f1033ea146acac0b7c34.tar.gz
SCons-9eb21f94e0490e8e7811f1033ea146acac0b7c34.tar.bz2
update lex tool to find paths on windows
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Tool/lex.py44
1 files changed, 41 insertions, 3 deletions
diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py
index 280c768..732c0da 100644
--- a/src/engine/SCons/Tool/lex.py
+++ b/src/engine/SCons/Tool/lex.py
@@ -34,10 +34,13 @@ selection method.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os.path
+import sys
import SCons.Action
import SCons.Tool
import SCons.Util
+from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
+from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
LexAction = SCons.Action.Action("$LEXCOM", "$LEXCOMSTR")
@@ -64,10 +67,42 @@ def lexEmitter(target, source, env):
target.append(fileName)
return (target, source)
+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.
+ """
+ # save existing path to reset if we don't want to append any paths
+ envPath = env['ENV']['PATH']
+
+ lex = SCons.Tool.find_program_path(env, 'lex', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
+ if lex:
+ if not append_paths:
+ env['ENV']['PATH'] = envPath
+ else:
+ lex_bin_dir = os.path.dirname(lex)
+ env.AppendENVPath('PATH', lex_bin_dir)
+ return lex
+
+ flex = SCons.Tool.find_program_path(env, 'flex', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
+ if flex:
+ if not append_paths:
+ env['ENV']['PATH'] = envPath
+ else:
+ flex_bin_dir = os.path.dirname(flex)
+ env.AppendENVPath('PATH', flex_bin_dir)
+ return flex
+ else:
+ SCons.Warnings.Warning('lex tool requested, but lex or flex binary not found in ENV PATH')
+
+
def generate(env):
"""Add Builders and construction variables for lex to an Environment."""
c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
+ if sys.platform == 'win32':
+ get_lex_path(env, append_paths=True)
+
# C
c_file.add_action(".l", LexAction)
c_file.add_emitter(".l", lexEmitter)
@@ -82,13 +117,16 @@ def generate(env):
# C++
cxx_file.add_action(".ll", LexAction)
cxx_file.add_emitter(".ll", lexEmitter)
-
- env["LEX"] = env.Detect("flex") or "lex"
+
+ env["LEX"] = env.Detect("flex") or "lex"
env["LEXFLAGS"] = SCons.Util.CLVar("")
env["LEXCOM"] = "$LEX $LEXFLAGS -t $SOURCES > $TARGET"
def exists(env):
- return env.Detect(["flex", "lex"])
+ if sys.platform == 'win32':
+ return get_lex_path(env)
+ else:
+ return env.Detect(["flex", "lex"])
# Local Variables:
# tab-width:4