public override bool Execute() { var psi = new ProcessStartInfo { UseShellExecute = false }; if (TargetTypeExecutable.Equals(TargetType, StringComparison.OrdinalIgnoreCase)) { psi.FileName = Target; psi.Arguments = Arguments; } else { // We need the active environment to run these commands. ResolveEnvironment resolver = new ResolveEnvironment(ProjectPath, BuildEngine); if (!resolver.Execute()) { return(false); } psi.FileName = resolver.InterpreterPath; if (TargetTypeModule.Equals(TargetType, StringComparison.OrdinalIgnoreCase)) { psi.Arguments = string.Format("-m {0} {1}", Target, Arguments); } else if (TargetTypeScript.Equals(TargetType, StringComparison.OrdinalIgnoreCase)) { psi.Arguments = string.Format("\"{0}\" {1}", Target, Arguments); } else if (TargetTypeCode.Equals(TargetType, StringComparison.OrdinalIgnoreCase)) { psi.Arguments = string.Format("-c \"{0}\"", Target); } // If no search paths are read, this is set to an empty string // to mask any global setting. psi.EnvironmentVariables[resolver.PathEnvironmentVariable] = string.Join(";", resolver.SearchPaths); } psi.WorkingDirectory = WorkingDirectory; if (!string.IsNullOrEmpty(Environment)) { foreach (var line in Environment.Split('\r', '\n')) { int equals = line.IndexOf('='); if (equals > 0) { psi.EnvironmentVariables[line.Substring(0, equals)] = line.Substring(equals + 1); } } } if (ExecuteInNone.Equals(ExecuteIn, StringComparison.OrdinalIgnoreCase)) { psi.CreateNoWindow = true; psi.WindowStyle = ProcessWindowStyle.Hidden; } else if (ExecuteInConsolePause.Equals(ExecuteIn, StringComparison.OrdinalIgnoreCase)) { psi.Arguments = string.Format( "/C \"\"{0}\" {1}\" & pause", psi.FileName, psi.Arguments ); psi.FileName = PathUtils.GetAbsoluteFilePath(System.Environment.SystemDirectory, "cmd.exe"); } psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; using (var process = Process.Start(psi)) { process.OutputDataReceived += Process_OutputDataReceived; process.ErrorDataReceived += Process_ErrorDataReceived; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); return(process.ExitCode == 0); } }
static void Main(string[] args) { var input = new Dictionary <string, GlobalDecl>(); for (int i = 0; i < args.Length / 2; i++) { var tag = args[i * 2]; var fileName = args[i * 2 + 1]; Console.WriteLine("Reading " + fileName + " ..."); var xml = XDocument.Load(fileName); var decl = (GlobalDecl)SymbolDecl.Deserialize(xml.Root); decl.BuildSymbolTree(null, tag); input.Add(tag, decl); } Console.WriteLine("De-duplicating ..."); var symbolGroup = new Dictionary <string, List <SymbolDecl> >(); GroupSymbolsByOverloadKey(input.Values, symbolGroup); foreach (var pair in symbolGroup) { var groups = pair.Value .GroupBy(x => x.ContentKey) .ToArray(); foreach (var group in groups) { var decls = group.ToArray(); var tags = decls .Select(x => x.Tags) .OrderBy(x => x) .Aggregate((a, b) => a + ";" + b); foreach (var decl in decls) { decl.Tags = tags; } } } Console.WriteLine("Resolving Symbols ..."); var symbolResolving = symbolGroup .SelectMany(x => x.Value) .ToArray(); var environment = new ResolveEnvironment(input.Values); foreach (var symbol in symbolResolving) { symbol.Resolve(environment); } var output = args[args.Length - 1]; var xmlErrors = environment.Errors.Where(x => x.StartsWith("(Xml)")).ToArray(); var warnings = environment.Errors.Where(x => x.StartsWith("(Warning)")).ToArray(); var errors = environment.Errors.Where(x => x.StartsWith("(Error)")).ToArray(); Console.WriteLine("Xml Errors: " + xmlErrors.Length); Console.WriteLine("Warnings: " + warnings.Length); Console.WriteLine("Errors: " + errors.Length); using (var writer = new StreamWriter(output + ".errors.txt", false, Encoding.UTF8)) { writer.WriteLine("=======================XML ERROR======================="); foreach (var message in xmlErrors) { writer.WriteLine(message); } writer.WriteLine(); writer.WriteLine("========================WARNING========================"); foreach (var message in warnings) { writer.WriteLine(message); } writer.WriteLine(); writer.WriteLine("=========================ERROR========================="); foreach (var message in errors) { writer.WriteLine(message); } } Console.WriteLine("Saving ..."); var symbolSaving = symbolGroup .ToDictionary( x => x.Key, x => x.Value .GroupBy(y => y.Tags) .Select(y => y.First()) .ToArray() ) .GroupBy(x => GetNamespaceSymbol(x.Value.First())) .ToDictionary( x => x.Key, x => x.ToDictionary( y => y.Key, y => y.Value ) ) ; var outputXml = new XDocument( new XElement("CppXmlDocument", symbolSaving.Select(x => new XElement("Namespace", new XAttribute("Name", x.Key is GlobalDecl ? "" : (x.Key as NamespaceDecl).NameKey), x.Value.Select(y => new XElement("Symbol", new XAttribute("OverloadKey", y.Key), y.Value .Select(z => z.Parent is TemplateDecl ? z.Parent : z) .Select(z => z.Serialize()) )) )) ) ); outputXml.Save(output); }