From aa6fc2562fa47f6449f03b7b90218a375877e96d Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 1 Jul 2022 14:03:36 -0600 Subject: Add lex/yacc filegen consvars lex and yacc tools both got two new construction variables for specifying side-effect creation of additional files, this method avoids the user embedding the options in LEXFLAGS and YACCFLAGS - the latter lets the commands generate the files, but the paths would not be properly relocated by SCons, so if the build was initiated in a subdirectory, the generated files would go into the top directory instead. Fixes #4154 Signed-off-by: Mats Wichmann --- CHANGES.txt | 8 ++++- RELEASE.txt | 6 ++++ SCons/Tool/lex.py | 37 +++++++++++++++------ SCons/Tool/lex.xml | 31 ++++++++++++++++++ SCons/Tool/yacc.py | 25 +++++++++++--- SCons/Tool/yacc.xml | 32 ++++++++++++++++++ test/LEX/FLEXFLAGS.py | 61 +++++++++++++++++++++++++++++------ test/YACC/BISONFLAGS.py | 58 +++++++++++++++++++++++++++------ test/YACC/YACCFLAGS-fixture/myyacc.py | 2 +- test/fixture/mylex.py | 2 +- 10 files changed, 227 insertions(+), 35 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 438ff85..42d0cd3 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -209,7 +209,13 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER Tool module loading no longer special-cases Jython, which is a dead project as far as SCons (no timeline in sight for Python 3 support). - Improvements to lex and yacc tools: better documentation of - extra-file options, add test for extra-file behavior. + extra-file options, add test for extra-file behavior. Two new + construction variables are introduced for lex (LEXHEADERFILE and + LEXTABLEFILE) as the preferred way of specifying these extra-file + options. Two new construction variables are introduced for yacc + (YACCHEADERFILE and YACCGRAPHFILE) as the preferred way of + specifying these extra-file options. + From Zhichang Yu: - Added MSVC_USE_SCRIPT_ARGS variable to pass arguments to MSVC_USE_SCRIPT. diff --git a/RELEASE.txt b/RELEASE.txt index 6f9c4a8..31080cb 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -45,6 +45,12 @@ NEW FUNCTIONALITY option may be added in a future enhancement. - Fortran: a new construction variable FORTRANCOMMONFLAGS is added which is applied to all Fortran dialects, to enable global (all-dialect) settings. +- lex: two new construction variables are introduced (LEXHEADERFILE + and LEXTABLEFILE) as the preferred way of specifying extra files that + the tool can generate. +- yacc: two new construction variables are introduced (YACCHEADERFILE + and YACCGRAPHFILE) as the preferred way of specifying extra files that + the tool can generate (applies only when using GNU flex and GNU bison). DEPRECATED FUNCTIONALITY diff --git a/SCons/Tool/lex.py b/SCons/Tool/lex.py index 0cf7de7..55f7112 100644 --- a/SCons/Tool/lex.py +++ b/SCons/Tool/lex.py @@ -80,6 +80,18 @@ def lexEmitter(target, source, env) -> tuple: file_name = option[l:].strip() target.append(file_name) + lexheaderfile = env.subst("$LEXHEADERFILE", target=target, source=source) + if lexheaderfile: + target.append(lexheaderfile) + # rewrite user-supplied file string with a node, we need later + env.Replace(LEXHEADERFILE=env.File(lexheaderfile)) + + lextablesfile = env.subst("$LEXTABLESFILE", target=target, source=source) + if lextablesfile: + target.append(lextablesfile) + # rewrite user-supplied file string with a node, we need later + env.Replace(LEXTABLESFILE=env.File(lextablesfile)) + return target, source @@ -129,18 +141,25 @@ def generate(env) -> None: cxx_file.add_action(".ll", LexAction) cxx_file.add_emitter(".ll", lexEmitter) - env["LEXFLAGS"] = CLVar("") - if sys.platform == 'win32': - # ignore the return - we do not need the full path here + # ignore the return, all we need is for the path to be added _ = get_lex_path(env, append_paths=True) - env["LEX"] = env.Detect(BINS) - if not env.get("LEXUNISTD"): - env["LEXUNISTD"] = CLVar("") - env["LEXCOM"] = "$LEX $LEXUNISTD $LEXFLAGS -t $SOURCES > $TARGET" + + env.SetDefault( + LEX=env.Detect(BINS), + LEXFLAGS=CLVar(""), + LEXHEADERFILE="", + LEXTABLESFILE="", + ) + + if sys.platform == 'win32': + env.SetDefault(LEXUNISTD=CLVar("")) + env["LEXCOM"] = "$LEX $LEXUNISTD $LEXFLAGS $_LEXHEADER $_LEXTABLES -t $SOURCES > $TARGET" else: - env["LEX"] = env.Detect(BINS) - env["LEXCOM"] = "$LEX $LEXFLAGS -t $SOURCES > $TARGET" + env["LEXCOM"] = "$LEX $LEXFLAGS $_LEXHEADER $_LEXTABLES -t $SOURCES > $TARGET" + + env['_LEXHEADER'] = '${LEXHEADERFILE and "--header-file=" + str(LEXHEADERFILE)}' + env['_LEXTABLES'] = '${LEXTABLESFILE and "--tables-file=" + str(LEXTABLESFILE)}' def exists(env) -> Optional[str]: diff --git a/SCons/Tool/lex.xml b/SCons/Tool/lex.xml index 8622ced..897eb49 100644 --- a/SCons/Tool/lex.xml +++ b/SCons/Tool/lex.xml @@ -60,6 +60,8 @@ Sets construction variables for the &lex; lexical analyser. LEXCOMSTR LEXFLAGS +LEXHEADERFILE +LEXTABLESFILE @@ -107,6 +109,35 @@ Recognized for this purpose are GNU &flex; options ; the output file is named by the option argument. + +Note that files specified by and + may not be properly handled +by &SCons; in all situations. Consider using +&cv-link-LEXHEADERFILE; and &cv-link-LEXTABLESFILE; instead. + + + + + + + +If supplied, generate a C header file with the name taken from this variable. +Will be emitted as a +command-line option. Use this in preference to including + in &cv-link-LEXFLAGS; directly. + + + + + + + +If supplied, write the lex tables to a file with the name +taken from this variable. +Will be emitted as a +command-line option. Use this in preference to including + in &cv-link-LEXFLAGS; directly. + diff --git a/SCons/Tool/yacc.py b/SCons/Tool/yacc.py index a2fef93..4bc6415 100644 --- a/SCons/Tool/yacc.py +++ b/SCons/Tool/yacc.py @@ -98,6 +98,18 @@ def _yaccEmitter(target, source, env, ysuf, hsuf) -> tuple: fileName = option[l:].strip() target.append(fileName) + yaccheaderfile = env.subst("$YACCHEADERFILE", target=target, source=source) + if yaccheaderfile: + target.append(yaccheaderfile) + # rewrite user-supplied file string with a node, we need later + env.Replace(YACCHEADERFILE=env.File(yaccheaderfile)) + + yaccgraphfile = env.subst("$YACCGRAPHFILE", target=target, source=source) + if yaccgraphfile: + target.append(yaccgraphfile) + # rewrite user-supplied file string with a node, we need later + env.Replace(YACCGRAPHFILE=env.File(yaccgraphfile)) + return target, source @@ -163,14 +175,19 @@ def generate(env) -> None: # ignore the return, all we need is for the path to be added _ = get_yacc_path(env, append_paths=True) - if 'YACC' not in env: - env["YACC"] = env.Detect(BINS) + env.SetDefault( + YACC=env.Detect(BINS), + YACCFLAGS=CLVar(""), + YACCHEADERFILE="", + YACCGRAPHSFILE="", + ) - env['YACCFLAGS'] = CLVar('') - env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES' + env['YACCCOM'] = '$YACC $YACCFLAGS $_YACCHEADER $_YACCGRAPH -o $TARGET $SOURCES' env['YACCHFILESUFFIX'] = '.h' env['YACCHXXFILESUFFIX'] = '.hpp' env['YACCVCGFILESUFFIX'] = '.vcg' + env['_YACCHEADER'] = '${YACCHEADERFILE and "--header=" + str(YACCHEADERFILE)}' + env['_YACCGRAPH'] = '${YACCGRAPHFILE and "--graph=" + str(YACCGRAPHFILE)}' def exists(env) -> Optional[str]: diff --git a/SCons/Tool/yacc.xml b/SCons/Tool/yacc.xml index 2f06451..f22c673 100644 --- a/SCons/Tool/yacc.xml +++ b/SCons/Tool/yacc.xml @@ -62,6 +62,8 @@ Sets construction variables for the &yacc; parse generator. YACCCOMSTR YACCFLAGS +YACCHEADERFILE +YACCGRAPHFILE @@ -139,6 +141,36 @@ which is similar to but the output filename is named by the option argument. + + +Note that files specified by and + may not be properly handled +by &SCons; in all situations. Consider using +&cv-link-YACCHEADERFILE; and &cv-link-YACCGRAPHFILE; instead. + + + + + + + +If supplied, generate a header file with the name taken from this variable. +Will be emitted as a +command-line option. Use this in preference to including + in &cv-link-YACCFLAGS; directly. + + + + + + + +If supplied, write a graph of the automaton to a file with the name +taken from this variable. +Will be emitted as a +command-line option. Use this in preference to including + in &cv-link-YACCFLAGS; directly. + diff --git a/test/LEX/FLEXFLAGS.py b/test/LEX/FLEXFLAGS.py index 0844030..59e4343 100644 --- a/test/LEX/FLEXFLAGS.py +++ b/test/LEX/FLEXFLAGS.py @@ -25,9 +25,11 @@ """ Test that detection of file-writing options in LEXFLAGS works. +Also test that construction vars for the same purpose work. """ import sysconfig +from pathlib import Path import TestSCons from TestCmd import IS_WINDOWS @@ -37,16 +39,18 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() -test.subdir('sub') +test.subdir('sub1') +test.subdir('sub2') test.file_fixture('mylex.py') test.write('SConstruct', """\ DefaultEnvironment(tools=[]) -SConscript("sub/SConscript") +SConscript(dirs=['sub1', 'sub2']) """) -test.write(['sub', 'SConscript'], f"""\ +# this SConscript is for the options-in-flags version +test.write(['sub1', 'SConscript'], f"""\ import sys env = Environment( @@ -60,7 +64,25 @@ t = [str(target) for target in targs] if not all((len(t) == 3, "header.h" in t, "tables.t" in t)): sys.exit(1) """) -test.write(['sub', 'aaa.l'], "aaa.l\nLEXFLAGS\n") +test.write(['sub1', 'aaa.l'], "aaa.l\nLEXFLAGS\n") + +# this SConscript is for the construction var version +test.write(['sub2', 'SConscript'], f"""\ +import sys + +env = Environment( + LEX=r'{_python_} mylex.py', + LEXFLAGS='-x', + tools=['default', 'lex'], +) +env.CFile( + target='aaa', + source='aaa.l', + LEXHEADERFILE='header.h', + LEXTABLESFILE='tables.t', +) +""") +test.write(['sub2', 'aaa.l'], "aaa.l\nLEXFLAGS\n") test.run('.', stderr=None) @@ -69,19 +91,38 @@ if IS_WINDOWS and not sysconfig.get_platform() in ("mingw",): lexflags = ' --nounistd' + lexflags # Read in with mode='r' because mylex.py implicitly wrote to stdout # with mode='w'. -test.must_match(['sub', 'aaa.c'], "aaa.l\n%s\n" % lexflags, mode='r') +test.must_match(['sub1', 'aaa.c'], "aaa.l\n%s\n" % lexflags, mode='r') # NOTE: this behavior is "wrong" but we're keeping it for compat. -# the generated files should go into 'sub'. +# the generated files should go into 'sub1', not the topdir. test.must_match(['header.h'], 'lex header\n') test.must_match(['tables.t'], 'lex table\n') # To confirm the files from the file-output options were tracked, -# do a clean and make sure they got removed. As noted, they currently -# don't go into the tracked location, so using the the SConscript check instead. +# we should do a clean and make sure they got removed. +# As noted, they currently don't go into the tracked location, +# so using the check in the SConscript instead. #test.run(arguments='-c .') -#test.must_not_exist(test.workpath(['sub', 'header.h'])) -#test.must_not_exist(test.workpath(['sub', 'tables.t'])) +#test.must_not_exist(test.workpath(['sub1', 'header.h'])) +#test.must_not_exist(test.workpath(['sub1', 'tables.t'])) + +sub2 = Path('sub2') +headerfile = sub2 / 'header.h' +tablefile = sub2 / 'tables.t' +lexflags = f' -x --header-file={headerfile} --tables-file={tablefile} -t' +if IS_WINDOWS and not sysconfig.get_platform() in ("mingw",): + lexflags = ' --nounistd' + lexflags +# Read in with mode='r' because mylex.py implicitly wrote to stdout +# with mode='w'. +test.must_match(['sub2', 'aaa.c'], "aaa.l\n%s\n" % lexflags, mode='r') +test.must_match(['sub2', 'header.h'], 'lex header\n') +test.must_match(['sub2', 'tables.t'], 'lex table\n') + +# To confirm the files from the file-output options were tracked, +# do a clean and make sure they got removed. +test.run(arguments='-c .', stderr=None) +test.must_not_exist(test.workpath('sub2', 'header.h')) +test.must_not_exist(test.workpath('sub2', 'tables.t')) test.pass_test() diff --git a/test/YACC/BISONFLAGS.py b/test/YACC/BISONFLAGS.py index f789339..05a99b3 100644 --- a/test/YACC/BISONFLAGS.py +++ b/test/YACC/BISONFLAGS.py @@ -25,8 +25,11 @@ """ Test that detection of file-writing options in YACCFLAGS works. +Also test that the construction vars for the same purpose work. """ +from pathlib import Path + import TestSCons from TestCmd import IS_WINDOWS @@ -42,16 +45,18 @@ else: test = TestSCons.TestSCons() -test.subdir('sub') +test.subdir('sub1') +test.subdir('sub2') test.dir_fixture('YACCFLAGS-fixture') test.write('SConstruct', """\ DefaultEnvironment(tools=[]) -SConscript("sub/SConscript") +SConscript(dirs=['sub1', 'sub2']) """) -test.write(['sub', 'SConscript'], """\ +# this SConscript is for the options-in-flags version +test.write(['sub1', 'SConscript'], """\ import sys env = Environment( @@ -65,21 +70,56 @@ t = [str(target) for target in targs] if not all((len(t) == 3, "header.h" in t, "graph.g" in t)): sys.exit(1) """ % locals()) -test.write(['sub', 'aaa.y'], "aaa.y\nYACCFLAGS\n") +test.write(['sub1', 'aaa.y'], "aaa.y\nYACCFLAGS\n") + +# this SConscript is for the construction var version +test.write(['sub2', 'SConscript'], """\ +import sys + +env = Environment( + YACC=r'%(_python_)s myyacc.py', + YACCFLAGS='-x', + tools=['yacc', '%(linker)s', '%(compiler)s'], +) +env.CFile( + target='aaa', + source='aaa.y', + YACCHEADERFILE='header.h', + YACCGRAPHFILE='graph.g', +) +""" % locals()) +test.write(['sub2', 'aaa.y'], "aaa.y\nYACCFLAGS\n") + test.run('.', stderr=None) -test.must_match(['sub', 'aaa.c'], "aaa.y\n -x --header=header.h --graph=graph.g\n") +test.must_match(['sub1', 'aaa.c'], "aaa.y\n -x --header=header.h --graph=graph.g\n") # NOTE: this behavior is "wrong" but we're keeping it for compat: -# the generated files should go into 'sub'. +# the generated files should go into 'sub1', not the topdir. test.must_match(['header.h'], 'yacc header\n') test.must_match(['graph.g'], 'yacc graph\n') # To confirm the files from the file-output options were tracked, +# we should do a clean and make sure they got removed. +# As noted, they currently don't go into the tracked location, +# so using the check in the SConscript instead. +#test.run(arguments='-c .') +#test.must_not_exist(test.workpath(['sub1', 'header.h'])) +#test.must_not_exist(test.workpath(['sub1', 'graph.g'])) + +sub2 = Path('sub2') +headerfile = sub2 / 'header.h' +graphfile = sub2 / 'graph.g' +yaccflags = f"aaa.y\n -x --header={headerfile} --graph={graphfile}\n" +test.must_match(['sub2', 'aaa.c'], yaccflags) +test.must_match(['sub2', 'header.h'], 'yacc header\n') +test.must_match(['sub2', 'graph.g'], 'yacc graph\n') + +# To confirm the files from the file-output options were tracked, # do a clean and make sure they got removed. As noted, they currently # don't go into the tracked location, so using the the SConscript check instead. -#test.run(arguments='-c .') -#test.must_not_exist(test.workpath(['sub', 'header.h'])) -#test.must_not_exist(test.workpath(['sub', 'graph.g'])) +test.run(arguments='-c .') +test.must_not_exist(test.workpath('sub2', 'header.h')) +test.must_not_exist(test.workpath('sub2', 'graph.g')) test.pass_test() diff --git a/test/YACC/YACCFLAGS-fixture/myyacc.py b/test/YACC/YACCFLAGS-fixture/myyacc.py index afab95a..3bc1375 100644 --- a/test/YACC/YACCFLAGS-fixture/myyacc.py +++ b/test/YACC/YACCFLAGS-fixture/myyacc.py @@ -6,7 +6,7 @@ from pathlib import Path def make_side_effect(path, text): p = Path(path) if str(p.parent) != '.': - p.mkdir(parents=True, exist_ok=True) + p.parent.mkdir(parents=True, exist_ok=True) with p.open(mode="wb") as f: f.write(text) diff --git a/test/fixture/mylex.py b/test/fixture/mylex.py index 59d6dbd..b5e94b1 100644 --- a/test/fixture/mylex.py +++ b/test/fixture/mylex.py @@ -15,7 +15,7 @@ from pathlib import Path def make_side_effect(path, text): p = Path(path) if str(p.parent) != '.': - p.mkdir(parents=True, exist_ok=True) + p.parent.mkdir(parents=True, exist_ok=True) with p.open(mode="wb") as f: f.write(text) -- cgit v0.12 From baf96f12d0e4fa015fefc31c79ab71d33f898fcf Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 20 Jul 2022 08:47:00 -0700 Subject: Move LEXHEADERFILE, LEXTABLEFILE, YACCHEADERFILE, YACCGRAPHFILE -> separated by underscores for readability --- CHANGES.txt | 11 ++++++----- RELEASE.txt | 8 ++++---- SCons/Tool/lex.py | 20 ++++++++++---------- SCons/Tool/lex.xml | 10 +++++----- SCons/Tool/yacc.py | 18 +++++++++--------- SCons/Tool/yacc.xml | 10 +++++----- test/LEX/FLEXFLAGS.py | 4 ++-- test/YACC/BISONFLAGS.py | 4 ++-- 8 files changed, 43 insertions(+), 42 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 42d0cd3..0e54bad 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -209,11 +209,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER Tool module loading no longer special-cases Jython, which is a dead project as far as SCons (no timeline in sight for Python 3 support). - Improvements to lex and yacc tools: better documentation of - extra-file options, add test for extra-file behavior. Two new - construction variables are introduced for lex (LEXHEADERFILE and - LEXTABLEFILE) as the preferred way of specifying these extra-file - options. Two new construction variables are introduced for yacc - (YACCHEADERFILE and YACCGRAPHFILE) as the preferred way of + extra-file options, add test for extra-file behavior. + - Two new construction variables are introduced for lex (LEX_HEADER_FILE + and LEX_TABLE_FILE) as the preferred way of specifying these extra-file + options. + - Two new construction variables are introduced for yacc + (YACC_HEADER_FILE and YACC_GRAPH_FILE) as the preferred way of specifying these extra-file options. diff --git a/RELEASE.txt b/RELEASE.txt index 31080cb..7e6ea9a 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -45,11 +45,11 @@ NEW FUNCTIONALITY option may be added in a future enhancement. - Fortran: a new construction variable FORTRANCOMMONFLAGS is added which is applied to all Fortran dialects, to enable global (all-dialect) settings. -- lex: two new construction variables are introduced (LEXHEADERFILE - and LEXTABLEFILE) as the preferred way of specifying extra files that +- lex: two new construction variables are introduced (LEX_HEADER_ILE + and LEX_TABLE_FILE) as the preferred way of specifying extra files that the tool can generate. -- yacc: two new construction variables are introduced (YACCHEADERFILE - and YACCGRAPHFILE) as the preferred way of specifying extra files that +- yacc: two new construction variables are introduced (YACC_HEADER_FILE + and YACC_GRAPH_FILE) as the preferred way of specifying extra files that the tool can generate (applies only when using GNU flex and GNU bison). diff --git a/SCons/Tool/lex.py b/SCons/Tool/lex.py index 55f7112..60ae4bd 100644 --- a/SCons/Tool/lex.py +++ b/SCons/Tool/lex.py @@ -80,17 +80,17 @@ def lexEmitter(target, source, env) -> tuple: file_name = option[l:].strip() target.append(file_name) - lexheaderfile = env.subst("$LEXHEADERFILE", target=target, source=source) + lexheaderfile = env.subst("$LEX_HEADER_FILE", target=target, source=source) if lexheaderfile: target.append(lexheaderfile) # rewrite user-supplied file string with a node, we need later - env.Replace(LEXHEADERFILE=env.File(lexheaderfile)) + env.Replace(LEX_HEADER_FILE=env.File(lexheaderfile)) - lextablesfile = env.subst("$LEXTABLESFILE", target=target, source=source) + lextablesfile = env.subst("$LEX_TABLE_FILE", target=target, source=source) if lextablesfile: target.append(lextablesfile) # rewrite user-supplied file string with a node, we need later - env.Replace(LEXTABLESFILE=env.File(lextablesfile)) + env.Replace(LEX_TABLE_FILE=env.File(lextablesfile)) return target, source @@ -148,18 +148,18 @@ def generate(env) -> None: env.SetDefault( LEX=env.Detect(BINS), LEXFLAGS=CLVar(""), - LEXHEADERFILE="", - LEXTABLESFILE="", + LEX_HEADER_FILE="", + LEX_TABLE_FILE="", ) if sys.platform == 'win32': env.SetDefault(LEXUNISTD=CLVar("")) - env["LEXCOM"] = "$LEX $LEXUNISTD $LEXFLAGS $_LEXHEADER $_LEXTABLES -t $SOURCES > $TARGET" + env["LEXCOM"] = "$LEX $LEXUNISTD $LEXFLAGS $_LEX_HEADER $_LEX_TABLES -t $SOURCES > $TARGET" else: - env["LEXCOM"] = "$LEX $LEXFLAGS $_LEXHEADER $_LEXTABLES -t $SOURCES > $TARGET" + env["LEXCOM"] = "$LEX $LEXFLAGS $_LEX_HEADER $_LEX_TABLES -t $SOURCES > $TARGET" - env['_LEXHEADER'] = '${LEXHEADERFILE and "--header-file=" + str(LEXHEADERFILE)}' - env['_LEXTABLES'] = '${LEXTABLESFILE and "--tables-file=" + str(LEXTABLESFILE)}' + env['_LEX_HEADER'] = '${LEX_HEADER_FILE and "--header-file=" + str(LEX_HEADER_FILE)}' + env['_LEX_TABLES'] = '${LEX_TABLE_FILE and "--tables-file=" + str(LEX_TABLE_FILE)}' def exists(env) -> Optional[str]: diff --git a/SCons/Tool/lex.xml b/SCons/Tool/lex.xml index 897eb49..e68a2bf 100644 --- a/SCons/Tool/lex.xml +++ b/SCons/Tool/lex.xml @@ -60,8 +60,8 @@ Sets construction variables for the &lex; lexical analyser. LEXCOMSTR LEXFLAGS -LEXHEADERFILE -LEXTABLESFILE +LEX_HEADER_FILE +LEX_TABLE_FILE @@ -113,12 +113,12 @@ the output file is named by the option argument. Note that files specified by and may not be properly handled by &SCons; in all situations. Consider using -&cv-link-LEXHEADERFILE; and &cv-link-LEXTABLESFILE; instead. +&cv-link-LEX_HEADER_FILE; and &cv-link-LEX_TABLE_FILE; instead. - + If supplied, generate a C header file with the name taken from this variable. @@ -129,7 +129,7 @@ command-line option. Use this in preference to including - + If supplied, write the lex tables to a file with the name diff --git a/SCons/Tool/yacc.py b/SCons/Tool/yacc.py index 4bc6415..42ef1db 100644 --- a/SCons/Tool/yacc.py +++ b/SCons/Tool/yacc.py @@ -98,17 +98,17 @@ def _yaccEmitter(target, source, env, ysuf, hsuf) -> tuple: fileName = option[l:].strip() target.append(fileName) - yaccheaderfile = env.subst("$YACCHEADERFILE", target=target, source=source) + yaccheaderfile = env.subst("$YACC_HEADER_FILE", target=target, source=source) if yaccheaderfile: target.append(yaccheaderfile) # rewrite user-supplied file string with a node, we need later - env.Replace(YACCHEADERFILE=env.File(yaccheaderfile)) + env.Replace(YACC_HEADER_FILE=env.File(yaccheaderfile)) - yaccgraphfile = env.subst("$YACCGRAPHFILE", target=target, source=source) + yaccgraphfile = env.subst("$YACC_GRAPH_FILE", target=target, source=source) if yaccgraphfile: target.append(yaccgraphfile) # rewrite user-supplied file string with a node, we need later - env.Replace(YACCGRAPHFILE=env.File(yaccgraphfile)) + env.Replace(YACC_GRAPH_FILE=env.File(yaccgraphfile)) return target, source @@ -178,16 +178,16 @@ def generate(env) -> None: env.SetDefault( YACC=env.Detect(BINS), YACCFLAGS=CLVar(""), - YACCHEADERFILE="", - YACCGRAPHSFILE="", + YACC_HEADER_FILE="", + YACC_GRAPH_FILE="", ) - env['YACCCOM'] = '$YACC $YACCFLAGS $_YACCHEADER $_YACCGRAPH -o $TARGET $SOURCES' + env['YACCCOM'] = '$YACC $YACCFLAGS $_YACC_HEADER $_YACC_GRAPH -o $TARGET $SOURCES' env['YACCHFILESUFFIX'] = '.h' env['YACCHXXFILESUFFIX'] = '.hpp' env['YACCVCGFILESUFFIX'] = '.vcg' - env['_YACCHEADER'] = '${YACCHEADERFILE and "--header=" + str(YACCHEADERFILE)}' - env['_YACCGRAPH'] = '${YACCGRAPHFILE and "--graph=" + str(YACCGRAPHFILE)}' + env['_YACC_HEADER'] = '${YACC_HEADER_FILE and "--header=" + str(YACC_HEADER_FILE)}' + env['_YACC_GRAPH'] = '${YACC_GRAPH_FILE and "--graph=" + str(YACC_GRAPH_FILE)}' def exists(env) -> Optional[str]: diff --git a/SCons/Tool/yacc.xml b/SCons/Tool/yacc.xml index f22c673..9ccc4e6 100644 --- a/SCons/Tool/yacc.xml +++ b/SCons/Tool/yacc.xml @@ -62,8 +62,8 @@ Sets construction variables for the &yacc; parse generator. YACCCOMSTR YACCFLAGS -YACCHEADERFILE -YACCGRAPHFILE +YACC_HEADER_FILE +YACC_GRAPH_FILE @@ -146,12 +146,12 @@ but the output filename is named by the option argument. Note that files specified by and may not be properly handled by &SCons; in all situations. Consider using -&cv-link-YACCHEADERFILE; and &cv-link-YACCGRAPHFILE; instead. +&cv-link-YACC_HEADER_FILE; and &cv-link-YACC_GRAPH_FILE; instead. - + If supplied, generate a header file with the name taken from this variable. @@ -162,7 +162,7 @@ command-line option. Use this in preference to including - + If supplied, write a graph of the automaton to a file with the name diff --git a/test/LEX/FLEXFLAGS.py b/test/LEX/FLEXFLAGS.py index 59e4343..1db9f42 100644 --- a/test/LEX/FLEXFLAGS.py +++ b/test/LEX/FLEXFLAGS.py @@ -78,8 +78,8 @@ env = Environment( env.CFile( target='aaa', source='aaa.l', - LEXHEADERFILE='header.h', - LEXTABLESFILE='tables.t', + LEX_HEADER_FILE='header.h', + LEX_TABLE_FILE='tables.t', ) """) test.write(['sub2', 'aaa.l'], "aaa.l\nLEXFLAGS\n") diff --git a/test/YACC/BISONFLAGS.py b/test/YACC/BISONFLAGS.py index 05a99b3..cae673d 100644 --- a/test/YACC/BISONFLAGS.py +++ b/test/YACC/BISONFLAGS.py @@ -84,8 +84,8 @@ env = Environment( env.CFile( target='aaa', source='aaa.y', - YACCHEADERFILE='header.h', - YACCGRAPHFILE='graph.g', + YACC_HEADER_FILE='header.h', + YACC_GRAPH_FILE='graph.g', ) """ % locals()) test.write(['sub2', 'aaa.y'], "aaa.y\nYACCFLAGS\n") -- cgit v0.12 From d9879189cce1796c3459cea017ba55d685d65d09 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 20 Jul 2022 08:53:25 -0700 Subject: LEX_TABLE_FILE -> LEX_TABLES_FILE --- CHANGES.txt | 2 +- RELEASE.txt | 2 +- SCons/Tool/lex.py | 8 ++++---- SCons/Tool/lex.xml | 6 +++--- test/LEX/FLEXFLAGS.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0e54bad..5900fca 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -211,7 +211,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Improvements to lex and yacc tools: better documentation of extra-file options, add test for extra-file behavior. - Two new construction variables are introduced for lex (LEX_HEADER_FILE - and LEX_TABLE_FILE) as the preferred way of specifying these extra-file + and LEX_TABLES_FILE) as the preferred way of specifying these extra-file options. - Two new construction variables are introduced for yacc (YACC_HEADER_FILE and YACC_GRAPH_FILE) as the preferred way of diff --git a/RELEASE.txt b/RELEASE.txt index 7e6ea9a..b7e5ceb 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -46,7 +46,7 @@ NEW FUNCTIONALITY - Fortran: a new construction variable FORTRANCOMMONFLAGS is added which is applied to all Fortran dialects, to enable global (all-dialect) settings. - lex: two new construction variables are introduced (LEX_HEADER_ILE - and LEX_TABLE_FILE) as the preferred way of specifying extra files that + and LEX_TABLES_FILE) as the preferred way of specifying extra files that the tool can generate. - yacc: two new construction variables are introduced (YACC_HEADER_FILE and YACC_GRAPH_FILE) as the preferred way of specifying extra files that diff --git a/SCons/Tool/lex.py b/SCons/Tool/lex.py index 60ae4bd..3f1a3ad 100644 --- a/SCons/Tool/lex.py +++ b/SCons/Tool/lex.py @@ -86,11 +86,11 @@ def lexEmitter(target, source, env) -> tuple: # rewrite user-supplied file string with a node, we need later env.Replace(LEX_HEADER_FILE=env.File(lexheaderfile)) - lextablesfile = env.subst("$LEX_TABLE_FILE", target=target, source=source) + lextablesfile = env.subst("$LEX_TABLES_FILE", target=target, source=source) if lextablesfile: target.append(lextablesfile) # rewrite user-supplied file string with a node, we need later - env.Replace(LEX_TABLE_FILE=env.File(lextablesfile)) + env.Replace(LEX_TABLES_FILE=env.File(lextablesfile)) return target, source @@ -149,7 +149,7 @@ def generate(env) -> None: LEX=env.Detect(BINS), LEXFLAGS=CLVar(""), LEX_HEADER_FILE="", - LEX_TABLE_FILE="", + LEX_TABLES_FILE="", ) if sys.platform == 'win32': @@ -159,7 +159,7 @@ def generate(env) -> None: env["LEXCOM"] = "$LEX $LEXFLAGS $_LEX_HEADER $_LEX_TABLES -t $SOURCES > $TARGET" env['_LEX_HEADER'] = '${LEX_HEADER_FILE and "--header-file=" + str(LEX_HEADER_FILE)}' - env['_LEX_TABLES'] = '${LEX_TABLE_FILE and "--tables-file=" + str(LEX_TABLE_FILE)}' + env['_LEX_TABLES'] = '${LEX_TABLES_FILE and "--tables-file=" + str(LEX_TABLES_FILE)}' def exists(env) -> Optional[str]: diff --git a/SCons/Tool/lex.xml b/SCons/Tool/lex.xml index e68a2bf..391e429 100644 --- a/SCons/Tool/lex.xml +++ b/SCons/Tool/lex.xml @@ -61,7 +61,7 @@ Sets construction variables for the &lex; lexical analyser. LEXCOMSTR LEXFLAGS LEX_HEADER_FILE -LEX_TABLE_FILE +LEX_TABLES_FILE @@ -113,7 +113,7 @@ the output file is named by the option argument. Note that files specified by and may not be properly handled by &SCons; in all situations. Consider using -&cv-link-LEX_HEADER_FILE; and &cv-link-LEX_TABLE_FILE; instead. +&cv-link-LEX_HEADER_FILE; and &cv-link-LEX_TABLES_FILE; instead. @@ -129,7 +129,7 @@ command-line option. Use this in preference to including - + If supplied, write the lex tables to a file with the name diff --git a/test/LEX/FLEXFLAGS.py b/test/LEX/FLEXFLAGS.py index 1db9f42..b803ec7 100644 --- a/test/LEX/FLEXFLAGS.py +++ b/test/LEX/FLEXFLAGS.py @@ -79,7 +79,7 @@ env.CFile( target='aaa', source='aaa.l', LEX_HEADER_FILE='header.h', - LEX_TABLE_FILE='tables.t', + LEX_TABLES_FILE='tables.t', ) """) test.write(['sub2', 'aaa.l'], "aaa.l\nLEXFLAGS\n") -- cgit v0.12