Skip to content

Commit fc61562

Browse files
File resolve and globbing improvements: (#438)
- Correctly resolve NatvisFiles, ResourceFiles, NoneFiles, etc. relative to SourceRootPath just like SourceFiles in the case that these files are not automatically gathered via globbing but rather directly initialized in a project constructor. - Ensure that .natvis globbing as well as globbing of some other file extensions works based on having the corresponding extensions specified, such as in NatvisFilesExtensions. Currently the code ignore these incorrectly. - Speed up generating the debug solution/project by disabling globbing fully for the debug project, so for all extensions that trigger globbing. Co-authored-by: Martin Ecker <me@martinecker.com>
1 parent 3e6c589 commit fc61562

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

Sharpmake/Project.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,30 @@ internal virtual void ResolveSourceFiles(Builder builder)
900900
NoneExtensions.RemoveAll(s => NoneExtensionsCopyIfNewer.Contains(s));
901901
}
902902

903+
var extensionContainers = new[]
904+
{
905+
SourceFilesExtensions,
906+
ResourceFilesExtensions,
907+
PRIFilesExtensions,
908+
NatvisFilesExtensions,
909+
NoneExtensions,
910+
NoneExtensionsCopyIfNewer,
911+
ProtoExtensions
912+
};
913+
914+
// The code below does an expensive glob to get source files, which when generating the
915+
// debug project will have to scan a potentially large depot tree and takes a long time
916+
// Clear all extensions to not do the file scanning for the debug project.
917+
if (this is DebugProject)
918+
{
919+
foreach (var container in extensionContainers)
920+
{
921+
container.Clear();
922+
}
923+
}
924+
903925
// Only scan directory for files if needed
904-
if (SourceFilesExtensions.Count != 0 || ResourceFilesExtensions.Count != 0 || PRIFilesExtensions.Count != 0 || NoneExtensions.Count != 0 || NoneExtensionsCopyIfNewer.Count != 0)
926+
if (extensionContainers.Any(container => container.Count != 0))
905927
{
906928
string capitalizedSourceRootPath = Util.GetCapitalizedPath(SourceRootPath);
907929

@@ -1912,6 +1934,13 @@ internal virtual void Resolve(Builder builder, bool skipInvalidPath)
19121934
Util.ResolvePath(SourceRootPath, ref SourceFilesExclude);
19131935
Util.ResolvePath(SourceRootPath, ref SourceFilesBlobExclude);
19141936
Util.ResolvePath(SourceRootPath, ref SourceFilesBuildExclude);
1937+
Util.ResolvePath(SourceRootPath, ref PRIFiles);
1938+
Util.ResolvePath(SourceRootPath, ref ResourceFiles);
1939+
Util.ResolvePath(SourceRootPath, ref NatvisFiles);
1940+
Util.ResolvePath(SourceRootPath, ref NoneFiles);
1941+
Util.ResolvePath(SourceRootPath, ref NoneFilesCopyIfNewer);
1942+
Util.ResolvePath(SourceRootPath, ref ProtoFiles);
1943+
19151944
Util.ResolvePath(SharpmakeCsPath, ref _blobPath);
19161945

19171946
if (SourceFilesFilters != null)
@@ -2046,6 +2075,10 @@ public FastBuildAllProject(Type targetType)
20462075
SourceFilesExtensions.Clear();
20472076
ResourceFilesExtensions.Clear();
20482077
PRIFilesExtensions.Clear();
2078+
NatvisFilesExtensions.Clear();
2079+
NoneExtensions.Clear();
2080+
NoneExtensionsCopyIfNewer.Clear();
2081+
ProtoExtensions.Clear();
20492082
}
20502083
}
20512084

0 commit comments

Comments
 (0)