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

Change dash to underscore in generated filenames #178

Merged

Conversation

mjduijn
Copy link
Contributor

@mjduijn mjduijn commented Dec 31, 2018

The generated rust file for my-file.proto is my_file.rs.
Declared outputs for *_proto and *_grpc rules should reflect this.

@@ -16,7 +16,7 @@

def file_stem(f):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should remain a helper that takes '/some/path/file.txt' and returns 'file', can you move the replace to L52?

paths = ["%s/%s" % (output_dir, file_stem(i).replace("-", "_") for i in protos.to_list()]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same functionality is needed for generating the module names for lib.rs (see proto/proto.bzl).
The function doesn't appear to be used in other cases.
Mind if I just rename the function to generated_file_stem instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that makes sense. (I didn't notice the other usages.)

@mfarrugi
Copy link
Collaborator

How did you notice this?

@mjduijn mjduijn force-pushed the set-underscore-genfile-delimiter branch from 79dc373 to 6b4f906 Compare January 2, 2019 07:44
@mjduijn
Copy link
Contributor Author

mjduijn commented Jan 2, 2019

We have some files with dashes as delimiter, so when trying to generate the code, I got the following error

ERROR: <path-to-build-file> output '<path-to-expected-output>' was not created
ERROR: <path-to-build-file>: not all outputs were created or valid Target <path-to-target> failed to build

I've written a couple of these kinds of bazel rules for generating gRPC bindings, so I was familiar with the error.

The generated rust code for my-file.proto is in my_file.rs.
Declared outputs for _proto and _grpc rules should reflect this.
@mjduijn mjduijn force-pushed the set-underscore-genfile-delimiter branch from 6b4f906 to 31e96ae Compare January 2, 2019 08:45
@mfarrugi mfarrugi merged commit ac74cc1 into bazelbuild:master Jan 4, 2019
@mfarrugi
Copy link
Collaborator

mfarrugi commented Jan 4, 2019

Thanks

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

Successfully merging this pull request may close these issues.

None yet

3 participants