-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
Runfiles for go_proto_compiler plugins #2895
base: master
Are you sure you want to change the base?
Conversation
The buildkite logs show that both relevant tests pass on Windows
The the plugin panics with |
Also there is now a failing test, this PR is no regression. That test would have failed before also. |
@fischor What you do in this PR looks reasonable, it's quite possible that |
Passing the plugin executable as tool in the compile actions to assure that its runfiles are made available at runtime.
Adds an attribute called data to go_proto_compiler that allows files to be passed to the rule that are made available to the plugin at runtime.
Expands the locations (ctx.expand_location) that are passed to the go_proto_compiler options attribute considering the data attributes as possible expansion targets.
The runfiles contained newlines that break the code generation on Windows.
@fmeum Thanks for the note. I rebased and updated to use //go/runfiles. The tests still fail with "no runfiles found":
I am currently not interested in pushing forward this PR. If you or anyone else is interested, feel free to take it over. |
What type of PR is this?
Bug fix
Feature
What does this PR do? Why is it needed?
Allow protoc plugins to work with runfiles.
Which issues(s) does this PR fix?
This is for #2704. However, it does not fix it yet.
Other notes for review
Firstly, I wanted to fix #2704.
As state there, plugins do not have access to their runfiles when the compile action of
go_proto_compiler
runs.Here is a failing test: fischor@5a67a43
I've tried to pass the plugin as a tool to the compile action: fischor@459d7fd
Still, compiling the
tests/core/go_proto_compiler/foo.proto
file with the plugin does not work.The runfiles can not be located.
The
bazel.Runfile
function returns an error:could not locate runfiles directory
.I can not see any special environment variable that is used by
bazel.Runfiles
to locate runfiles in the above command.Also, when inspecting the sandbox environment of the above command, I can not locate the
executable_runfiles.conf
file.You can modify the
tests/core/go_proto_compiler/executable_runfiles_plugin.go
to print out the content of the runfile.When running the
go_binary
target, the runfile can be located.So I am assuming that the plugin works correctly, unless I miss something.
Can you help me out here? Why can't it locate the runfile when the
go_proto_compile
action is run?I've also added a
data
attribute to thego_proto_compiler
rule: fischor@00e36e5That allows files to be passed to the plugin. When specifing the path additionally in
options
, the plugin can access the file.I think that would be a better solution to provide configuration files to a protoc plugin.
Since when simply relying of runfiles of the executable, the executable has to be rebuild i.e. a new
go_binary
target has to be created for every compiler that uses a different configuration file.That works and should not break anything.
Test case for that:
b test //tests/core/go_proto_compiler:data_test
.One thing that would be nice is if one could use the "Predefined label variables" for the paths specified in
options
.But the Bazel docs also state that,
So there is no way to use them with files specified in a
data
attribute? Or can I make the label variables work somehow?