Skip to content

Commit 611ec99

Browse files
committed
feat(build-rs): Add cargo_manifest_path
1 parent 4ff0809 commit 611ec99

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

crates/build-rs-test-lib/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ fn smoke_test_inputs() {
4747
dbg!(cargo_encoded_rustflags());
4848
dbg!(cargo_feature("unstable"));
4949
dbg!(cargo_manifest_dir());
50+
dbg!(cargo_manifest_path());
5051
dbg!(cargo_manifest_links());
5152
dbg!(cargo_pkg_authors());
5253
dbg!(cargo_pkg_description());

crates/build-rs/src/input.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ pub fn cargo_manifest_dir() -> PathBuf {
2929
to_path(var_or_panic("CARGO_MANIFEST_DIR"))
3030
}
3131

32+
/// The path to the manifest of your package.
33+
#[track_caller]
34+
pub fn cargo_manifest_path() -> PathBuf {
35+
var_os("CARGO_MANIFEST_PATH")
36+
.map(to_path)
37+
.unwrap_or_else(|| {
38+
let mut path = cargo_manifest_dir();
39+
path.push("Cargo.toml");
40+
path
41+
})
42+
}
43+
3244
/// The manifest `links` value.
3345
#[track_caller]
3446
pub fn cargo_manifest_links() -> Option<String> {

0 commit comments

Comments
 (0)