/// <summary> /// Runs this instance. /// </summary> /// <returns></returns> public CppModule Run(CppModule groupSkeleton, string[] additionalCompilationArguments) { _group = groupSkeleton; Logger.Message("Config files changed."); const string progressMessage = "Parsing C++ headers starts, please wait..."; StreamReader xmlReader = null; try { Logger.Progress(15, progressMessage); var configRootHeader = Path.Combine(OutputPath, _configRoot.Id + ".h"); xmlReader = _gccxml.Process(configRootHeader, additionalCompilationArguments); if (xmlReader != null) { Parse(xmlReader); } Logger.Progress(30, progressMessage); } catch (Exception ex) { Logger.Error(null, "Unexpected error", ex); } finally { xmlReader?.Dispose(); // Write back GCCXML document on the disk using (var stream = File.OpenWrite(Path.Combine(OutputPath, GccXmlFileName))) { GccXmlDoc?.Save(stream); } Logger.Message("Parsing headers is finished."); } // Track number of included macros for statistics foreach (var cppInclude in _group.Includes) { IncludeMacroCounts.TryGetValue(cppInclude.Name, out int count); foreach (var cppDefine in cppInclude.Macros) { count++; } IncludeMacroCounts[cppInclude.Name] = count; } return(_group); }
/// <summary> /// Runs this instance. /// </summary> /// <returns></returns> public CppModule Run(CppModule groupSkeleton, StreamReader xmlReader) { _group = groupSkeleton; Logger.Message("Config files changed."); const string progressMessage = "Parsing C++ headers starts, please wait..."; try { Logger.Progress(15, progressMessage); if (xmlReader != null) { Parse(xmlReader); } Logger.Progress(30, progressMessage); } catch (Exception ex) { Logger.Error(null, "Unexpected error", ex); } finally { // Write back GCCXML document on the disk using (var stream = File.OpenWrite(GccXmlFileName)) { GccXmlDoc?.Save(stream); } Logger.Message("Parsing headers is finished."); } // Track number of included macros for statistics foreach (var cppInclude in _group.Includes) { IncludeMacroCounts.TryGetValue(cppInclude.Name, out var count); count += cppInclude.Macros.Count(); IncludeMacroCounts[cppInclude.Name] = count; } return(_group); }
/// <summary> /// Runs this instance. /// </summary> /// <returns></returns> public CppModule Run(CppModule groupSkeleton, string additionalArguments = "") { _group = groupSkeleton; Logger.Message("Config files changed."); const string progressMessage = "Parsing C++ headers starts, please wait..."; StreamReader xmlReader = null; try { Logger.Progress(15, progressMessage); var configRootHeader = _config.Id; // Path.Combine(OutputPath, Path.GetFileNameWithoutExtension(_config.Id)); additionalArguments += " " + String.Join(" ", _config.Include.Select(i => $"-include \"{i}\"")) + " " + String.Join(" ", _config.Macros.Select(m => $"-D{m.Key}" + (m.Value is null ? "" : $"=\"{m.Value}\""))); xmlReader = _gccxml.Process(configRootHeader, OutputPath, additionalArguments); if (xmlReader != null) { Parse(xmlReader); } Logger.Progress(30, progressMessage); } catch (Exception ex) { Logger.Error(null, "Unexpected error", ex); } finally { xmlReader?.Dispose(); // Write back GCCXML document on the disk /*using (var stream = File.OpenWrite(Path.Combine(OutputPath, GccXmlFileName))) * { * GccXmlDoc?.Save(stream); * }*/ Logger.Message("Parsing headers is finished."); } // Track number of included macros for statistics foreach (var cppInclude in _group.Includes) { IncludeMacroCounts.TryGetValue(cppInclude.Name, out int count); foreach (var cppDefine in cppInclude.Macros) { count++; } IncludeMacroCounts[cppInclude.Name] = count; } return(_group); }