msvs: Update project sorting in visual studio solution file

In order to correctly set a default project in visual studio any folders
must be listed at the top of the solution file. This change ensures that
any folders included in generated solutions sort to the top of the .sln
file. The default project, if one exists, will be located after the
folders. Note that it should also be correct to place the default
at the top of the file, followed by any folders.
This commit is contained in:
Erik Parker 2021-03-12 10:26:06 -06:00
parent 3f8bb16329
commit 8fecd438f3
1 changed files with 5 additions and 1 deletions

View File

@ -787,8 +787,12 @@ class msvs_generator(BuildContext):
self.collect_dirs()
default_project = getattr(self, 'default_project', None)
def sortfun(x):
if x.name == default_project:
# folders should sort to the top
if getattr(x, 'VS_GUID_SOLUTIONFOLDER', None):
return ''
# followed by the default project
elif x.name == default_project:
return ' '
return getattr(x, 'path', None) and x.path.win32path() or x.name
self.all_projects.sort(key=sortfun)