MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / render_sources

Function render_sources

crates/os-runtime/build.rs:85–106  ·  view source on GitHub ↗
(sources: &[Source])

Source from the content-addressed store, hash-verified

83 };
84 for entry in entries.flatten() {
85 let path = entry.path();
86 if path.is_dir() {
87 collect_tree(&path, manifest_dir, out);
88 continue;
89 }
90 let ext = path.extension().and_then(|ext| ext.to_str());
91 if !matches!(ext, Some("hll" | "s" | "build")) {
92 continue;
93 }
94 let rel = path.strip_prefix(manifest_dir).expect("source under crate");
95 let key = rel.to_string_lossy().replace('\\', "/");
96 let rel = key.clone();
97 out.push(Source { key, rel, path });
98 }
99}
100
101fn render_tree(tree: &[Source]) -> String {
102 let mut out = String::new();
103 out.push_str("\n/// Every boot/kernel/stdlib source file keyed by crate-relative path.\n");
104 out.push_str("pub static SOURCE_TREE: &[(&str, &str)] = &[\n");
105 for source in tree {
106 writeln!(
107 out,
108 " (\"{}\", include_str!(\"{}\")),",
109 escape(&source.key),

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected