-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See google/cargo-raze#71 (comment) for the rationale as to why In brief: Certain rust build processes expect to find files from the environment variable `$CARGO_MANIFEST_DIR`. Examples of this include pest, tera, asakuma. The compiler and by extension proc-macros see the current working directory as the Bazel exec root. Therefore, in order to fix this without an upstream code change, we have to set `$CARGO_MANIFEST_DIR`. As such we attempt to infer `$CARGO_MANIFEST_DIR`. Inference cannot be derived from `attr.crate_root`, as this points at a source file which may or may not follow the `src/lib.rs` convention. As such we use `ctx.build_file_path` mapped into the `exec_root`. Since we cannot (seemingly) get the `exec_root` from skylark, we cheat a little and use `$(pwd)` which resolves the `exec_root` at action execution time. Fixes: google/cargo-raze#71
- Loading branch information
1 parent
ac74cc1
commit f32695d
Showing
4 changed files
with
43 additions
and
1 deletion.
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
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 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load( | ||
"//rust:rust.bzl", | ||
"rust_test", | ||
) | ||
|
||
rust_test( | ||
name = "conflicting_deps_test", | ||
srcs = ["tests/manifest_dir.rs"], | ||
data = ["src/manifest_dir_file.txt"], | ||
) |
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 @@ | ||
This file tests that CARGO_MANIFEST_DIR is set for the build environment |
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,6 @@ | ||
#[test] | ||
pub fn test_manifest_dir() { | ||
let actual = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/manifest_dir_file.txt")); | ||
let expected = "This file tests that CARGO_MANIFEST_DIR is set for the build environment\n"; | ||
assert_eq!(actual, expected); | ||
} |