flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

allow no filename suffix [all languages, flatc 2.0.0]

Open Holo-Viktor opened this issue 2 years ago • 4 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

Holo-Viktor avatar May 04 '22 14:05 Holo-Viktor

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.

CasperN avatar May 05 '22 16:05 CasperN

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

Holo-Viktor avatar May 08 '22 14:05 Holo-Viktor

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

CasperN avatar May 08 '22 22:05 CasperN

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?

le-michael avatar Oct 26 '22 07:10 le-michael

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

Holo-Viktor avatar Nov 02 '22 15:11 Holo-Viktor