only deal one file onces

This commit is contained in:
ouczbs 2024-06-26 19:30:02 +08:00
parent d0be43ef70
commit ce7f5bf520

View File

@ -59,18 +59,13 @@ namespace refl
}
return parse;
}
public static List<string> PrepareFileList(List<string> file_list)
public static string PreprocessFile(string file_path)
{
StringBuilder code = new StringBuilder();
foreach (var file in file_list)
{
string fileContent = File.ReadAllText(file);
code.AppendLine(fileContent.Replace("#include", "//#include"));
}
file_list.Clear();
file_list.Add(InputFile);
string fileContent = File.ReadAllText(file_path);
code.AppendLine(fileContent.Replace("#include", "//#include"));
File.WriteAllText(InputFile, code.ToString());
return file_list;
return InputFile;
}
public static int CMD_CheckBuildOption(CmdBuildOption opt)
{
@ -89,7 +84,12 @@ namespace refl
{
file_list = opt.InputFiles.Skip(1).ToList();
}
var compilation = CppAst.CppParser.ParseFiles(PrepareFileList(file_list), parse_opt);
int index = file_list.Count - 1;
if(index >= 0)
{
file_list[index] = PreprocessFile(file_list[index]);
}
var compilation = CppAst.CppParser.ParseFiles(file_list, parse_opt);
if (opt.Verbose)
{
// Print diagnostic messages