diff --git a/compiler/mesh-codegen/src/link.rs b/compiler/mesh-codegen/src/link.rs index f5d3cae1..cfda8b92 100644 --- a/compiler/mesh-codegen/src/link.rs +++ b/compiler/mesh-codegen/src/link.rs @@ -200,6 +200,14 @@ pub(crate) fn link_with_plan( /// profiles. Prefers the profile matching the compiler's own build: a release /// `meshc` links the release runtime, a debug `meshc` links the debug runtime. fn find_mesh_rt(target: &LinkTarget) -> Result { + // ENV override (highest priority) + if let Ok(path) = std::env::var("MESH_RT_PATH") { + let path = PathBuf::from(path); + if path.exists() { + return Ok(path); + } + } + let profiles: &[&str] = if cfg!(debug_assertions) { &["debug", "release"] } else { @@ -217,6 +225,49 @@ fn find_mesh_rt(target: &LinkTarget) -> Result { } } + // NEW: fallback directories + let mut extra_dirs: Vec = Vec::new(); + + // ~/.mesh/lib + if let Some(home) = std::env::var_os("HOME") { + extra_dirs.push(PathBuf::from(home).join(".mesh/lib")); + } + + // current working directory + if let Ok(current) = std::env::current_dir() { + extra_dirs.push(current); + } + + // directory of meshc binary + if let Ok(exe) = std::env::current_exe() { + if let Some(parent) = exe.parent() { + extra_dirs.push(parent.to_path_buf()); + } + } + + // search fallback dirs + for dir in extra_dirs { + // check profile-based structure + for profile in profiles { + let candidate = dir.join(profile).join(target.runtime_filename()); + + if candidate.exists() { + return Ok(candidate); + } + + searched_paths.push(candidate); + } + + // check direct file + let direct = dir.join(target.runtime_filename()); + if direct.exists() { + return Ok(direct); + } + + searched_paths.push(direct); + } + + // error message (unchanged) let mut message = format!( "Could not locate Mesh runtime static library for target '{}'. Expected {}. Run `cargo build -p mesh-rt{}` first.", target.display_triple(), diff --git a/website/package.json b/website/package.json index 6b3d2fec..147d19ae 100644 --- a/website/package.json +++ b/website/package.json @@ -7,7 +7,7 @@ "dev": "vitepress dev docs", "build": "vitepress build docs", "preview": "vitepress preview docs", - "generate:og": "python3 scripts/generate-og-image.py" + "generate:og": "python3 scripts/generate-og-image.py || (echo Python is not installed. Please install it from https://www.python.org/downloads/ and try again. && exit 1)" }, "keywords": [], "author": "", @@ -31,4 +31,4 @@ "@types/node": "^25.2.3", "typescript": "^5.9.3" } -} +} \ No newline at end of file