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
proposal: x/tools/go/packages: add Dir and Target (and perhaps other) fields to Package struct #38445
Comments
I would really like to see |
Agreed on |
I think if the proposal to add the field with build system specific information as accepted, |
If proposal 3 doesn't get accepted, then I would argue that go/packages should support the important features of the most common build system, which is |
That's reasonable. I think we should probably do one or the other. |
Another field I would deem useful is
This would allow tools to emulate Go's behavior of warning about patterns that don't match any packages, a la Whether me needing yet another field pushes us more towards proposal 3 I don't know. |
Another one would be a package's build ID, once/if #37281 is implemented. We could call the field |
Hm, I'm thinking that
|
The issue, as so often, is performance: we want to use go/packages to be build-system agnostic, but we also want low-level details when available, without incurring the cost of a second |
I thought |
It isn't. If this proposal is accepted, we'll relax our requirement that all of We'll have to be careful about this to make sure that we don't end up with too many tools that don't work on Blaze/Bazel. |
I'm hoping that fixing this (adding some build-system-specific fields to Package) will provide users enough information so that #38448 isn't needed. So I'd like to hear if there are any other build-system-specific fields users need. I think we should have a plan for what we're going to do with both proposals before proceeding. |
@matloob ping - has this advanced in the past few months? Or are you waiting for more input from users? |
I'd love to see a I am currently using a kludgey workaround:
At first I did try to retrieve the |
I'd like to echo mvdan's ping and vote to move forward with adding the following fields:
The fields which are not viable across build systems can be documented and handled as such by tools. For example, in my specific case, Match would be used for improved UI, and BuildID as an optimization, both of which can be optional. We might need a new field, however, that stores which build system specific fields were populated, as an empty Match is a valid value and difficult to differentiate from "Match wasn't populated". I don't think that #38448 is viable due to the bad performance of tying all information to a single Need bit. Furthermore, it has been 3 years since the introduction of go/packages, and exactly one public driver exists, I'd also like to assume that there will be enough overlap between the fields of different build systems, the same way we already assume for the current fields in type Package. That is, these additional fields might not stay specific to Finally, go/packages already has several features specific to
I think it is safe to say that go/packages has already adopted a " |
In addition to information about modules, go/packages now also exposes information about go:embed, which is moderately specific to the Go build system. I think that at this point we've clearly decided to keep adding information and Need bits to go/packages directly, without going the modular route of #38448, even if they don't universally apply to all build systems. IMO it is time to retire #38448 and to move forward with this issue. |
I think at this point we should proceed with this proposal and not with #38448. |
This is proposal 1 of 3 coming out of the discussion of issue #38234.
We propose adding the following fields to the Package struct, which might not necessarily be present for all build systems:
Dir
, which would be the directory associated with the package, if any. For the go build system, this would be the directory the package is contained in. This might not be as clearly defined for Bazel, but might be the directory the BUILD file is in.Target
, which is the install path of the.a
file, for libraries, and executable file for binaries,and perhaps other such fields, pending the discussion. If these fields are added, we'd need to also add Need fields. We'd also need to make it clear to users that these fields might not be set, even if they are requested via needs fields.
The text was updated successfully, but these errors were encountered: