diff options
| author | 5an7y <[email protected]> | 2026-03-30 15:43:16 -0700 |
|---|---|---|
| committer | 5an7y <[email protected]> | 2026-03-30 15:43:16 -0700 |
| commit | 83cfa72cc265ab052100563cfc2e8c9d9b6020ba (patch) | |
| tree | 26f6917c3ffc5865613265bae22a3215ea29194e | |
| parent | bc6b2708d9d762dde716a2af7c8fa08534c1afcc (diff) | |
Support wildcard patterns in -Samples parameter
- When -Samples contains wildcards (* or ?), discover all samples first
then filter with -like (same pattern style as exclusions.csv)
- Exact sample names still work as before without discovery overhead
- Update parameter docs, examples, and Building-Locally.md
| -rw-r--r-- | Build-Samples.ps1 | 43 | ||||
| -rw-r--r-- | Building-Locally.md | 3 |
2 files changed, 38 insertions, 8 deletions
diff --git a/Build-Samples.ps1 b/Build-Samples.ps1 index 4242d428..7eafb54d 100644 --- a/Build-Samples.ps1 +++ b/Build-Samples.ps1 @@ -16,7 +16,9 @@ .PARAMETER Samples - Optional array of specific sample names to build. When omitted, all samples are discovered dynamically via ListAllSamples.ps1. + Optional array of specific sample names or wildcard patterns to build. Supports + wildcards (e.g. 'tools.*', 'audio.*') which are matched against all discovered + samples. When omitted, all samples are discovered dynamically via ListAllSamples.ps1. .PARAMETER Configurations Build configurations (e.g. 'Debug','Release'). Defaults to $env:WDS_Configuration or @@ -50,6 +52,11 @@ Builds specific samples for a single configuration and platform. .EXAMPLE + .\Build-Samples -Samples 'tools.*' + + Builds all samples whose name matches the wildcard pattern 'tools.*'. + +.EXAMPLE .\Build-Samples -ThrottleLimit 8 Discovers all samples and builds them with limited parallelism. @@ -408,17 +415,37 @@ $reportCsvPath = Join-Path $LogFilesDirectory "$ReportFileName.csv" # Step 4 - Load Sample List # ============================================================================= -if ($Samples) { - # Explicit list passed by the caller — use as-is, sorted alphabetically. - $sampleNames = $Samples | Sort-Object -} -else { - # Default: discover samples dynamically via ListAllSamples.ps1. - # ListAllSamples outputs one alphabetically-sorted sample name per line to stdout. +# Always discover the full sample list when patterns contain wildcards, +# or when no -Samples were provided at all. +$hasWildcards = $Samples | Where-Object { $_ -match '[*?]' } + +if (-not $Samples) { + # No filter: discover and build everything. Write-Verbose "No -Samples provided. Discovering samples via ListAllSamples.ps1..." $sampleNames = & (Join-Path $PSScriptRoot 'ListAllSamples.ps1') -Verbose:$verbose | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } } +elseif ($hasWildcards) { + # One or more entries contain wildcards — discover all, then filter with -like. + Write-Verbose "Wildcard detected in -Samples. Discovering all samples to match patterns..." + $allSamples = & (Join-Path $PSScriptRoot 'ListAllSamples.ps1') -Verbose:$verbose | + Where-Object { -not [string]::IsNullOrWhiteSpace($_) } + $sampleNames = @() + foreach ($pattern in $Samples) { + $matched = $allSamples | Where-Object { $_ -like $pattern } + if ($matched) { + $sampleNames += $matched + } + else { + Write-Warning "Pattern '$pattern' did not match any samples." + } + } + $sampleNames = $sampleNames | Sort-Object -Unique +} +else { + # Exact list passed by the caller — use as-is, sorted alphabetically. + $sampleNames = $Samples | Sort-Object +} # Map sample names to directory paths, validating each exists $sampleSet = [ordered]@{} diff --git a/Building-Locally.md b/Building-Locally.md index d988a330..45110098 100644 --- a/Building-Locally.md +++ b/Building-Locally.md @@ -155,6 +155,9 @@ Get-Help .\Build-Samples # Build specific samples for all flavors: .\Build-Samples -Samples 'tools.sdv.samples.sampledriver','usb.kmdf_fx2' +# Build all samples inside the 'tools' folder using wildcards: +.\Build-Samples -Samples 'tools.*' + # Build specific samples for only 'Debug|x64': .\Build-Samples -Samples 'tools.sdv.samples.sampledriver' -Configurations 'Debug' -Platforms 'x64' ``` |
