mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-25 03:11:21 +00:00
fix(build): resolve the artifacts dir at build-script runtime
This commit is contained in:
+10
-2
@@ -17,11 +17,19 @@ use anyhow::{Context as _, Result, bail};
|
||||
/// }
|
||||
/// ```
|
||||
pub fn include_artifacts(artifacts_sub_dir: &str) -> Result<()> {
|
||||
let manifest_dir = PathBuf::from(std::env!("CARGO_MANIFEST_DIR"));
|
||||
// Resolved at build-script runtime from the invoking crate, not at compile
|
||||
// time: `env!` would bake in the path of whichever checkout compiled this
|
||||
// rlib first, and with a shared cargo target dir every other worktree then
|
||||
// embeds that checkout's artifacts instead of its own.
|
||||
let invoking_manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
|
||||
let workspace_root = invoking_manifest_dir
|
||||
.ancestors()
|
||||
.find(|dir| dir.join("artifacts").is_dir())
|
||||
.context("no artifacts/ directory above the invoking crate")?;
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR")?);
|
||||
let mod_dir = out_dir.join(artifacts_sub_dir);
|
||||
let mod_file = mod_dir.join("mod.rs");
|
||||
let artifacts_dir = manifest_dir.join(format!("../artifacts/{artifacts_sub_dir}/"));
|
||||
let artifacts_dir = workspace_root.join(format!("artifacts/{artifacts_sub_dir}/"));
|
||||
|
||||
println!("cargo:rerun-if-changed={}", artifacts_dir.display());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user