Skip to content

Commit

Permalink
internal: add $mod_dir and $pkg_dir for pre-build command
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Nov 28, 2024
1 parent ed710c1 commit 8e6c163
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions crates/moonbuild/src/pre_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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(" "))
Expand Down
2 changes: 0 additions & 2 deletions crates/mooncake/src/pkg/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 `{}`",
Expand Down
2 changes: 2 additions & 0 deletions crates/moonutil/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8e6c163

Please sign in to comment.