google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library

Home Page:https://flatbuffers.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

allow no filename suffix [all languages, flatc 2.0.0]

Holo-Viktor opened this issue · comments

Hello flatbuffers people.
It would be nice to allow no filename suffix at all. I generate files into a "generated" directory and don't need suffixes per file.
I guess an easy way to support this could be to allow an empty string for the --filename-suffix option: flatc --filename-suffix ""

The current behavior when passing "" to --filename-suffix results in the "" being swallowed and the following command line arg being used as a filename suffix which potentially causes parsing to fail if the following arg was the only filename passed to flatc.
So this might be a parsing issue.

Cheers

Hello, so this might be a little annoying to implement since every code generator is implemented slightly differently but #7142 might help. I will keep it in mind as I work on standardizing our code.

How does this affect the code generators? Isn't the filename concatenated before?

We don't centrally open files and give each code generator a file handle, code generators create files themselves decide on how the files are named individually. In some languages, file layout affects modules/namespaces so some code generators make a file per type.

There are also some configuration flags around output directories and code generators also vary the case of the generated files... some of them don't respect the --filename-suffix flag (for good reasons). Its not uniform.

The current behavior when passing "" to --filename-suffix results in the "" being swallowed and the following command line arg being used as a filename suffix which potentially causes parsing to fail if the following arg was the only filename passed to flatc.

All that said, I think this is a parsing issue

I'm unable to reproduce this issue in flatc v2.0.0, I ran these commands and got the resulting files.

$ ls
hero.fbs

$ flatc -c hero.fbs

$ flatc -c --filename-suffix "" hero.fbs

$ tree
.
├── hero.fbs
├── hero_generated.h
└── hero.h

Seems to be working as intended for me.

@Holo-Viktor do you have an example that could reproduce this issue?

huh, I could swear that I tested it in cmd and it didn't work back then, I tested it again now and it seems to work in cmd.
It still doesn't work via vscode cmd terminal tho, so it might be an issue on their part