(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame)
| 977 | StdlibPolicy::Explicit(mode) => Some(mode), |
| 978 | }; |
| 979 | |
| 980 | let mut manifest = manifest.clone(); |
| 981 | // Build from the live editor buffer, not the on-disk file. |
| 982 | manifest.root = BuildSource::inline_with_path( |
| 983 | manifest.name.clone(), |
| 984 | source.to_owned(), |
| 985 | std::path::PathBuf::from(path), |
| 986 | ); |
| 987 | manifest.write_artifacts = false; |
| 988 | // Inject the cached stdlib objects instead of recompiling them each keystroke. |
| 989 | manifest.stdlib = StdlibPolicy::None; |
| 990 | if let Some(mode) = stdlib_mode { |
| 991 | let stdlib = self |
| 992 | .stdlib_objects_for(mode) |
| 993 | .ok_or_else(|| "stdlib build failed".to_owned())? |
| 994 | .to_vec(); |
| 995 | manifest.extra_objects = stdlib |
| 996 | .into_iter() |
| 997 | .map(|(name, assembled)| BuildObject { name, assembled }) |
| 998 | .collect(); |
| 999 | } |
| 1000 | |
| 1001 | match BuildExecutor::build(&manifest) { |
| 1002 | Ok(artifacts) => Ok(BinaryOutput { |
| 1003 | assembled: artifacts.linked, |
| 1004 | }), |
| 1005 | Err(BuildError::Link(err)) => Err(format!("linker error: {}", err.message)), |
| 1006 | Err(err) => Err(err.to_string()), |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | pub(super) fn refresh_build_target(&mut self) { |
| 1011 | let Some(active_path) = self.active_path() else { |
| 1012 | self.active_build_target = None; |
| 1013 | return; |
| 1014 | }; |
| 1015 | self.active_build_target = self.find_build_target_for(&active_path); |
| 1016 | } |
| 1017 | |
| 1018 | fn find_build_target_for(&self, path: &VPath) -> Option<BuildTarget> { |
| 1019 | let manifest_path = if path.as_str().ends_with(".build") { |
| 1020 | path.clone() |
| 1021 | } else { |
| 1022 | self.find_nearest_build_manifest(path)? |
| 1023 | }; |
| 1024 | self.build_target_from_manifest(manifest_path) |
| 1025 | } |
| 1026 | |
| 1027 | fn build_target_from_manifest(&self, manifest_path: VPath) -> Option<BuildTarget> { |
| 1028 | let manifest = self.workspace.load_manifest(&manifest_path).ok()?; |
| 1029 | let root_path = match manifest.root { |
| 1030 | BuildSource::Inline { |
| 1031 | source_path: Some(path), |
| 1032 | .. |
| 1033 | } |
| 1034 | | BuildSource::Path { path, .. } => VPath::parse(&path.display().to_string()).ok()?, |
| 1035 | BuildSource::Inline { .. } => return None, |
| 1036 | }; |
no test coverage detected