File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed
Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,15 @@ use std::path::PathBuf;
77pub fn get_project_root ( ) -> Result < PathBuf , & ' static str > {
88 let project_root = env ! ( "PROJECT_ROOT" ) ;
99 if project_root. is_empty ( ) {
10- let error =
11- "The crate `prebindgen-project-root` is being used as a Cargo dependency.\n \
12- Since it is not located inside your workspace, it cannot determine the path to the workspace root.\n \
13- Please add `prebindgen-project-root` as a member of your workspace and patch dependencies to use it locally .\n \n \
14- This can be done using the helper tool:\n \n \
10+ let error =
11+ "The crate `prebindgen-project-root` is being used as a regular Cargo dependency.\n \
12+ Because it is not located within your workspace, it cannot determine the path to the workspace root.\n \
13+ Please add `prebindgen-project-root` as a member of your workspace and patch your dependencies to use the local path .\n \n \
14+ You can do this with the helper tool:\n \n \
1515 cargo install prebindgen-project-root\n \
1616 cargo prebindgen-project-root install <path>\n \n \
17- where `<path>` is the path to your workspace root.\n ";
17+ where `<path>` is the path to your workspace root.\n \n \
18+ If the patch is already applied and the error persists, verify the version of the patched crate.";
1819 Err ( error)
1920 } else {
2021 Ok ( project_root. into ( ) )
Original file line number Diff line number Diff line change @@ -88,16 +88,22 @@ fn install(input: &Path) -> Result<()> {
8888 // 2) Write Cargo.toml for the local crate (library only)
8989 let local_cargo = local_crate_dir. join ( "Cargo.toml" ) ;
9090 if !local_cargo. exists ( ) {
91- let cargo_toml = r#"[package]
91+ // Use this binary's package version for the generated crate version.
92+ let version = env ! ( "CARGO_PKG_VERSION" ) ;
93+ let cargo_toml = format ! (
94+ r#"[package]
9295name = "prebindgen-project-root"
96+ version = "{version}"
9397edition = "2021"
9498license = "MIT OR Apache-2.0"
9599description = "Utility to expose the workspace project root at build time"
100+ publish = false
96101
97102[build-dependencies]
98103project-root = "0.2"
99104quote = "1"
100- "# ;
105+ "#
106+ ) ;
101107 fs:: write ( & local_cargo, cargo_toml)
102108 . with_context ( || format ! ( "writing {}" , local_cargo. display( ) ) ) ?;
103109 }
Original file line number Diff line number Diff line change @@ -166,8 +166,7 @@ fn cargo_run_and_assert_workspace(dir: &Path, pkg: Option<&str>) {
166166 eprintln ! ( "[test] program printed: {}" , printed) ;
167167 eprintln ! ( "[test] expected root : {}" , expected_str) ;
168168 assert_eq ! (
169- printed,
170- expected_str,
169+ printed, expected_str,
171170 "printed workspace root does not match expected"
172171 ) ;
173172}
You can’t perform that action at this time.
0 commit comments