Skip to content

Commit b03d5bd

Browse files
committed
fix parsing for string defines in clang args
1 parent 652d048 commit b03d5bd

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "flash"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
edition = "2021"
55
authors = ["HJfod", "matcool"]
66
description = "Documentation generator for C++"

src/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async fn analyze_with_clang(config: Arc<Config>, args: &[String]) -> Result<(),
7777
pbar.set_message("Cleaning up files");
7878

7979
// Clean up analyzable file
80-
fs::remove_file(target_src).unwrap();
80+
// fs::remove_file(target_src).unwrap();
8181

8282
pbar.finish_using_style();
8383

src/cmake.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ pub struct CompileCommand {
1212

1313
impl CompileCommand {
1414
pub fn get_command_list(&self, config: Arc<Config>) -> Vec<String> {
15+
// regex for defines with \"\" escaping, since the slashes seem to be doubled for some reason
16+
let define_regex = regex_lite::Regex::new("^-D(.+)=\\\\\"(.+)\\\\\"$").unwrap();
17+
1518
// Not using shlex because that screws up -DFMT_CONSTEVAL=\"\"
1619
let mut list: Vec<String> = self.command.split(' ')
1720
// Skip clang.exe
@@ -32,6 +35,16 @@ impl CompileCommand {
3235
vec![s.to_owned().replace("=\"\"", "=")]
3336
}
3437
)
38+
.map(|arg| {
39+
let caps = define_regex.captures(&arg);
40+
if let Some(caps) = caps {
41+
let name = caps.get(1).unwrap().as_str();
42+
let value = caps.get(2).unwrap().as_str();
43+
format!("-D{name}=\"{value}\"")
44+
} else {
45+
arg
46+
}
47+
})
3548
// Add header root to include directories
3649
.chain(vec![format!("-I{}", config.input_dir.to_str().unwrap())])
3750
// Set working directory
@@ -47,6 +60,8 @@ impl CompileCommand {
4760
list.drain(ix..ix + 2);
4861
}
4962

63+
list.push("-ferror-limit=200".into());
64+
5065
list
5166
}
5267
}
@@ -104,6 +119,7 @@ pub fn cmake_compile_args_for(config: Arc<Config>) -> Result<Vec<String>, String
104119
return Ok(cmd.get_command_list(config));
105120
}
106121
}
122+
107123
Err(format!(
108124
"Unable to find compile args for '{}'",
109125
config.input_dir.join(from).to_string_lossy()

0 commit comments

Comments
 (0)