public int RunProcess(Project proj, string app, string args, string workDir, bool redirectOutput) { proc = new Process() { EnableRaisingEvents = true, StartInfo = new ProcessStartInfo(app, args) { WorkingDirectory = workDir, RedirectStandardOutput = redirectOutput, RedirectStandardError = redirectOutput, UseShellExecute = !redirectOutput, CreateNoWindow = true, } }; string debugString = (workDir ?? String.Empty) + ">" + app + " " + (args ?? String.Empty); builder.AppendLog(debugString); proc.EnableRaisingEvents = true; if (redirectOutput) { proc.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) { if (proj != null) proj.AppendLog(e.Data); else builder.AppendLog(e.Data); }; } proc.Start(); if (redirectOutput) proc.BeginOutputReadLine(); proc.WaitForExit(); int retCode = proc.ExitCode; if (redirectOutput && retCode != 0) { string error = proc.StandardError.ReadToEnd(); if (!String.IsNullOrEmpty(error)) builder.AppendLog("Error: " + error); } proc.Dispose(); proc = null; return retCode; }
private void GenerateTableForProjects(Project[] projs) { var table = new DataTable(); // Generate columns var columns = new DataColumn[projs.Length + 1]; columns[0] = new DataColumn(@"Projects\Deps"); columns[0].DataType = typeof(string); for (int i = 0; i < projs.Length; i++) { columns[i + 1] = new DataColumn(projs[i].Name); columns[i + 1].DataType = typeof(ProjectDependency); } table.Columns.AddRange(columns); // Generate rows for (int i = 0; i < projs.Length; i++) { DataRow row = table.NewRow(); row[0] = columns[i + 1].ColumnName; for (int j = 0; j < projs.Length; j++) { if (j == i) { row[j + 1] = ProjectDependency.Invalid; } else { //row[j + 1] = projs[i].DepProjects.Has(projs[j]) ? ProjectDependency.Direct : DataGridViewTriState.False; ProjectDependency dep = ProjectDependency.None; if (projs[i].DepProjects.Has(projs[j])) dep = ProjectDependency.Direct; else if (projs[i].ProjectTree.Has(projs[j])) dep = ProjectDependency.Indirect; else if (projs[i].Parents.Has(projs[j])) dep = ProjectDependency.Invalid; else dep = ProjectDependency.None; row[j + 1] = dep; } } table.Rows.Add(row); } MatrixDataGridView.DataSource = table; MatrixDataGridView.ColumnHeadersHeight = 10; // resize columns MatrixDataGridView.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; for (int i = 1; i < columns.Length; i++) { MatrixDataGridView.Columns[i].Width = box_size + 2 * box_offset; } }
public static void ParseSolution(string solutionSource, bool isUpdate) { string solutionDir = new FileInfo(solutionSource).Directory.FullName; if (ProjTable == null || !isUpdate) { ProjTable = new Dictionary<string, Project>(); } else { foreach (Project proj in ProjTable.Values) { proj.ClearDepGraph(); } } // Parse deps from solution Dictionary<string, Project> guidTable = new Dictionary<string, Project>(); Project currentProj = null; bool projectDepencenciesSection = false; foreach (string rawLine in File.ReadAllLines(solutionSource)) { string line = rawLine.Trim(); if (line.StartsWith("# Visual Studio")) { // # Visual Studio 2010 string[] s1 = line.Split(' '); VSVersion = s1[3]; } if (line.StartsWith("Project(")) { // Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EtlViewRealTimeTest", "..\Tools\EtlViewRealTimeTest\EtlViewRealTimeTest.vcxproj", "{3DC6B51F-56DB-4207-8AB6-EAAA78DBBBF3}" string[] s1 = line.Split('='); string ProjectTypeGUID = s1[0].Split('\"')[1].ToUpper(); string[] s2 = s1[1].Split(','); char[] trim_chars = new char[] { '\"', ' ' }; string projectName = s2[0].Trim(trim_chars); string projectPath = s2[1].Trim(trim_chars); string projectGUID = s2[2].Trim(trim_chars).ToUpper(); Project proj = null; if (ProjectTypeGUID == CPP_PROJECT_TYPE_GUID) { if (isUpdate) proj = ProjTable.Values.FirstOrDefault(p => p.GUID == projectGUID); if (proj == null) proj = new Project(projectName, Path.Combine(solutionDir, projectPath), projectGUID, false); guidTable[projectGUID] = proj; } currentProj = proj; continue; } if (line == "EndProject") { currentProj = null; continue; } if (currentProj != null) { if (line.StartsWith("ProjectSection(")) { // ProjectSection(ProjectDependencies) = postProject string[] s1 = line.Split('='); char[] split_chars = new char[] { '(', ')' }; string sectionName = s1[0].Split(split_chars)[1]; string sectionStage = s1[1].Trim(); if (sectionName == "ProjectDependencies") projectDepencenciesSection = true; continue; } if (line == "EndProjectSection") { projectDepencenciesSection = false; continue; } if (projectDepencenciesSection) { // {2901AF0B-7C78-4256-AE90-83C078387FD1} = {2901AF0B-7C78-4256-AE90-83C078387FD1} string[] s1 = line.Split('='); string projectGUID = s1[0].Trim().ToUpper(); string projectGUID2 = s1[1].Trim().ToUpper(); currentProj.AddDepGUID(projectGUID); continue; } } } // Parse deps from project files // NOTE: External dependencies are only for graph presentation and are excluded from check builds foreach (Project proj in guidTable.Values.ToArray()) { ParseProject(proj, guidTable); } // Resolve deps foreach (Project proj in guidTable.Values) { if (!isUpdate) { // Unify project name on collision string originalName = proj.Name; int index = 0; while (ProjTable.ContainsKey(proj.Name)) { proj.Name = String.Format("{0}[{1}]", originalName, ++index); } ProjTable.Add(proj.Name, proj); } proj.ResolveDeps(guidTable); } }
private static void ParseProject(Project proj, Dictionary<string, Project> guidTable) { try { string fileContent = File.ReadAllText(proj.File.FullName); string projectDir = proj.File.Directory.FullName; using (XmlReader reader = XmlReader.Create(new StringReader(fileContent))) { while (reader.ReadToFollowing("ProjectReference")) { reader.MoveToAttribute("Include"); string projectPath = reader.Value; if (reader.ReadToFollowing("Project")) { string projectGUID = reader.ReadElementContentAsString().ToUpper(); Project depProj; if (!guidTable.TryGetValue(projectGUID, out depProj)) { // Create external project FileInfo projectFile = new FileInfo(Path.Combine(projectDir, projectPath)); string projectName = Path.GetFileNameWithoutExtension(projectFile.Name); depProj = new Project(projectName, projectFile.FullName, projectGUID, true); guidTable[projectGUID] = depProj; } proj.AddDepGUID(projectGUID); } } } } catch(Exception e) { MessageBox.Show(e.ToString(), "Parse Project", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public int RunProcess(Project proj, string app, string args, string workDir) { return RunProcess(proj, app, args, workDir, true); }
public int RunProcess(Project proj, string app, string args) { return RunProcess(proj, app, args, null, true); }
public static bool Has(this List<Project> projects, Project proj) { return projects.Exists(p => p.Name == proj.Name); }
public static bool AddUnique(this List<Project> projects, Project proj) { if (!projects.Has(proj)) { projects.Add(proj); return true; } return false; }
private string ProjectStatusColor(Project proj) { if (proj.IsExternal) return "lightcyan"; if (proj.Status == Project.BuildStatus.Wait) return "gray"; if (proj.Status == Project.BuildStatus.Progress) return "skyblue"; if (proj.Status == Project.BuildStatus.Success) return "palegreen"; if (proj.Status == Project.BuildStatus.Failed) return "tomato"; return "white"; }