Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions compiler/mesh-codegen/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf, String> {
// 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 {
Expand All @@ -217,6 +225,49 @@ fn find_mesh_rt(target: &LinkTarget) -> Result<PathBuf, String> {
}
}

// NEW: fallback directories
let mut extra_dirs: Vec<PathBuf> = 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(),
Expand Down
4 changes: 2 additions & 2 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand All @@ -31,4 +31,4 @@
"@types/node": "^25.2.3",
"typescript": "^5.9.3"
}
}
}
Loading