-
Notifications
You must be signed in to change notification settings - Fork 402
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
Handle external packages using CARGO_MANIFEST_DIR #464
Handle external packages using CARGO_MANIFEST_DIR #464
Conversation
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
bb61346
to
c2a05ce
Compare
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.
LGTM!
Looks like CI is failing because the root WORKSPACE
doesn't have a definition for the hello_cargo_manifest_dir
repository :)
c2a05ce
to
0df10b1
Compare
Fixed! |
WORKSPACE
Outdated
@@ -79,3 +79,9 @@ docs_deps() | |||
load("@docs//:docs_transitive_deps.bzl", docs_transitive_deps = "transitive_deps") | |||
|
|||
docs_transitive_deps(is_top_level = True) | |||
|
|||
# For the hello_uses_cargo_manifest_dir example. | |||
local_repository( |
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.
Why does this need to be a repository? And if it needs to be a repository, could it not be put into example_deps
similar to how rules_proto
was added to docs/docs_transitive_deps.bzl
?
https://github.com/bazelbuild/rules_rust/blob/master/docs/docs_transitive_deps.bzl#L20-L31
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.
Great questions!
It needs to be a repository because that's specifically the case we are testing: something that depends on an external target that uses the CARGO_MANIFEST_DIR
environment variable. If the target is not external (ie. not in a separate repo) it won't reproduce the issue that this commit is fixing.
I can definitely put the deps in a separate bzl and will do so. Unfortunately I won't be able to reuse that .bzl
file in examples/WORKSPACE
because the path
attribute has to be different, but it will still be a nice improvement to avoid polluting the root WORKSPACE
👍
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.
You could use a bool (is_top_level
) similar to the snippet I sent you to toggle between the paths. Would that not be sufficient?
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.
You're totally right, I should have read your comment more carefully. Amended as suggested!
222b9e3
to
d740455
Compare
|
||
# Needed by the hello_uses_cargo_manifest_dir example. | ||
if is_top_level: | ||
maybe( |
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 should be
maybe(
native.local_repository,
name = "hello_cargo_manifest_dir",
path = "hello_cargo_manifest_dir",
)
(Sorry if this is obvious, just trying to help 😅)
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.
"just one small change, surely I can't mess that one up". Anyway, thanks for the help :-)
Unrelated, but I noticed that if you build from the examples/
dir (which creates all the examples/bazel-*
directories, building from the root directory sometimes fails because of infinite recursion, as if the .bazelignore
was ignored. I couldn't find how to fix the issue (the issue wasn't introduced in this commit though).
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.
Yeah... that's what happens when you have nested workspaces that depend on the root workspace like this. local_repository
should ignore bazel output paths (or accept a pattern to ignore certain directories).
Hopefully Bazel's proposal for external dependencies resolves this. For now, you'll just have to make sure you bazel clean
in ./examples
. Or at least that's what I do... 😅
d740455
to
d76df03
Compare
Ok I think we're good now :-) |
@sitaktif I know this is a bit late but I was wondering if you'd be willing to merge
to something like:
Just as a way to bundle the two examples 😅 (obviously not major, just a drive-by thought) |
No description provided.