-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
Respect go_prefix attr of dependencies #30
Conversation
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)
Can one of the admins verify this patch? |
Jenkins: test this please. |
Hmm, "test this please" does not work. |
Yes, you need to be member of bazelbuild and make it public (https://github.com/orgs/bazelbuild/people/yugui) Jenkins test this please. |
remote = "https://github.com/golang/glog.git", | ||
commit = "23def4e6c14b4da8ac2ed8007337bc5eb5007998", | ||
build_file_content = GLOG_BUILD, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a pretty easy way to do a go_vendor macro rule:
TEMPLATE = """
load("@io_bazel_rules_go//go:def.bzl", "go_prefix", "go_library")
go_prefix("github.com/%s/%s")
go_library(name = "go_default_library", srcs = glob(["**/*.go"]), visibility = ["//visibility:public"])
"""
def go_vendor(org, project, commit):
new_git_repository(name = "com_github_%s_%s" % (org, project), remote = "https://github.com/%s/%s.git" % (org, project), commit = commit, build_file_content = TEMPLATE % (org, project))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually io_bazel_rules_go won't work currently. You have to use a trick with str(Label(...)) for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damienmg
I would like to keep go_vendor
separated from this PR because other go libraries requires much more work. It it acceptable for you?
The simple macro works fine with glog
but other common go libraries are more complex. e.g. https://github.com/golang/oauth2 requires:
- parsing build tags
- dependency analysis in the repository
- external dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sounds reasonable.
I don't think you need to handle all the cases for an initial version but sure you might want to handle some more than a basic build.
@damienmg |
LGTM |
For the org: you have a pending invitation, you should be able to accept it. |
I found the invitation mail in my inbox. Thank you! |
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)
Supports case 1 and 3 in #16.