@@ -12,6 +12,9 @@ pub struct CompileCommand {
1212
1313impl 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