Skip to content

Commit

Permalink
Add a Glob package and use it for adding files to a project with wild…
Browse files Browse the repository at this point in the history
…cards instead of regex filtering
  • Loading branch information
d-s-h committed Nov 10, 2023
1 parent fc38e6a commit 5f861bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Sharpmake/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.IO;
using System.Linq;
using System.Threading;
using GlobExpressions;

namespace Sharpmake
{
Expand Down Expand Up @@ -118,6 +119,7 @@ public int SourceFilesFiltersCount
public Strings SourceFilesExclude = new Strings(); // Excluded files from the project, removed from SourceFiles

public Strings SourceFilesIncludeRegex = new Strings(); // files that match SourceFilesIncludeRegex and SourceFilesExtension from source directory will make SourceFiles
public Strings SourceFilesIncludeWildcards = new Strings(); // alternative way to add source files (wildcards instead of regex)

public Strings SourceFilesFiltersRegex = new Strings(); // Filters SourceFiles list

Expand Down Expand Up @@ -864,7 +866,15 @@ internal virtual void ResolveSourceFiles(Builder builder)
}

// Only scan directory for files if needed
if (SourceFilesExtensions.Count != 0 || ResourceFilesExtensions.Count != 0 || PRIFilesExtensions.Count != 0 || NoneExtensions.Count != 0 || NoneExtensionsCopyIfNewer.Count != 0)
if (SourceFilesIncludeWildcards.Count != 0)
{
// Use an explicit way to specify files.
foreach (string pattern in SourceFilesIncludeWildcards)
{
SourceFiles.AddRange(Glob.Files(SourceRootPath, pattern).ToArray());
}
}
else if (SourceFilesExtensions.Count != 0 || ResourceFilesExtensions.Count != 0 || PRIFilesExtensions.Count != 0 || NoneExtensions.Count != 0 || NoneExtensionsCopyIfNewer.Count != 0)
{
string capitalizedSourceRootPath = Util.GetCapitalizedPath(SourceRootPath);

Expand Down
1 change: 1 addition & 0 deletions Sharpmake/Sharpmake.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Glob" Version="1.1.9" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.7.2175" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
Expand Down

0 comments on commit 5f861bc

Please sign in to comment.