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

Provide a way to add build comment lines in generated files #42

Open
stephane-martin opened this issue Oct 1, 2017 · 2 comments
Open

Comments

@stephane-martin
Copy link

Hi,

thank you for this great project!

I need some generated files to be compiled only on Linux. Usually I'd drop a "// +build linux" line on top of such file. Obviously I don't want to manually add that on generated files. I could automate that with a Makefile, but Makefiles come with their own problem when you want to support both Linux and Macos (different make command, different sed command).

So maybe goderive could copy build comment lines from the source file to the generated file, when such comment line is present ? Or another more clever mechanism you could imagine...

@awalterschulze
Copy link
Owner

I think this sounds like a good feature.
Basically I don't want goderive to generate code that is not used.
This means that if code is generated from a file that will only be used in linux then the generated functions should only be available to the linux code.

This means that goderive should be able to generate multiple files for a single package and add the appropriate build tags to each, if they are necessary.

I don't know if I'll have time to build this feature, but I will provide support for a pull request.

@awalterschulze
Copy link
Owner

As a temporary work around you could always write a little go program (cross platform) to add the lines for you. I needed to do this for gogoprotobuf. Here is my very lame example
https://github.com/gogo/protobuf/blob/master/gogoreplace/main.go

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

No branches or pull requests

2 participants