-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add /graph:noBuild #6016
Add /graph:noBuild #6016
Conversation
@rainersigwald I added a record type with init properties and it seems the CI is using an older compiler that does not recognize these. Is it fairly easy to get CI updated, or should I replace the records with manual equals / hashcode implementations? 😢 |
I bet the update to Arcade 5/.NET 5 SDK will handle that. @benvillalobos is pretty close on that so I wouldn't rewrite. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- should we fork for 16.9 so we have a place to land this?
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
|
||
while (blockedNodes.Count > 0 || buildingNodes.Count > 0) | ||
{ | ||
waitHandle.WaitOne(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused here. It looks like the waitHandle receives signals below, but how would it ever get there if the thread is paused indefinitely here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just an extracted method, not new logic, you can skip it if you wish. To answer your question, whenever there's potential new work to do the waitHandle gets signaled. Check out all the places in the method that call Set() on that waitHandle.
317f2d5
to
25ba2ed
Compare
@radical, do you know how to update the compilers in the Mono CI to a new enough version to parse C# record types? CI is currently failing because of that: https://dev.azure.com/dnceng/public/_build/results?buildId=959029&view=logs&j=09f5a607-bbad-5164-6b70-f20ebe806390&t=64b2bbfe-7647-5e20-2e5f-fab3af842098 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -7,6 +7,14 @@ | |||
|
|||
namespace Microsoft.Build.Graph | |||
{ | |||
public record GraphBuildOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make this a record if it only has one thing in it? It seems like it's making it unnecessarily complicated, since then in addition to checking whether it's null, you need to check whether .Build is true or false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there will be more things in it in the future and since MSBuild APIs are set in stone until the end of time I'd rather start with a 1 member record than successive API changes that progressively add yet another public constructor with yet another parameter followed eventually by an actual struct. Basically avoiding the fiasco with the Project constructors which got eventually followed by ProjectOptions.
using var cacheService = cacheServiceTask.Result; | ||
if (submission.BuildRequestData.GraphBuildOptions.Build) | ||
{ | ||
var cacheServiceTask = Task.Run(() => SearchAndInitializeProjectCachePluginFromGraph(projectGraph)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity—why did you reorder these? Shouldn't matter either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pedantism. Put the task which I think takes the longest first. Thread can loose context right before issuing the second task so might as well have the longest running one first.
/// <summary> | ||
/// If false, the graph is constructed but the nodes are not built. | ||
/// </summary> | ||
public bool Build { get; init; } = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't familiar with this, and it looks like it's too new for mono. Might change it to set { init; return whatever; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mono will get eventually updated and until then we'll just disable it. See #6059
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM! Pending build errors & questions
@@ -1233,7 +1233,7 @@ string outputResultsCache | |||
|
|||
if (!restoreOnly) | |||
{ | |||
if (graphBuild) | |||
if (graphBuildOptions != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& graphBuildOptions.Build
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
graphBuildOptions.Build
gets acted upon later on in the BuildManager, after the graph is constructed. That's the whole point, construct the graph but not build it.
|
||
if (parameter.Trim().Equals("NoBuild", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
options = options with {Build = false}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this data structure be a record if we actually want to be able to set the value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should it not be a record?
[Fact] | ||
public void GraphBuildShouldBeAbleToConstructGraphButSkipBuild() | ||
{ | ||
var graph = Helpers.CreateProjectGraph(_env, new Dictionary<int, int[]> {{1, new[] {2, 3}}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: list out parameter names to make it easier to read. You did it just below this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random question: Any worry about this method being passed invalid data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a helper method for tests, if it's passed invalid data some test somewhere will fail.
|
||
IReadOnlyDictionary<ProjectGraphNode, ImmutableList<string>> targetLists = targetListTask.Result; | ||
using var cacheService = cacheServiceTask.Result; | ||
if (submission.BuildRequestData.GraphBuildOptions.Build) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a null check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GraphBuildRequestData
constructors ensures it's never null.
And the build error is because the mono build doesn't have an updated version of roslyn. Resolved by #6059 (admittedly not ideally—by updating roslyn for mono—but by disabling it). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
This new option constructs the graph but does not build the nodes.
This is useful for a few use cases: