-
Notifications
You must be signed in to change notification settings - Fork 412
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
Merged
illicitonion
merged 1 commit into
bazelbuild:master
from
sitaktif:external-cargo-manifest-dir
Oct 26, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
docs | ||
examples | ||
examples/hello_cargo_manifest_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
# bazel | ||
/bazel-* | ||
/examples/bazel-* | ||
/examples/*/bazel-* | ||
/docs/bazel-* | ||
|
||
# rustfmt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello_cargo_manifest_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library") | ||
|
||
rust_library( | ||
name = "hello_cargo_manifest_dir", | ||
srcs = ["src/lib.rs"], | ||
data = ["include/included_file.rs.inc"], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
local_repository( | ||
name = "io_bazel_rules_rust", | ||
path = "../..", | ||
) | ||
|
||
load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories") | ||
|
||
rust_repositories() | ||
|
||
load("@io_bazel_rules_rust//:workspace.bzl", "rust_workspace") | ||
|
||
rust_workspace() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
I love veggies! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
pub fn get_included_str() -> &'static str { | ||
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/include/included_file.rs.inc")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_test") | ||
|
||
rust_test( | ||
name = "hello_uses_cargo_manifest_dir", | ||
srcs = ["src/lib.rs"], | ||
edition = "2018", | ||
deps = ["@hello_cargo_manifest_dir"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
use hello_cargo_manifest_dir::get_included_str; | ||
|
||
#[test] | ||
fn test_lib_with_include() { | ||
assert_eq!(get_included_str(), "I love veggies!\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
(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 theexamples/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... 😅