diff --git a/crates/moonbuild/src/pre_build.rs b/crates/moonbuild/src/pre_build.rs index 412063f3..604ddbdf 100644 --- a/crates/moonbuild/src/pre_build.rs +++ b/crates/moonbuild/src/pre_build.rs @@ -19,7 +19,7 @@ use std::path::PathBuf; use std::rc::Rc; -use moonutil::common::MoonbuildOpt; +use moonutil::common::{MoonbuildOpt, DEP_PATH, MOD_DIR, MOONCAKE_BIN, MOON_BIN_DIR, PKG_DIR}; use moonutil::module::ModuleDB; use moonutil::package::StringOrArray; use n2::graph::{self as n2graph, Build, BuildIns, BuildOuts, FileId, FileLoc}; @@ -108,14 +108,16 @@ pub fn load_moon_pre_build( command.to_string() } .replace( - moonutil::common::MOONCAKE_BIN, + MOONCAKE_BIN, &moonbuild_opt .source_dir - .join(moonutil::common::DEP_PATH) - .join(moonutil::common::MOON_BIN_DIR) + .join(DEP_PATH) + .join(MOON_BIN_DIR) .display() .to_string(), - ); + ) + .replace(MOD_DIR, &moonbuild_opt.source_dir.display().to_string()) + .replace(PKG_DIR, &cwd.display().to_string()); let command = command .replace("$input", &inputs.join(" ")) diff --git a/crates/mooncake/src/pkg/install.rs b/crates/mooncake/src/pkg/install.rs index abc0dc58..ab033db9 100644 --- a/crates/mooncake/src/pkg/install.rs +++ b/crates/mooncake/src/pkg/install.rs @@ -75,8 +75,6 @@ pub(crate) fn install_impl( None => dep_dir.path().join(bin_mod_to_install), }; - // dbg!(&bin_mod_path); - if !bin_mod_path.exists() { anyhow::bail!( "binary module `{}` not found in `{}`", diff --git a/crates/moonutil/src/common.rs b/crates/moonutil/src/common.rs index 825e6f74..adacaf3d 100644 --- a/crates/moonutil/src/common.rs +++ b/crates/moonutil/src/common.rs @@ -61,6 +61,8 @@ pub const MOON_DOC_TEST_POSTFIX: &str = "__moonbit_internal_doc_test"; pub const MOON_BIN_DIR: &str = "__moonbin__"; pub const MOONCAKE_BIN: &str = "$mooncake_bin"; +pub const MOD_DIR: &str = "$mod_dir"; +pub const PKG_DIR: &str = "$pkg_dir"; #[derive(Debug, thiserror::Error)] pub enum SourceError {