diff options
author | William Deegan <bill@baddogconsulting.com> | 2019-03-03 02:20:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-03 02:20:43 (GMT) |
commit | 3a3626cc08b3d27a90e65ccebb874e1082d9deca (patch) | |
tree | 779bce734128bf71e62e2ed75b1543b66b59aa62 | |
parent | ae0960e31030bf7c5e3a5bd2c1c543867fbc5f8b (diff) | |
parent | 08f5e913d3b70a07672873c4573e236c4ccc7ac1 (diff) | |
download | SCons-3a3626cc08b3d27a90e65ccebb874e1082d9deca.zip SCons-3a3626cc08b3d27a90e65ccebb874e1082d9deca.tar.gz SCons-3a3626cc08b3d27a90e65ccebb874e1082d9deca.tar.bz2 |
Merge pull request #3321 from bdbaddog/fix_win_location_yacc
Fix win location yacc
-rwxr-xr-x | src/CHANGES.txt | 3 | ||||
-rw-r--r-- | src/engine/SCons/Tool/yacc.py | 30 | ||||
-rw-r--r-- | test/YACC/live-check-output-cleaned.py | 3 | ||||
-rw-r--r-- | test/YACC/live.py | 7 |
4 files changed, 35 insertions, 8 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index d4576a1..0a80095 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -16,6 +16,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER leaving TypeError Nonetype exception in config.log - Fix Issue #3303 - Handle --config=force overwriting the Environment passed into Configure()'s Decider and not clearing it when the configure context is completed. + - Add default paths for yacc tool on windows to include cygwin, mingw, and chocolatey From Daniel Moody: - Change the default for AppendENVPath to delete_existing=0, so path @@ -23,7 +24,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fixed bug which threw error when running SCons on windows system with no MSVC installed. - Update link tool to convert target to node before accessing node member - Update mingw tool to remove MSVC like nologo CCFLAG - - Add default paths for lex tool on windows + - Add default paths for lex tool on windows to include cygwin, mingw, and chocolatey - Add lex construction variable LEXUNISTD for turning off unix headers on windows - Update lex tool to use win_flex on windows if available diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py index cd9b9a8..5db49d3 100644 --- a/src/engine/SCons/Tool/yacc.py +++ b/src/engine/SCons/Tool/yacc.py @@ -41,6 +41,7 @@ import SCons.Tool import SCons.Util from SCons.Platform.mingw import MINGW_DEFAULT_PATHS from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS +from SCons.Platform.win32 import CHOCO_DEFAULT_PATH YaccAction = SCons.Action.Action("$YACCCOM", "$YACCCOMSTR") @@ -97,6 +98,28 @@ def ymEmitter(target, source, env): def yyEmitter(target, source, env): return _yaccEmitter(target, source, env, ['.yy'], '$YACCHXXFILESUFFIX') +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'] + + for prog in bins: + bin_path = SCons.Tool.find_program_path( + 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: + 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') + def generate(env): """Add Builders and construction variables for yacc to an Environment.""" c_file, cxx_file = SCons.Tool.createCFileBuilders(env) @@ -124,7 +147,12 @@ def generate(env): else: SCons.Warnings.Warning('yacc tool requested, but bison binary not found in ENV PATH') - env['YACC'] = env.Detect('bison') or 'yacc' + 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['YACCFLAGS'] = SCons.Util.CLVar('') env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES' env['YACCHFILESUFFIX'] = '.h' diff --git a/test/YACC/live-check-output-cleaned.py b/test/YACC/live-check-output-cleaned.py index 8329b94..9adaaf0 100644 --- a/test/YACC/live-check-output-cleaned.py +++ b/test/YACC/live-check-output-cleaned.py @@ -34,12 +34,13 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() -yacc = test.where_is('yacc') or test.where_is('bison') +yacc = test.where_is('yacc') or test.where_is('bison') or test.where_is('win_bison') if not yacc: test.skip_test('No yacc or bison found; skipping test.\n') test.write('SConstruct', """ +DefaultEnvironment(tools=[]) foo = Environment(YACCFLAGS='-v -d', tools = ['default', 'yacc']) foo.CFile(source = 'foo.y') """ % locals()) diff --git a/test/YACC/live.py b/test/YACC/live.py index a79d3db..4567dba 100644 --- a/test/YACC/live.py +++ b/test/YACC/live.py @@ -37,18 +37,15 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -yacc = test.where_is('yacc') or test.where_is('bison') +yacc = test.where_is('yacc') or test.where_is('bison') or test.where_is('win_bison') if not yacc: test.skip_test('No yacc or bison found; skipping test.\n') -if sys.platform == 'win32': - if not test.where_is('gcc'): - test.skip_test('No gcc found on windows; skipping test.\n') - test.file_fixture('wrapper.py') test.write('SConstruct', """ +DefaultEnvironment(tools=[]) foo = Environment(YACCFLAGS='-d', tools = ['default', 'yacc']) yacc = foo.Dictionary('YACC') bar = Environment(YACC = r'%(_python_)s wrapper.py ' + yacc, tools = ['default', 'yacc']) |