Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,18 @@ fn fetch_metadata(args: &RuntimeMetadataArgs) -> Result<subxt_codegen::Metadata,
)
}

let root = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".into());
let root_path = std::path::Path::new(&root);
let path = root_path.join(rest_of_path);
// Replace $OUT_DIR with the actual OUT_DIR environment variable
let path = if rest_of_path.contains("$OUT_DIR") {
let out_dir = std::env::var("OUT_DIR").unwrap_or_else(|_| {
abort_call_site!("$OUT_DIR is used in runtime_metadata_path but OUT_DIR environment variable is not set")
});
std::path::Path::new(&rest_of_path.replace("$OUT_DIR", &out_dir)).into()
} else {
let root = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".into());
let root_path = std::path::Path::new(&root);
root_path.join(rest_of_path)
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably make a little function for this and apply the same logic above for lines 216-218; people would expect to be able to do the same thing for the runtime-wasm-path field


subxt_utils_fetchmetadata::from_file_blocking(&path)
.and_then(|b| subxt_codegen::Metadata::decode(&mut &*b).map_err(Into::into))
.map_err(|e| CodegenError::Other(e.to_string()).into_compile_error())?
Expand Down
Loading