-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
x/tools/go/packages: add Dir, Target, and ForTest fields to Package #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. |
I think we should add at least |
Related, the proposal to add a |
Updated to add ForTest. |
I reworded the definition of ForTest. Otherwise this looks good to me. |
This proposal has been added to the active column of the proposals project |
Have all remaining concerns about this proposal been addressed? The proposal is to add three fields to type Package: We propose adding the following fields to the Package struct, which might not necessarily be present for all build systems:
|
Minor clarification: In "ForTest, which is a string set to the name of a test that this package is being built for", I think we should s/name/package path. |
Based on the discussion above, this proposal seems like a likely accept. The proposal is to add three fields to type Package: We propose adding the following fields to the Package struct, which might not necessarily be present for all build systems:
|
No change in consensus, so accepted. 🎉 The proposal is to add three fields to type Package: We propose adding the following fields to the Package struct, which might not necessarily be present for all build systems:
|
Change https://go.dev/cl/626495 mentions this issue: |
Add a new Dir field, and export ForTest, per golang/go#38445. The needInternalForTest mode bit is promoted to NeedForTest, but no mode bit is added for Dir as it is logically related to NeedFiles. A test is added for the new fields using a simpler txtar-based setup, since I did not have time to page in the quite heavyweight packagestest framework. For golang/go#38445 Change-Id: I92026462f7ed7e237db1f4e50a3bbf2936802fbb Reviewed-on: https://go-review.googlesource.com/c/tools/+/626495 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
@matloob do you want to add Target so that we can close this? You may be better suited to implement/test that (we don't use the compiler for gopls). |
Updated 2024-08-12: Added
ForTest
to the set of fields proposed to be added.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.ForTest
, which is a string set to the name of a test that this package is being built for (when the package is not the standard copy of that package and has been modified for a specific test; this happens with coverage and pgo).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: