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

Function render_source_files

build.rs:111–132  ·  view source on GitHub ↗
(sources: &[SourceFile])

Source from the content-addressed store, hash-verified

109 let mut programs: Vec<Program> = build_files.iter().map(|path| Program::load(path)).collect();
110 programs.sort_by(|a, b| (a.kind.rank(), &a.name).cmp(&(b.kind.rank(), &b.name)));
111
112 let programs_dir = manifest_dir.join("programs");
113 println!("cargo:rerun-if-changed={}", programs_dir.display());
114 let mut source_files = Vec::new();
115 collect_source_files(&programs_dir, manifest_dir, &mut source_files);
116 source_files.sort_by(|a, b| a.key.cmp(&b.key));
117
118 let mut code = render_userspace(&programs);
119 code.push_str(&render_source_files(&source_files));
120 fs::write(out_dir.join("userspace.rs"), code).expect("failed to write userspace.rs");
121}
122
123// Walk `programs/` for embeddable sources keyed by repo-relative path: every `.hll`,
124// plus build and lowering files used by the demo and lesson workspaces.
125fn collect_source_files(dir: &Path, manifest_dir: &Path, out: &mut Vec<SourceFile>) {
126 let Ok(entries) = fs::read_dir(dir) else {
127 return;
128 };
129 for entry in entries.flatten() {
130 let path = entry.path();
131 if path.is_dir() {
132 if path.file_name().and_then(|name| name.to_str()) == Some("demo_workspace") {
133 continue;
134 }
135 collect_source_files(&path, manifest_dir, out);

Callers 1

generate_userspaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected