From 359e8303a9423cb0ed8ee250042941866eaa64c8 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Mon, 22 Apr 2002 22:45:23 +0000 Subject: Small fix for yacc: only look for a .h file if they used the -d option. (Charles Crain) --- src/engine/SCons/Defaults.py | 30 ++++++++++++------------------ test/YACC.py | 4 ++++ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index ac04d9a..8d6bd34 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -80,9 +80,11 @@ class SharedCmdGenerator: def yaccEmitter(target, source, env, **kw): # Yacc can be configured to emit a .h file as well - # as a .c file. Append that as a target. - if len(source) and os.path.splitext(SCons.Util.to_String(source[0]))[1] in \ - [ '.y', '.yy']: + # as a .c file, if -d is specified on the command line. + if len(source) and \ + os.path.splitext(SCons.Util.to_String(source[0]))[1] in \ + [ '.y', '.yy'] and \ + '-d' in string.split(env.subst("$YACCFLAGS")): target.append(os.path.splitext(SCons.Util.to_String(target[0]))[0] + \ '.h') return (target, source) @@ -191,21 +193,13 @@ def win32LinkGenerator(env, target, source, **kw): args.extend(map(SCons.Util.to_String, source)) return win32TempFileMunge(env, args) -kw = { - 'name' : 'Program', - 'prefix' : '$PROGPREFIX', - 'suffix' : '$PROGSUFFIX', - 'src_suffix' : '$OBJSUFFIX', - 'src_builder' : Object, - 'scanner' : SCons.Scanner.Prog.ProgScan() -} - -if sys.platform == 'win32': - kw['generator'] = win32LinkGenerator -else: - kw['action'] = '$LINKCOM' - -Program = apply(SCons.Builder.Builder, (), kw) +Program = SCons.Builder.Builder(name='Program', + action='$LINKCOM', + prefix='$PROGPREFIX', + suffix='$PROGSUFFIX', + src_suffix='$OBJSUFFIX', + src_builder=Object, + scanner = SCons.Scanner.Prog.ProgScan()) class LibAffixGenerator: def __init__(self, static, shared): diff --git a/test/YACC.py b/test/YACC.py index 486200c..8fea904 100644 --- a/test/YACC.py +++ b/test/YACC.py @@ -140,12 +140,16 @@ newline: '\n'; test.run(arguments = 'foo' + _exe, stderr = None) + test.up_to_date(arguments = 'foo' + _exe) + test.fail_test(os.path.exists(test.workpath('wrapper.out'))) test.run(program = test.workpath('foo'), stdin = "a\n", stdout = "foo.y\n") test.run(arguments = 'bar' + _exe) + test.up_to_date(arguments = 'bar' + _exe) + test.fail_test(test.read('wrapper.out') != "wrapper.py\n") test.run(program = test.workpath('bar'), stdin = "b\n", stdout = "bar.y\n") -- cgit v0.12