private void parsefile(string file) { if (File.Exists(file)) { StreamReader reader = new StreamReader(file); string content = reader.ReadToEnd(); string[] elements = content.Split(' '); CommandLineparser p = new CommandLineparser(); p.Init(); p.parseOptions(elements); updateModel(p); } }
public ProjectModel Fac_getProjectModel(string[] args) { model = new ProjectModel(); CommandLineparser parser = new CommandLineparser(); parser.Init(); parser.parseOptions(args); if (args.Length == 0) { return(null); } else if (args.Length > 0) { if (parser.CommandLineOptions["-file"].Count > 0) { foreach (string f in parser.CommandLineOptions["-file"]) { parsefile(f); } } else { updateModel(parser); } foreach (string path in model.IncludePaths) { path.Replace('/', '\\'); } foreach (string path in model.CommonHeaders) { path.Replace('/', '\\'); } foreach (string path in model.LibraryPaths) { path.Replace('/', '\\'); } model.IncludePaths = model.IncludePaths.Distinct <string>().ToList(); model.CommonHeaders = model.CommonHeaders.Distinct <string>().ToList(); foreach (string path in model.IncludePaths) { if (Directory.Exists(path)) { model.HeaderFiles.AddRange(Directory.GetFiles(path, "*.h", SearchOption.TopDirectoryOnly)); } } foreach (string path in model.SourcePaths) { if (File.Exists(path)) { model.SourceFiles.Add(path); } } model.SourceFiles = model.SourceFiles.Distinct().ToList(); if (model.IncludePaths.Count == 0) { model.HeaderFiles.AddRange(Directory.GetFiles(model.RootDir.Trim(), "*.h", SearchOption.AllDirectories)); foreach (string file in model.HeaderFiles) { DirectoryInfo di = new DirectoryInfo(file); while (di.FullName != model.RootDir) { di = di.Parent; model.IncludePaths.Add(di.FullName); } } model.IncludePaths = model.IncludePaths.Distinct().ToList(); } if (model.SourcePaths.Count == 0) { model.SourceFiles.AddRange(Directory.GetFiles(model.RootDir.Trim(), "*.c", SearchOption.AllDirectories)); foreach (string file in model.SourceFiles) { DirectoryInfo di = new DirectoryInfo(file); while (di.FullName != model.RootDir) { di = di.Parent; model.IncludePaths.Add(di.FullName); } } model.IncludePaths = model.IncludePaths.Distinct().ToList(); } model.HeaderFiles = model.HeaderFiles.Distinct().ToList(); model.SourceFiles = model.SourceFiles.Distinct().ToList(); } Updateclangoptions(); updateSwcConfig(); return(model); }