--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAPuPPcsQk9yL1XZ76i8SgWnPxNt1mYogCux%3Dub1q3v_MsmhH2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
Thanks for your explanation! Let me loop in some folks from the regular rules_go contributors, maybe they have some thoughts too.
Meanwhile, can you explain why you can't run gazelle from the extension? I mean, is it that you don't know how to run it do it, or you do but gazelle reports some error?
For the record, I'm working on a change that'll add a runfiles.sh library to @bazel_tools (maybe in Bazel 0.8.0) that will define a `rlocation()` function that you can use to look up runfiles easily, without having to use the find|head hack. (https://bazel-review.googlesource.com/c/bazel/+/18412)
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAPuPPcsQk9yL1XZ76i8SgWnPxNt1mYogCux%3Dub1q3v_MsmhH2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAPuPPcsX1S6gumD_MX2Dw3cs0wqvJXxBO4Jh-hRY9wC_NoGbCw%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAPuPPcsQk9yL1XZ76i8SgWnPxNt1mYogCux%3Dub1q3v_MsmhH2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
So I think the fundamental problem you're running into is that "bazel run" executes programs in the execroot, not in the source tree. The gazelle rule cheats a bit here. You can see the implementation in gazelle.bzl. We add //:WORKSPACE as a data dependency to a generated bash script. When the script runs, it reads the symlink to the WORKSPACE file in the source tree, changes to that directory, then executes the Gazelle binary.
I would not recommend this approach. There are several disadvantages.
- It's not guaranteed to work in the future. There's no reason a data dependency has to be a symlink to the source tree.
- You won't know the user's working directory; you can only jump to a specific directory in the source tree.
- You won't have access to stdin. "bazel run" doesn't provide it.
- Bazel will hold a lock while your program is running. No other bazel commands can run concurrently.
- In general, this breaks expectations that things executed with "bazel run" are isolated from your source tree.
Because of these disadvantages, I'm thinking of switching Gazelle to another approach.
- A bazel rule would build a script that has all the Gazelle arguments baked in.
- The script would have to be manually copied to the source tree. This would need to be done once in a new workspace, and then whenever the script changes (not very often). The script would warn when it needs to be updated.
- When the script is run from the source tree, it would "bazel build" and then execute Gazelle with the baked in arguments.
> Yes, but we have tasks where we need to update source tree.> If you restrict do it from "run" targets, it means, users would be forced to write some wrappers-scripts around bazel...> Probably we should consider to allow write rules which modify source tree.> These rules should be banned from build execution, it is just utility actions, which always run manually.Personally, I agree with you here. I'd like to be able to define rules which operate in the workspace and don't hold the Bazel lock. There could be an attribute on binary rules that says whether they execute that way. It makes sense to disqualify these from being run as part of a normal build.I brought up some of these ideas in another thread, and while there were lots of good ideas, it didn't seem like Bazel itself could support this before 1.0. The required changes are significant.
Until then, it seems like wrapper scripts are the best option.
> If you restrict work with WORKSPACE, it means I should wrap bazel and some my scripts in the root Makefile, and use make instead off bazel-onlyYou don't necessarily need to use make, but you will probably need some sort of wrapper script that builds some tools with Bazel then executes them with known arguments.