public NodeStyle GetAttrs(TargetGraph.Node node) { var style = new NodeStyle(); if (node.CachePoint) { style.Penwidth = "8.0"; style.outline ??= "purple"; } if (node.Color != null) { style.Fill = node.Color; style.Style = "filled"; } if (node.Error) { style.outline = "tomato"; style.Penwidth = "8.0"; node.Color = style.Fill; } return(style); }
public NodeStyle GetAttrs(TargetGraph.Node node) { var style = new NodeStyle() { Style = "filled" }; if (node.Finished) { // was it skipped? if (!node.WasBuilt) { if (node.FromCache) { // likely skipped because of cache style.Fill = "darkgoldenrod1"; } else { // skipped because of condition style.Fill = "powderblue"; } } else { // it was actually built if (node.FromCache) { // bad! we already built this from a prior build style.outline = "tomato"; } else { // green is good: this target was supposed to be built in this config style.Fill = "lightgreen"; } } } if (node.FromCache && style.Fill == null) { // make sure we can see all the nodes that were in cache style.Fill = "lightgoldenrod1"; node.ColorEdges = false; } if (node.Started && !node.Finished || node.Error) { // build failure style.outline = "tomato"; style.Penwidth = "8.0"; node.Color = style.Fill; } return(style); }
private ProjectInstance CreateProjectInstanceImpl(string projectPath, Dictionary <string, string> globalProperties, ProjectCollection projectCollection) { var project = _cache.LoadProject(projectPath); if (project == null) { if (projectPath != _entryProjectPath) { var manifestPath = _pathMapper.ToManifestPath(projectPath); throw new ProjectCacheMissException(projectPath); } foreach (var(name, value) in projectCollection.GlobalProperties) { globalProperties[name] = value; } project = new ProjectInstance( projectPath, globalProperties, "Current", projectCollection); } else { project.LateInitialize(projectCollection.ProjectRootElementCache, null); } Environment.CurrentDirectory = project.Directory; if (_cache.Project == null && project.FullPath == _entryProjectPath) { _cache.Project = project; EntryProject = project; } if (_targetGraph != null) { var path = _pathMapper.ToBazel(projectPath); var cluster = _targetGraph.GetOrAddCluster(path, null); void AddTargets(TargetGraph.Node thisTarget, string targetString, TargetBuiltReason reason) { foreach (var beforeName in targetString.Split(";") .Where(s => !string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s))) { if (beforeName.StartsWith("$")) { var property = GetProperty(beforeName, project); if (property == null) { continue; } AddTargets(thisTarget, property.EvaluatedValue, reason); return; } var other = cluster !.GetOrAdd(beforeName); TargetGraph.Node parent = null !; TargetGraph.Node child = null !; switch (reason) { case TargetBuiltReason.BeforeTargets: parent = other; child = thisTarget; break; case TargetBuiltReason.DependsOn: case TargetBuiltReason.AfterTargets: default: parent = thisTarget; child = other; break; } parent.AddDependency(child, reason); } } foreach (var(targetName, target) in project.Targets) { var thisTarget = cluster.GetOrAdd(targetName); AddTargets(thisTarget, target.DependsOnTargets, TargetBuiltReason.DependsOn); AddTargets(thisTarget, target.AfterTargets, TargetBuiltReason.AfterTargets); AddTargets(thisTarget, target.BeforeTargets, TargetBuiltReason.BeforeTargets); foreach (var buildTask in target.Tasks) { List <string>?projects = null; switch (buildTask.Name.ToLower()) { case "msbuild": if (buildTask.Parameters.TryGetValue("Projects", out var projectsString)) { projects = projectsString.Split(";").ToList(); } else { throw new Exception(":("); } break; case "calltarget": projects = new List <string>() { "$(MSBuildProjectFullPath)" }; break; default: continue; } foreach (var projectValue in projects) { if (projectValue.Contains("RestoreGraph")) { continue; } List <string>?defaultTargets = null; Cluster targetCluster = cluster; var first = projectValue[0]; if (projectValue[1] == ':') // windows { first = '/'; } switch (first) { case '/': case '%': case '@': // these items likely won't have anything in them yet, since we haven't dont a build yet. // we'll make them a "meta" cluster var bazelPath = _pathMapper.ToBazel(projectValue); targetCluster = _targetGraph.GetOrAddCluster(bazelPath, null); break; case '$': switch (projectValue) { case "$(MSBuildProjectFullPath)": defaultTargets = project.DefaultTargets; break; case "$(MSBuildThisFileFullPath)": { var builtProject = buildTask.FullPath; var sdkIndex = builtProject.ToLower().IndexOf("sdk"); if (sdkIndex >= 0) { builtProject = builtProject[sdkIndex..]; } targetCluster = _targetGraph.GetOrAddCluster(builtProject, null); break; }