-
-
Notifications
You must be signed in to change notification settings - Fork 668
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
Support the root of code built with rules_go starting under a subdirectory. #459
Comments
I looked very hard at what you did before writing #458, and decided there was no good way to generalise it. The limitation of only one root per repository is too limiting, and any attempt to allow multiple roots ends up with adding an extra attribute to every go library anyway, but in ways that make it harder to understand than a simple import path. The clearest I could manage is to make the go prefix attribute of a go library not hidden, so it can be set, and then you can tell each library where it's root prefix is, and then work out the relative path from the prefix location to the library, but it's not pretty. The advantages of #458 are that it also enables layouts where the package import path is not even slightly related to the file layout, and also allows multiple versions of the same package to exist in the same build (if you build two binaries that need different versions of the same common library for instance, that will work find with this system). |
i'm going to close this on the assumption that the importpath declaration allows the desired pattern, and that the plans in #721 to kill go_prefix and improve gazelle to always generate the importpath declaration are an acceptable plan of action. |
Our repository structure means that all of the code built with rules_go does not start at the root of our Bazel workspace, but in a subdirectory.
This means that a package with importpath "improbable.io/server/foo" would live under the workspace at directory "go/improbable.io/server/foo".
So that we don't have to rewrite all of our importpaths we have a patch which adds an option called prefix_root which specifies the directory at which the go portion of a workspace will begin. improbable-io@512545a
#458 does support this, and is more general, but would require us to specify the import_path in every one of our build targets which seems slightly more complex than a simple directory offset.
Opening this ticket to discuss and see if there are any strong preferences for either approach
The text was updated successfully, but these errors were encountered: