From 35ac5267d91db9379129fc33d49d6699350347e5 Mon Sep 17 00:00:00 2001 From: Daniel Moody Date: Mon, 9 Apr 2018 15:34:24 -0500 Subject: updated yacc tool to add default paths, updated to test to use the tool specifically and know when to skip on windows. --- src/engine/SCons/Tool/yacc.py | 9 +++++++++ test/YACC/YACC.py | 8 ++++---- test/YACC/live-check-output-cleaned.py | 2 +- test/YACC/live.py | 12 +++++++++--- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py index 648433b..be65104 100644 --- a/src/engine/SCons/Tool/yacc.py +++ b/src/engine/SCons/Tool/yacc.py @@ -34,6 +34,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path +import sys import SCons.Defaults import SCons.Tool @@ -113,6 +114,14 @@ def generate(env): cxx_file.add_action('.yy', YaccAction) cxx_file.add_emitter('.yy', yyEmitter) + if(sys.platform == 'win32'): + bison = SCons.Tool.find_program_path(env, 'bison', default_paths=['C:\\cygwin64\\bin', 'C:\\cygwin\\bin', 'C:\\msys', 'C:\\msys64' ]) + 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') + env['YACC'] = env.Detect('bison') or 'yacc' env['YACCFLAGS'] = SCons.Util.CLVar('') env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES' diff --git a/test/YACC/YACC.py b/test/YACC/YACC.py index 3fc1f7c..b27c2a7 100644 --- a/test/YACC/YACC.py +++ b/test/YACC/YACC.py @@ -53,10 +53,10 @@ env.CFile(target = 'ddd', source = 'ddd.ym') test.run(arguments = '.', stderr = None) -test.must_match('aaa.c', "aaa.y\nmyyacc.py\n") -test.must_match('bbb.c', "bbb.yacc\nmyyacc.py\n") -test.must_match('ccc.cc', "ccc.yacc\nmyyacc.py\n") -test.must_match('ddd.m', "ddd.yacc\nmyyacc.py\n") +test.must_match('aaa.c', "aaa.y" + os.linesep + "myyacc.py" + os.linesep) +test.must_match('bbb.c', "bbb.yacc" + os.linesep + "myyacc.py" + os.linesep) +test.must_match('ccc.cc', "ccc.yacc" + os.linesep + "myyacc.py" + os.linesep) +test.must_match('ddd.m', "ddd.yacc" + os.linesep + "myyacc.py" + os.linesep) diff --git a/test/YACC/live-check-output-cleaned.py b/test/YACC/live-check-output-cleaned.py index a6240c9..8329b94 100644 --- a/test/YACC/live-check-output-cleaned.py +++ b/test/YACC/live-check-output-cleaned.py @@ -40,7 +40,7 @@ if not yacc: test.skip_test('No yacc or bison found; skipping test.\n') test.write('SConstruct', """ -foo = Environment(YACCFLAGS='-v -d') +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 6dd08f7..35f6c37 100644 --- a/test/YACC/live.py +++ b/test/YACC/live.py @@ -29,6 +29,8 @@ Test YACC and YACCFLAGS with a live yacc compiler. """ import TestSCons +import sys +import os _exe = TestSCons._exe _python_ = TestSCons._python_ @@ -40,12 +42,16 @@ yacc = test.where_is('yacc') or test.where_is('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', """ -foo = Environment(YACCFLAGS='-d') +foo = Environment(YACCFLAGS='-d', tools = ['default', 'yacc']) yacc = foo.Dictionary('YACC') -bar = Environment(YACC = r'%(_python_)s wrapper.py ' + yacc) +bar = Environment(YACC = r'%(_python_)s wrapper.py ' + yacc, tools = ['default', 'yacc']) foo.Program(target = 'foo', source = 'foo.y') bar.Program(target = 'bar', source = 'bar.y') foo.Program(target = 'hello', source = ['hello.cpp']) @@ -152,7 +158,7 @@ test.run(arguments = 'bar' + _exe) test.up_to_date(arguments = 'bar' + _exe) -test.must_match(test.workpath('wrapper.out'), "wrapper.py\n") +test.must_match(test.workpath('wrapper.out'), "wrapper.py" + os.linesep) test.run(program = test.workpath('bar'), stdin = "b\n", stdout = "bar.y\n") -- cgit v0.12