Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNU Bison options --header and --defines are not recognised by SCons when they don't have an argument #4326

Closed
piotrsiupa opened this issue Mar 20, 2023 · 2 comments · Fixed by #4330
Labels
Tools Issues related to tools subsystem

Comments

@piotrsiupa
Copy link

SCons ignores options --header and --defines passed to Bison when the argument is not provided.
The argument is optional for those options and if it is not provided SCons should behave the same way as if it encountered the options -d (which is detected correctly).
(https://www.gnu.org/software/bison/manual/bison.html#Output-Files)

  • Link to SCons Users thread discussing your issue. - https://discord.com/channels/571796279483564041/571796280146133047/1087434623476301836
  • Version of SCons - v4.5.1.49578b34582d9e92dac7d713a8e58599ae35aa63
  • Version of Python - 3.10.6
  • Which python distribution if applicable (python.org, cygwin, anaconda, macports, brew,etc) - the one from Ubuntu repository
  • How you installed SCons - through pip
  • What Platform are you on? (Linux/Windows and which version) - Linux Mint
  • How to reproduce your issue? Please include a small self contained reproducer. Likely a SConstruct should do for most issues. - it's below
  • How you invoke scons (The command line you're using "scons --flags some_arguments") - scons
targets = CFile('foo.y', YACCFLAGS='-d')
print('Flag `-d` (correct target list):', targets)

targets = CFile('bar.y', YACCFLAGS='--defines')
print('Flag `--defines` (incorrect target list):', targets)

targets = CFile('baz.y', YACCFLAGS='--header')
print('Flag `--header` (incorrect target list):', targets)
@mwichmann
Copy link
Collaborator

The code currently only recognizes the option if it includes an equals sign:

    fileGenOptions = ["--defines=", "--header=", "--graph="]

So we'd have to rework this a bit. Still doesn't look complicated.

@mwichmann
Copy link
Collaborator

Note to self (or whoever takes on implementing): the -g option defaults to a .gv file suffix. This suffix does not have a construction variable analogous to $YACCHFILESUFFIX - not sure if we need to add one, or can just hard-code it.

@mwichmann mwichmann added the Tools Issues related to tools subsystem label Mar 20, 2023
mwichmann added a commit to mwichmann/scons that referenced this issue Mar 23, 2023
The yacc tool now recognizes the bison syntax of using --header, --defines
and --graph options in YACCFLAGS without supplying an option argument.
Note that byacc doesn't allow leaving off the option argument, and would
error out in such cases.

Fixes SCons#4326

The yacc tool now recognizes -H as a partial synonym for --header.
It only works in the no-option-argument form - giving an option argument
will likely break things.

Fixes SCons#4327

Tests are expanded to cover these.

The graph file name (-g) is now generated relative to the requested
target file name, not to the source name, to match actual current
behavior. This is rare case - only kicks in if target explicitly requested
with a different base name than source - in this case SCons would emit a
different name than bison produces.  Unlikely to affect any real usage -
you would have to set up the condition described, and additionally use
the graph file as a source for some other build target.

The default file suffix for graph files is set to .gv, which is current
for Bison as of 1.38.  The previous suffix for Bison, dating back to 2.4,
was .dot, which is still the suffix byacc uses.  Docs updated to better
describe when you need to set this. The former default, .vcg, has not
been used since 2006.

Documentation updated for the two header suffix construction variables
to better describe (I hope) what these mean and when to set them. Other
doc updates as well.

Signed-off-by: Mats Wichmann <[email protected]>
@mwichmann mwichmann mentioned this issue Mar 23, 2023
3 tasks
mwichmann added a commit to mwichmann/scons that referenced this issue May 6, 2023
The yacc tool now recognizes the bison syntax of using --header, --defines
and --graph options in YACCFLAGS without supplying an option argument.
Note that byacc doesn't allow leaving off the option argument, and would
error out in such cases.

Fixes SCons#4326

The yacc tool now recognizes -H as a partial synonym for --header.
It only works in the no-option-argument form - giving an option argument
will likely break things.

Fixes SCons#4327

Tests are expanded to cover these.

The graph file name (-g) is now generated relative to the requested
target file name, not to the source name, to match actual current
behavior. This is rare case - only kicks in if target explicitly requested
with a different base name than source - in this case SCons would emit a
different name than bison produces.  Unlikely to affect any real usage -
you would have to set up the condition described, and additionally use
the graph file as a source for some other build target.

The default file suffix for graph files is set to .gv, which is current
for Bison as of 3.8.  The previous suffix for Bison, dating back to 2.4,
was .dot, which is still the suffix byacc uses.  Docs updated to better
describe when you need to set this. The former default, .vcg, has not
been used since 2006.

Documentation updated for the two header suffix construction variables
to better describe (I hope) what these mean and when to set them. Other
doc updates as well.

Signed-off-by: Mats Wichmann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools Issues related to tools subsystem
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants