-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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: suggest sets of build constraints that cover all files in a package #26733
Comments
Also cc @alandonovan for |
How does In theory, the number of variants is exponential with the number of tags, but in practice the number of combinations found in build constraints source files is much smaller than the powerset of tags. |
If you have a directory containing go files and you want to find some set of build tags such that loading the directory with each member of that set in turn leads to every go file in the directory being included at least once, you need to know what tags can affect selection. If you go through every GOOS ⨯ GOARCH ⨯ release tag ⨯ cgo/!cgo ⨯ … ⨯ etc. you're looking at (way!) too many combinations and most of them will resolve to the same list of included files and you're ignoring user-defined tags and things like a GOOS added after you've compiled the tool doing the search. I'm not entirely sure yet that AllTags is sufficient to perform such a search (I need to do some sketching/prototyping) but I do believe that it is necessary. |
We shouldn't have the Probably the right solution for tools is to obtain the complete list of source files from |
That would work, too, I imagine. I am not super familiar with that part of the codebase, but, based on my find/grep/go-to-definition spelunking, it looks like cmd/go/internal/load already computes AllTags, because go/build does. It just doesn't get copied into the struct that go list uses for output. |
Even if it already computes that data, I would argue that we shouldn't expose it unless we think tools will use it appropriately. The |
@ianthehat, a use-case for your team to consider. 🙂 |
(Also CC @jayconrod.) |
It is surprisingly hard to fit into the model for go/packages |
Yeah, I would expect this functionality to go in some package other than |
https://golang.org/cl/12703044 added
AllTags
to*go/build.Package
so that "[t]ools scanning packages can use this to decide how many variants there are and what they are."Since it's often necessary to invoke
go list
rather than usego/build
directly, I think the same reasoning applies for adding it togo list
.The text was updated successfully, but these errors were encountered: