-
-
Notifications
You must be signed in to change notification settings - Fork 684
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
go.library_to_source should only accept Targets for deps #1784
Comments
I just happened upon this issue - another case of what if one rule generates more than one library/archive? In particular, our rule generates several libraries that a binary then depends on. I saw this comment in the code base before https://github.com/bazelbuild/rules_go/blob/3b5f0c950e0deec63cd77cdcec7765b5f41fefbd/go/private/context.bzl#L199-L200 Unfortunately, that means that users cannot specify target patterns in the cmds list and every cmd has to be listed individually (and with an absolute label, but that's my fault). Because of this, I'd like it if |
Seems reasonable to change to drop that TODO and change the documentation to reflact that
Just to double check, does the rule generate multiple packages that could be imported by the binary, or one importable package with others that need to be passed to the linker? If it's the first case, you would just need one
Hopefully you won't need this, but you can set |
It generates both multiple packages, and the binary depending on all of them. Hm. How can I put many different libraries into on GoArchive/Target? Could split the process into 2 steps (n packages rewritten in one rule + binary depending on all those packages), rather than n+1; that'd keep it a Target. |
You can't. I was just thinking that if you only had one importable package, no change would be needed. I think this ought to be possible though. I'll add a note to #2578. If there's a substantial change to the API in the future, that ought to be included. For the short term, documenting that in |
Got it, SGTM. Thank you! |
attr["deps"] may be a list of either Targets or GoArchive. Fixes bazel-contrib#1784
attr["deps"] may be a list of either Targets or GoArchive. Fixes #1784
go.library_to_source
accepts anattr
parameter, which is usually but not alwaysctx.attr
. When retrieving the list of dependencies, we callget_archive
on each element ofattr["deps"]
, which is normally a list ofTargets
.Callers that generate packages (
go_test
,nogo
) calllibrary_to_source
with astruct
instead ofctx.attr
. These callers pass in a list ofGoArchives
instead of a list ofTargets
forattr["deps"]
. This makes it hard to do anything withattr["deps"]
not related to archives.The documentation says
attr
is just a set of attributes. We should clarify what to put here for clients that are generating packages.The text was updated successfully, but these errors were encountered: