We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compile_project
to automate target dir separation per contract in the spirit of near/cargo-near#292, one might replace
near-workspaces-rs/workspaces/src/cargo/mod.rs
Lines 8 to 42 in 187a992
pub async fn compile_project(project_path: &str) -> Result<Vec<u8>, color_eyre::Report> { let project_path = std::fs::canonicalize(project_path).map_err(|e| match e.kind() { std::io::ErrorKind::NotFound => color_eyre::eyre::eyre!( "Incorrect file supplied to compile_project('{}')", project_path ), _ => color_eyre::eyre::eyre!("{:#?}", e), })?; let manifest_path = cargo_near_build::camino::Utf8PathBuf::from_path_buf(project_path.join("Cargo.toml")) .map_err(|error_path| { color_eyre::eyre::eyre!( "Unable to construct UTF-8 path from: {}", error_path.display() ) })?; let build_opts = cargo_near_build::BuildOpts::builder() .no_locked(true) .manifest_path(manifest_path) .build(); compile_project_with_opts(build_opts).await } pub async fn compile_project_with_opts( mut build_opts: cargo_near_build::BuildOpts, ) -> Result<Vec<u8>, color_eyre::Report> { if build_opts.override_cargo_target_dir.is_none() { // should run `cargo metadata --frozen --no-deps` when `no_locked` is false // should run `cargo metadata --offline --no-deps` when `no_locked` is true let (contract_crate_name, target_dir) = cargo_near_build::get_min_metadata( build_opts.manifest_path, build_opts.no_locked ); let path_buf = { let pwd = Path::new(target_dir).canonicalize()?; let sub_target = pwd.join(format!("test-target-for-{contract_crate_name}")); sub_target .to_str() .ok_or_eyre(color_eyre::eyre::eyre!("non valid utf-8 path"))? .to_string() }; build_opts.override_cargo_target_dir = Some(path_buf); } let compile_result = tokio::task::spawn_blocking(move || cargo_near_build::build(build_opts)).await?; let compile_artifact = compile_result?; let file = compile_artifact .path .canonicalize() .map_err(|e| color_eyre::eyre::eyre!("{:#?}", e))?; tokio::fs::read(file).await.map_err(|e| color_eyre::eyre::eyre!("{:#?}", e)) }
without losing much flexibility
The text was updated successfully, but these errors were encountered:
this needs adding cargo_near_build::get_min_metadata export to cargo_near_build
cargo_near_build::get_min_metadata
cargo_near_build
Sorry, something went wrong.
color_eyre was added to snippet just to check if it mostly compiles, near_workspaces::Result should be used as it is now as return value
color_eyre
near_workspaces::Result
No branches or pull requests
to automate target dir separation per contract in the spirit of
near/cargo-near#292, one might replace
near-workspaces-rs/workspaces/src/cargo/mod.rs
Lines 8 to 42 in 187a992
without losing much flexibility
The text was updated successfully, but these errors were encountered: