summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-04-10 03:15:02 (GMT)
committerSteven Knight <knight@baldmt.com>2005-04-10 03:15:02 (GMT)
commit829d0fa89c2d93bb1461df2a8bb2fd2bb28a67da (patch)
treee6b270dac3f9ad01abb544204a5489ab1a46b091 /src
parent02f182567ed45a89f03ad02561b490eef8f0d1f1 (diff)
downloadSCons-829d0fa89c2d93bb1461df2a8bb2fd2bb28a67da.zip
SCons-829d0fa89c2d93bb1461df2a8bb2fd2bb28a67da.tar.gz
SCons-829d0fa89c2d93bb1461df2a8bb2fd2bb28a67da.tar.bz2
Allow configurability of yacc-generated header files suffixes.
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt4
-rw-r--r--src/engine/SCons/Tool/yacc.py10
-rw-r--r--src/engine/SCons/Tool/yacc.xml34
3 files changed, 44 insertions, 4 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 00973cf..cfd7097 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -262,6 +262,10 @@ RELEASE 0.97 - XXX
subdivide the dependency tree arbitrarily by putting an SConstruct
file in every directory and using content signatures.
+ - Add support for $YACCHFILESUFFIX and $YACCHXXFILESUFFIX variables
+ that accomodate parser generators that write header files to a
+ different suffix than the hard-coded .hpp when the -d option is used.
+
From Wayne Lee:
- Avoid "maximum recursion limit" errors when removing $(-$) pairs
diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py
index da88aa2..b8916ae 100644
--- a/src/engine/SCons/Tool/yacc.py
+++ b/src/engine/SCons/Tool/yacc.py
@@ -47,16 +47,16 @@ def _yaccEmitter(target, source, env, ysuf, hsuf):
# the input file is a .y or .yy, respectively.
if len(source) and '-d' in SCons.Util.CLVar(env.subst("$YACCFLAGS")):
base, ext = os.path.splitext(SCons.Util.to_String(source[0]))
- if ext == ysuf:
+ if ext in ysuf:
base, ext = os.path.splitext(SCons.Util.to_String(target[0]))
- target.append(base + hsuf)
+ target.append(base + env.subst(hsuf))
return (target, source)
def yEmitter(target, source, env):
- return _yaccEmitter(target, source, env, '.y', '.h')
+ return _yaccEmitter(target, source, env, ['.y', '.yacc'], '$YACCHFILESUFFIX')
def yyEmitter(target, source, env):
- return _yaccEmitter(target, source, env, '.yy', '.hpp')
+ return _yaccEmitter(target, source, env, ['.yy'], '$YACCHXXFILESUFFIX')
def generate(env):
"""Add Builders and construction variables for yacc to an Environment."""
@@ -72,6 +72,8 @@ def generate(env):
env['YACC'] = env.Detect('bison') or 'yacc'
env['YACCFLAGS'] = SCons.Util.CLVar('')
env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES'
+ env['YACCHFILESUFFIX'] = '.h'
+ env['YACCHXXFILESUFFIX'] = '.hpp'
def exists(env):
return env.Detect(['bison', 'yacc'])
diff --git a/src/engine/SCons/Tool/yacc.xml b/src/engine/SCons/Tool/yacc.xml
index 59735af..97bdf9b 100644
--- a/src/engine/SCons/Tool/yacc.xml
+++ b/src/engine/SCons/Tool/yacc.xml
@@ -40,3 +40,37 @@ or a .hpp file
(if the yacc source file ends in a .yy suffix)
</summary>
</cvar>
+
+<cvar name="YACCHFILESUFFIX">
+<summary>
+The suffix of the C
+header file generated by the parser generator
+when the
+<option>-d</option>
+option is used.
+Note that setting this variable does not cause
+the parser generator to generate a header
+file with the specified suffix,
+it exists to allow you to specify
+what suffix the parser generator will use of its own accord.
+The default value is
+<filename>.h</filename>.
+</summary>
+</cvar>
+
+<cvar name="YACCHXXFILESUFFIX">
+<summary>
+The suffix of the C++
+header file generated by the parser generator
+when the
+<option>-d</option>
+option is used.
+Note that setting this variable does not cause
+the parser generator to generate a header
+file with the specified suffix,
+it exists to allow you to specify
+what suffix the parser generator will use of its own accord.
+The default value is
+<filename>.hpp</filename>.
+</summary>
+</cvar>