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

Allow custom file suffix #5753

Closed
mavam opened this issue Feb 4, 2020 · 5 comments · Fixed by #5778
Closed

Allow custom file suffix #5753

mavam opened this issue Feb 4, 2020 · 5 comments · Fixed by #5778

Comments

@mavam
Copy link

mavam commented Feb 4, 2020

When generating C++ headers via flatc, all files have the suffix _generated.h. However, in many modern C++ projects we have a *.hpp extension. It's not possible to just rename the files, because the generated files include themselves and have the name hardcoded inside. It would be great to have the ability to specify the suffix explicitly.

In #5054 I suggested an option --filename-suffix that allows for customizing everything that comes after the name of the schema. For example, flatc --file-suffix .hpp would create a filename for the schema foo that has the name foo.hpp instead of foo_generated.h.

@aardappel
Copy link
Collaborator

Yes, an option for generated file extension would be good. I guess C++ is the only language we currently support where more than 1 extension is ever used?

@mavam
Copy link
Author

mavam commented Feb 8, 2020

Yeah, I think C++ is the only language with that property. For most flexibility, we could have two options:

  1. --filename-suffix, which would default to _generated
  2. --filename-extension, which would default to the language-specific extension

What do you think?

@aardappel
Copy link
Collaborator

That sounds fine to me. Though, if we haven't ever seen a reason why an other language programmer would want to change the extension, it is not worth supporting?

Either way, feel free to create a PR supporting some or all of this.

@dbaileychess
Copy link
Collaborator

+1 to --filename-suffix and I agree with @aardappel that the extension option is not needed, as that can be done externally via a script.

@mavam
Copy link
Author

mavam commented Mar 2, 2020

@dbaileychess thanks for taking over and filing a PR. Great to see this one completed so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants