`-depend` shows phantom dependency
- Dominant language
- Java
- Stars
- 19k
- Forks
- 3.5k
- PR merge metrics
- No merged PRs in 30d
Description
- [x] I am not submitting a question on how to use ANTLR; instead, go to [antlr4-discussion google group](https://groups.google.com/forum/#!forum/antlr-discussion) or ask at [stackoverflow](http://stackoverflow.com/questions/tagged/antlr4)
- [x] I have done a search of the existing issues to make sure I'm not sending in a duplicate
I have 2 ANTLR 4 grammar files. One is the lexer, the other is parser.
Running `antrl4 -o gen -Dlanguage=Cpp -depend ADLexer.g4 ADParser.g4` says
```
gen/ADLexer.h : ADLexer.g4
gen/ADLexer.cpp : ADLexer.g4
gen/ADLexer.tokens : ADLexer.g4
gen/ADLexerListener.h : ADLexer.g4
gen/ADLexerListener.cpp : ADLexer.g4
gen/ADLexerBaseListener.h : ADLexer.g4
gen/ADLexerBaseListener.cpp : ADLexer.g4
ADParser.g4: ADLexer.tokens
gen/ADParser.h : ADParser.g4
gen/ADParser.cpp : ADParser.g4
gen/ADParser.tokens : ADParser.g4
gen/ADParserListener.h : ADParser.g4
gen/ADParserListener.cpp : ADParser.g4
gen/ADParserBaseListener.h : ADParser.g4
gen/ADParserBaseListener.cpp : ADParser.g4
```
But, `antlr4` does not emit the `gen/ADLexer{Listener,BaseListener}.{h,cpp}`

This issue blocks me to write CMake rules to minimize rebuilding. If correct dependency is available, we can avoid using file globs to collect generated files, and minimize rebuilds (and get the tools for resolving https://github.com/antlr/antlr4/issues/1872 )
Contributor guide
Research direction
Reproduce `antlr4 -o gen -Dlanguage=Cpp -depend ADLexer.g4 ADParser.g4` with the two grammar files and compare its dependency output with the files actually generated under `gen/`. Start from the `-depend` entry point and the CMake rebuild use case; done means the dependency list accurately reflects generated listener and base-listener files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, java
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100