(state: &mut AppState)
| 78 | } |
| 79 | |
| 80 | pub fn load_project_config(state: &mut AppState) -> Result<()> { |
| 81 | let Some(project_dir) = &state.config.project_dir else { |
| 82 | return Ok(()); |
| 83 | }; |
| 84 | if let Some((result, info)) = try_project_config(project_dir.as_ref()) { |
| 85 | let project_config = result?; |
| 86 | state.config.custom_make = project_config.custom_make.clone(); |
| 87 | state.config.custom_args = project_config.custom_args.clone(); |
| 88 | state.config.target_obj_dir = project_config |
| 89 | .target_dir |
| 90 | .as_deref() |
| 91 | .map(|p| project_dir.join(p.with_platform_encoding())); |
| 92 | state.config.base_obj_dir = project_config |
| 93 | .base_dir |
| 94 | .as_deref() |
| 95 | .map(|p| project_dir.join(p.with_platform_encoding())); |
| 96 | state.config.build_base = project_config.build_base.unwrap_or(true); |
| 97 | state.config.build_target = project_config.build_target.unwrap_or(false); |
| 98 | if let Some(watch_patterns) = &project_config.watch_patterns { |
| 99 | state.config.watch_patterns = watch_patterns |
| 100 | .iter() |
| 101 | .map(|s| Glob::new(s)) |
| 102 | .collect::<Result<Vec<Glob>, globset::Error>>()?; |
| 103 | } else { |
| 104 | state.config.watch_patterns = default_watch_patterns(); |
| 105 | } |
| 106 | if let Some(ignore_patterns) = &project_config.ignore_patterns { |
| 107 | state.config.ignore_patterns = ignore_patterns |
| 108 | .iter() |
| 109 | .map(|s| Glob::new(s)) |
| 110 | .collect::<Result<Vec<Glob>, globset::Error>>()?; |
| 111 | } else { |
| 112 | state.config.ignore_patterns = default_ignore_patterns(); |
| 113 | } |
| 114 | state.watcher_change = true; |
| 115 | state.objects = project_config |
| 116 | .units |
| 117 | .as_deref() |
| 118 | .unwrap_or_default() |
| 119 | .iter() |
| 120 | .map(|o| { |
| 121 | ObjectConfig::new( |
| 122 | o, |
| 123 | project_dir, |
| 124 | state.config.target_obj_dir.as_deref(), |
| 125 | state.config.base_obj_dir.as_deref(), |
| 126 | ) |
| 127 | }) |
| 128 | .collect::<Vec<_>>(); |
| 129 | state.object_nodes = build_nodes(&mut state.objects); |
| 130 | state.current_project_config = Some(project_config); |
| 131 | state.project_config_info = Some(info); |
| 132 | if let Some(options) = |
| 133 | state.current_project_config.as_ref().and_then(|project| project.options.as_ref()) |
| 134 | { |
| 135 | let mut diff_config = DiffObjConfig::default(); |
| 136 | if let Err(e) = apply_project_options(&mut diff_config, options) { |
| 137 | log::error!("Failed to apply project config options: {e:#}"); |
no test coverage detected