(programs: &[Program])
| 244 | layout_path: Option<String>, |
| 245 | } |
| 246 | |
| 247 | impl Program { |
| 248 | fn load(build_path: &Path) -> Self { |
| 249 | println!("cargo:rerun-if-changed={}", build_path.display()); |
| 250 | let text = fs::read_to_string(build_path).expect("read .build"); |
| 251 | let manifest = fs_utils::build_manifest::parse(&text) |
| 252 | .unwrap_or_else(|err| panic!("{}: {err}", build_path.display())); |
| 253 | let dir = build_path.parent().expect("manifest parent"); |
| 254 | let field = |key: &str| { |
| 255 | manifest |
| 256 | .string(key) |
| 257 | .unwrap_or_else(|| panic!("{}: missing `{key}`", build_path.display())) |
| 258 | }; |
| 259 | |
| 260 | let name = field("name"); |
| 261 | let kind = Kind::parse(&field("kind")); |
| 262 | let source = abs(dir, &field("root")); |
| 263 | println!("cargo:rerun-if-changed={source}"); |
| 264 | let import_closure = manifest |
| 265 | .bool("import_closure") |
| 266 | .expect("import_closure") |
| 267 | .unwrap_or(true); |
| 268 | let mangle_symbols = manifest |
| 269 | .bool("mangle_symbols") |
| 270 | .expect("mangle_symbols") |
| 271 | .unwrap_or(true); |
| 272 | |
| 273 | let (layout_const, layout_path) = match manifest.get("source_prelude") { |
| 274 | Some(rel) => { |
| 275 | let path = abs(dir, rel); |
| 276 | println!("cargo:rerun-if-changed={path}"); |
| 277 | (Some(format!("{}_LAYOUT", name.to_uppercase())), Some(path)) |
| 278 | } |
| 279 | None => (None, None), |
| 280 | }; |
| 281 | |
| 282 | Self { |
| 283 | name, |
| 284 | title: field("title"), |
| 285 | description: field("description"), |
| 286 | kind, |
| 287 | install_path: manifest.string("install_path"), |
| 288 | source, |
| 289 | build_path: build_path.display().to_string(), |
| 290 | import_closure, |
| 291 | mangle_symbols, |
| 292 | layout_const, |
| 293 | layout_path, |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | fn render_userspace(programs: &[Program]) -> String { |
| 299 | let mut out = String::new(); |
| 300 | out.push_str("// @generated by build.rs from programs/user/**/*.build - do not edit.\n"); |
| 301 | |
| 302 | for program in programs { |
| 303 | let source_const = source_const_name(&program.name); |
no test coverage detected