-
Notifications
You must be signed in to change notification settings - Fork 650
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 specifying custom package name #16
Comments
IIUC, the main problem described in bazelbuild/bazel#828 has gone because now label names can contain slash. I'll summarize the patterns and remaining problems tomorrow or day after tomorrow. |
Preliminary work in f32a39c. It suits my immediate hacking needs, but I'll try to come up with something that's actually properly committable (not to mention with the correct git author field). @damienmg I didn't check yet, but I'll assume this is maintained primarily externally? And also, given that there's no project on Gerrit, I'll assume that a Github PR is the correct way to contribute? |
Sorry for being a bit late. It'd be better to discuss use cases of customization. In my understanding, basically users need to customize import paths when they import third-party libraries. So before discussing solutions to customize import paths, I'd like to summarize several possible patterns of importing third-party libraries. Patterns of Bazelization of third-party librariesTL;TR. It shows that the main use case of import path customization is the case that the user uses Pattern 1: Add a
|
I love the overview!
I agree that the need for total customization of package names, esp. in relation to pattern 2, has dropped off significantly when slashes in target names became possible. I'm trying this out now and the porting over to Bazel rules is going extremely smoothly. In addition to the commentary above, I have run into additional use case in my small project from bazelbuild/bazel#828: generated proto->go files. To make building easier with
Current workaround for the problem:
This way, |
You can reuse the rule if the external project is simple enough. However, similarly to the con 2 of the pattern 1, you cannot reuse if the external project have several Bazel packages.
That's an interesting use case. But I couldn't get your point about how import path customization would help this use case. |
FWIW I would prefer pattern 3 because it is more the Bazel philosophy. We could create a custom go_vendor() rule for the WORKSPACE file that would create a good skylark kind with a provider for the list of import map. That would work just fine. If the rules is correctly set-up then it could actually cover both pattern 1 and 3. |
@damienmg I like pattern 3 as well -- but why would I go with pattern 2 (git submodules in
@yugui Ah, I missed the "workspaces are not importable" problem. Regarding my use of renaming, I'll try to describe without going all the way to provide a public demo.
Sorry I wasn't clearer before; does this make more sense? |
@damienmg @ivucica More generically, can we say that existing repositories sometimes contains generated files because those files are hard to regenerate but in Bazel it is easier to regenerate them so it is better to let Bazel regenerate? In my understanding, existing repositories tend to contain generated files because treditional build tools were not good at installing uncommon code generators. e.g.
On the other hand, it is easy for Bazel to write a skylark rule which installs/builds For me, this difference between traditional build tools and Bazel seems to be the cause of the problem. So I am wondering if we can have a more generic solution. |
@yugui: yes :) |
Uses go_prefix attr of individual dependencies to calculate their importpaths. This allows users to use Bazel's external dependency resolution -- {,new_}git_repository rules -- to manage Go libraries. c.f. #16 (comment)
Uses go_prefix attr of individual dependencies to calculate their importpaths. This allows users to use Bazel's external dependency resolution -- {,new_}git_repository rules -- to manage Go libraries. c.f. #16 (comment)
In #30, I implemented the solution I proposed. It allows us to deal with the case 3 and it is also useful for the case 1. As @damienmg suggested, it is better to define a repository rule Unfortunately #30 does not solve @ivucica's use case. But #30 is still useful as a foundation to support his use case if necessary. |
Uses go_prefix attr of individual dependencies to calculate their importpaths. This allows users to use Bazel's external dependency resolution -- {,new_}git_repository rules -- to manage Go libraries. c.f. #16 (comment)
* Github-flavored markdown now supports bzl format * Fix typo * Follow e08ee96 in documents * Wrap lines to keep them shorter than 80 characters * Now bazel accepts "github.com" as a directory name c.f. abe7374 and #16 (comment)
It supports the pattern 2 discussed in #16 (comment)
It supports the pattern 2 discussed in #16 (comment)
I think everything in here is now covered by the explicit import_path and flat build file solutions. |
See bazelbuild/bazel#828
The text was updated successfully, but these errors were encountered: