From d942724d79b839bbbc022992f1abc98fa79fd7bd Mon Sep 17 00:00:00 2001 From: Martin Ecker Date: Mon, 15 Dec 2025 16:18:51 -0800 Subject: [PATCH] File resolve and globbing improvements: - 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. --- Sharpmake/Project.cs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Sharpmake/Project.cs b/Sharpmake/Project.cs index da168f94f..df8c031f0 100644 --- a/Sharpmake/Project.cs +++ b/Sharpmake/Project.cs @@ -900,8 +900,30 @@ internal virtual void ResolveSourceFiles(Builder builder) NoneExtensions.RemoveAll(s => NoneExtensionsCopyIfNewer.Contains(s)); } + var extensionContainers = new[] + { + SourceFilesExtensions, + ResourceFilesExtensions, + PRIFilesExtensions, + NatvisFilesExtensions, + NoneExtensions, + NoneExtensionsCopyIfNewer, + ProtoExtensions + }; + + // The code below does an expensive glob to get source files, which when generating the + // debug project will have to scan a potentially large depot tree and takes a long time + // Clear all extensions to not do the file scanning for the debug project. + if (this is DebugProject) + { + foreach (var container in extensionContainers) + { + container.Clear(); + } + } + // Only scan directory for files if needed - if (SourceFilesExtensions.Count != 0 || ResourceFilesExtensions.Count != 0 || PRIFilesExtensions.Count != 0 || NoneExtensions.Count != 0 || NoneExtensionsCopyIfNewer.Count != 0) + if (extensionContainers.Any(container => container.Count != 0)) { string capitalizedSourceRootPath = Util.GetCapitalizedPath(SourceRootPath); @@ -1912,6 +1934,13 @@ internal virtual void Resolve(Builder builder, bool skipInvalidPath) Util.ResolvePath(SourceRootPath, ref SourceFilesExclude); Util.ResolvePath(SourceRootPath, ref SourceFilesBlobExclude); Util.ResolvePath(SourceRootPath, ref SourceFilesBuildExclude); + Util.ResolvePath(SourceRootPath, ref PRIFiles); + Util.ResolvePath(SourceRootPath, ref ResourceFiles); + Util.ResolvePath(SourceRootPath, ref NatvisFiles); + Util.ResolvePath(SourceRootPath, ref NoneFiles); + Util.ResolvePath(SourceRootPath, ref NoneFilesCopyIfNewer); + Util.ResolvePath(SourceRootPath, ref ProtoFiles); + Util.ResolvePath(SharpmakeCsPath, ref _blobPath); if (SourceFilesFilters != null) @@ -2046,6 +2075,10 @@ public FastBuildAllProject(Type targetType) SourceFilesExtensions.Clear(); ResourceFilesExtensions.Clear(); PRIFilesExtensions.Clear(); + NatvisFilesExtensions.Clear(); + NoneExtensions.Clear(); + NoneExtensionsCopyIfNewer.Clear(); + ProtoExtensions.Clear(); } }