Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e835591

Browse filesBrowse files
committed
Use CARGO_MANIFEST_DIR variable for bootimage runner
For doctests it's not possible to derive the manifest path from the executable path and the cargo metadata since doctests live under temp and all use the same name ('rust-out'). Fortunately, cargo sets a `CARGO_MANIFEST_DIR` environment variable for runner executables that points to the manifest path of the executable (which can be different from the root manifest path for workpace projects.)
1 parent 65a03a8 commit e835591
Copy full SHA for e835591

File tree

Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed

‎src/main.rs

Copy file name to clipboardExpand all lines: src/main.rs
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,17 @@ pub(crate) fn runner(args: RunnerArgs) -> Result<i32> {
8585
args.executable.display(),
8686
)
8787
})?;
88+
89+
// Cargo sets a CARGO_MANIFEST_DIR environment variable for all runner
90+
// executables. This variable contains the path to the Cargo.toml of the
91+
// crate that the executable belongs to (i.e. not the project root
92+
// manifest for workspace projects)
93+
let manifest_dir = env::var("CARGO_MANIFEST_DIR")
94+
.context("Failed to read CARGO_MANIFEST_DIR environment variable")?;
95+
let kernel_manifest_path = Path::new(&manifest_dir).join("Cargo.toml");
96+
8897
builder.create_bootimage(
89-
bin_name,
98+
&kernel_manifest_path,
9099
&executable_canonicalized,
91100
&output_bin_path,
92101
args.quiet,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.