MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / resolve_stubs_root

Function resolve_stubs_root

build.rs:76–92  ·  view source on GitHub ↗

Locate the stubs root directory. 1. If `CARGO_MANIFEST_DIR/stubs` exists (local dev), use that. 2. Otherwise, download into `OUT_DIR/stubs` (safe during `cargo publish`).

()

Source from the content-addressed store, hash-verified

74/// 1. If `CARGO_MANIFEST_DIR/stubs` exists (local dev), use that.
75/// 2. Otherwise, download into `OUT_DIR/stubs` (safe during `cargo publish`).
76fn resolve_stubs_root() -> (PathBuf, bool) {
77 let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
78 let local_stubs = Path::new(&manifest_dir).join("stubs");
79
80 if local_stubs.join(MAP_FILE_REL).exists() {
81 // Stubs already present in source tree (normal local development).
82 // Still need to check staleness via .commit marker.
83 return (local_stubs, false);
84 }
85
86 // Stubs not in source tree — use OUT_DIR so we never modify the source
87 // directory. This is required for `cargo publish` verification.
88 let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
89 let out_stubs = Path::new(&out_dir).join("stubs");
90 let needs_fetch = !out_stubs.join(MAP_FILE_REL).exists();
91 (out_stubs, needs_fetch)
92}
93
94fn main() {
95 // Watch the project root directory so that creating/removing `stubs/`

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected