Return the stdlib as a list of (`module_name`, source) tuples for the given mode. This makes it possible to compile each HLL file independently so that `.ir`, `.s` and `.o` artifacts exist per original source file instead of concatenating everything into one big bundle.
(mode: TargetMode)
| 12 | let manifest = fs_utils::build_manifest::parse(STDLIB_BUILD).expect("parse stdlib.build"); |
| 13 | let key = match mode { |
| 14 | TargetMode::Hosted => "hosted", |
| 15 | TargetMode::Freestanding => "freestanding", |
| 16 | TargetMode::Kernel => "kernel", |
| 17 | }; |
| 18 | let entries = manifest |
| 19 | .list(key) |
| 20 | .expect("parse stdlib module list") |
| 21 | .unwrap_or_else(|| panic!("stdlib.build missing `{key}` list")); |
| 22 | |
| 23 | entries |
| 24 | .into_iter() |
| 25 | .map(|entry| { |
| 26 | let (name, source_key) = parse_module_entry(&entry); |
| 27 | let source = os_runtime::module_source(source_key) |
| 28 | .unwrap_or_else(|| panic!("stdlib.build references unknown module `{source_key}`")); |
| 29 | (leak(name), source) |
| 30 | }) |
| 31 | .collect() |
| 32 | } |
| 33 | |
| 34 | /// Repo-relative source path of stdlib module `name` in `mode`, for the |
| 35 | /// pc-to-source line table. `None` when the module or its path is unknown. |
| 36 | pub fn stdlib_module_source_path(mode: TargetMode, name: &str) -> Option<&'static str> { |
| 37 | let manifest = fs_utils::build_manifest::parse(STDLIB_BUILD).ok()?; |
| 38 | let key = match mode { |