Skip to content

Commit

Permalink
Add more details when we can't find the sources
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Dec 6, 2024
1 parent 1e9d887 commit a04f54e
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions dylo-runtime/src/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,22 @@ fn get_paths(mod_name: &str) -> Paths {
None
}

let mod_srcdir = find_mod_dir(base_dir, mod_name)
.unwrap_or_else(|| panic!("Could not find mod source directory for mod {mod_name}"));
let mod_srcdir = match find_mod_dir(base_dir, mod_name) {
Some(dir) => dir,
None => {
eprintln!("❌ ================================================");
eprintln!("🚫 Error looking for source directory for module:");
eprintln!(" 🔍 Module: \x1B[36m{mod_name}\x1B[0m");
eprintln!(" 📂 Base dir: \x1B[33m{}\x1B[0m", base_dir.display());
eprintln!("================================================");
eprintln!();
eprintln!("📦 \x1B[1mdylo\x1B[0m (https://github.com/bearcove/dylo) is a dynamic loading solution");
eprintln!("🔧 that expects to find Rust source code for modules in a '\x1B[32mmod-{mod_name}\x1B[0m' directory,");
eprintln!(" or a pre-compiled library if builds are disabled via \x1B[35mDYLO_BUILD=0\x1B[0m");
eprintln!("================================================");
panic!("💥 Could not find source directory for module: {mod_name}");
}
};
let cargo_target_dir = get_target_dir(mod_name);

Paths {
Expand Down Expand Up @@ -138,6 +152,11 @@ fn spawn_reader_thread(
}

fn build_mod(mod_name: &'static str) {
let build_mode = BuildMod::from_env();
if !build_mode.should_build() {
return;
}

let extensions = Extensions::get();
let paths = get_paths(mod_name);
let build_profile = if cfg!(debug_assertions) {
Expand All @@ -147,11 +166,6 @@ fn build_mod(mod_name: &'static str) {
};

let before_build = Instant::now();
let build_mode = BuildMod::from_env();

if !build_mode.should_build() {
return;
}

let current_exe_path = std::env::current_exe().expect("Failed to get current executable path");
let current_exe_folder = current_exe_path.parent().unwrap();
Expand Down

0 comments on commit a04f54e

Please sign in to comment.