Skip to content

Commit b21d879

Browse files
committed
make crate defined output-dir relative to Cargo.toml it was defined in. Fixes #48
1 parent 39397c4 commit b21d879

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

crates/cargo-gpu/src/metadata.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Get config from the shader crate's `Cargo.toml` `[*.metadata.rust-gpu.*]`
22
3+
use serde_json::Value;
4+
35
/// `Metadata` refers to the `[metadata.*]` section of `Cargo.toml` that `cargo` formally
46
/// ignores so that packages can implement their own behaviour with it.
57
#[derive(Debug)]
@@ -59,8 +61,19 @@ impl Metadata {
5961
&mut metadata,
6062
{
6163
log::debug!("looking for crate metadata");
62-
let crate_meta = Self::get_crate_metadata(cargo_json, path)?;
64+
let mut crate_meta = Self::get_crate_metadata(cargo_json, path)?;
6365
log::trace!("crate_metadata: {crate_meta:#?}");
66+
if let Some(output_path) = crate_meta.pointer_mut("/build/output_dir") {
67+
log::debug!("found output-dir path in crate metadata: {:?}", output_path);
68+
if let Some(output_dir) = output_path.clone().as_str() {
69+
let new_output_path = path.join(output_dir);
70+
*output_path = Value::String(format!("{}", new_output_path.display()));
71+
log::debug!(
72+
"setting that to be relative to the Cargo.toml it was found in: {}",
73+
new_output_path.display()
74+
);
75+
}
76+
}
6477
crate_meta
6578
},
6679
None,

0 commit comments

Comments
 (0)