flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

grpc/compiler: Respect filename suffix and extension during code generation

Open amaneureka opened this issue 2 years ago • 3 comments

grpc compiler is not respecting filename suffix and extension passed to flatc CLI. This causes compiler to spit out incorrect code, which then cannot be compiled without modification.

Following patch fixes the problem.

Signed-off-by: Aman Priyadarshi [email protected]

amaneureka avatar Jun 12 '22 16:06 amaneureka

Looks OK to me, can we add a test to show that it is working?

dbaileychess avatar Jun 15 '22 04:06 dbaileychess

mmhm, I had a second look at the code just now, while adding tests.

Turns out, this entire generation code is a mess, with things all over the place.

For example, we have generator suffix is defined in two places cpp_generator.cc and idle_gen_grpc.cpp.

While the former definition is still "okay", but the later doesn't makes sense to be defined in the base class (".h" is not a valid extension for other languages).

My changes does the right thing of keeping language specific stuff in *lang*_generator.cc file.

amaneureka avatar Jun 18 '22 15:06 amaneureka

@dbaileychess I've made some additional changes compared to the last revision, and added tests too.

amaneureka avatar Jun 18 '22 17:06 amaneureka

Please rebase and run scripts/generate_code.py and reupload. You were missed checking in some generated files.

dbaileychess avatar Aug 06 '22 06:08 dbaileychess

@dbaileychess Not really. Build failed because commit b7f13cd8 ("cpp_generator: comment out unused parameter to avoid warnings (#7381)") was merged to master before my PR :)

Anyway, I'll rebase my branch against master and raise a new PR.

amaneureka avatar Aug 07 '22 15:08 amaneureka