I've had success before where I was in the same package and new which files to inspect in the mockgen target, but I can't seem to easily get to the genfiles of another distant, generated target without resorting to assuming things about the filepaths bazel uses.
I'm not sure how to do this programmatically inside of bazel. Is there a way to get to the genfiles a target creates from another target?
--
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/531572c7-b500-4242-9297-d899f31d941a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I'm not familiar with the Go rules, but the way to get access to that information is via the transitive info providers of the rule. I often find the easiest way to work with unknown/underdocumented rules is to just print what's there and see if anything looks like what you want. `print('%s' % dir(ctx.attr.attr_name))` where attr_name is deps or srcs or whatever you called the attribute where the label of the go_proto_library rules are will get you names of all the providers, and then you can drill down from there. Once you find a File which is what you're looking for, path is the way to get a path to it. Digging around with paths manually is a recipe for making non-hermetic rules which don't rebuild properly, so avoid that.Another way to figure out how to work with the Go rules is to look at their implementation see what they provide. As mentioned in the documentation, whatever the rule implementation function returns is (basically) what you can access, so look at what's there.On Sun, Apr 16, 2017 at 3:26 PM, jeff via bazel-discuss <bazel-...@googlegroups.com> wrote:I'm stuck trying to get a mockgen[1] target to work on a go_proto_library target. mockgen expects either a) a working GOPATH (which rules_go currently doesn't provide to it) or b) a file path to the specific code file that holds the interface you want to create a fake for.
I've had success before where I was in the same package and new which files to inspect in the mockgen target, but I can't seem to easily get to the genfiles of another distant, generated target without resorting to assuming things about the filepaths bazel uses.
I'm not sure how to do this programmatically inside of bazel. Is there a way to get to the genfiles a target creates from another target?
[1] https://github.com/golang/mock
--
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.