Make sure VS projects order is always the same in solution
Solution file is being rewritten and reloaded by Visual Studio if projects
order changes during 'gn gen' command.
BUG=305761
Review URL: https://codereview.chromium.org/1667553003
Cr-Original-Commit-Position: refs/heads/master@{#373486}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 17be731c097793e928e8d146c0dc7c8611e856b9
diff --git a/tools/gn/visual_studio_writer.cc b/tools/gn/visual_studio_writer.cc
index 968e046..951b81d 100644
--- a/tools/gn/visual_studio_writer.cc
+++ b/tools/gn/visual_studio_writer.cc
@@ -236,6 +236,13 @@
return false;
}
+ // Sort projects so they appear always in the same order in solution file.
+ // Otherwise solution file is rewritten and reloaded by Visual Studio.
+ std::sort(writer.projects_.begin(), writer.projects_.end(),
+ [](const SolutionEntry* a, const SolutionEntry* b) {
+ return a->path < b->path;
+ });
+
writer.ResolveSolutionFolders();
return writer.WriteSolutionFile(err);
}