Skip to content

Commit

Permalink
make cmake_compile_args_for return Result instead of Option
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Jan 27, 2023
1 parent 6dd2df8 commit 08b43ac
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/cmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ pub fn cmake_compile_commands(config: Arc<Config>) -> Result<CompileCommands, St
.map_err(|e| format!("Unable to parse compile_commands.json: {e}"))
}

pub fn cmake_compile_args_for(config: Arc<Config>) -> Option<Vec<String>> {
let from = &config.cmake.as_ref()?.infer_args_from;
for cmd in cmake_compile_commands(config.clone()).ok()? {
pub fn cmake_compile_args_for(config: Arc<Config>) -> Result<Vec<String>, String> {
let from = &config.cmake.as_ref()
.ok_or(String::from("Project does not use CMake"))?
.infer_args_from;
for cmd in cmake_compile_commands(config.clone())? {
if cmd.file == config.input_dir.join(from) {
return Some(cmd.get_command_list(config));
return Ok(cmd.get_command_list(config));
}
}
None
Err(format!("Unable to find compile args for '{}'", from.to_string_lossy()))
}

0 comments on commit 08b43ac

Please sign in to comment.