From Steven Knight:
+ - Tighten up the scons -H help output.
+
+ - When the input yacc file ends in .yy and the -d flag is specified,
+ recognize that a .hpp file (not a .h file) will be created.
+
RELEASE 0.90 - Wed, 25 Jun 2003 14:24:52 -0500
FortranScan = SCons.Scanner.Fortran.FortranScan()
def yaccEmitter(target, source, env, **kw):
- # Yacc can be configured to emit a .h file as well
- # 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')
+ # If -d is specified on the command line, yacc will emit a .h
+ # or .hpp file as well as a .c or .cpp file, depending on whether
+ # the input file is a .y or .yy, respectively.
+ if len(source) and '-d' in string.split(env.subst("$YACCFLAGS")):
+ suff = os.path.splitext(SCons.Util.to_String(source[0]))[1]
+ h = None
+ if suff == '.y':
+ h = '.h'
+ elif suff == '.yy':
+ h = '.hpp'
+ if h:
+ base = os.path.splitext(SCons.Util.to_String(target[0]))[0]
+ target.append(base + h)
return (target, source)
def CFile():
bar = Environment(YACC = r'%s wrapper.py ' + yacc)
foo.Program(target = 'foo', source = 'foo.y')
bar.Program(target = 'bar', source = 'bar.y')
+foo.Program(target = 'hello', source = ['hello.cpp'])
+foo.CXXFile(target = 'file.cpp', source = ['file.yy'], YACCFLAGS='-d')
""" % python)
yacc = r"""
newline: '\n';
"""
+ test.write("file.yy", """\
+%token GRAPH_T NODE_T EDGE_T DIGRAPH_T EDGEOP_T SUBGRAPH_T
+
+%pure_parser
+
+%%
+graph: GRAPH_T
+ ;
+
+%%
+""")
+
+ test.write("hello.cpp", """\
+#include "file.hpp"
+
+int main()
+{
+}
+""")
+
test.write('foo.y', yacc % 'foo.y')
test.write('bar.y', yacc % 'bar.y')
test.fail_test(os.path.exists(test.workpath('foo.h')))
+ test.run(arguments = '.')
+
+ test.up_to_date(arguments = '.')
+
test.pass_test()