summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakobL-MSFT <[email protected]>2023-02-07 15:36:48 -0800
committerGitHub <[email protected]>2023-02-07 15:36:48 -0800
commit208b227667182dfcd7bdf3ab4f5090aa823cf477 (patch)
tree1b7d8ad37d67108ef7225b66eed00030f581584d
parent9ab70a3207b3586eeef00298911b05e425d5a3a9 (diff)
Enable CodeQL to work thru reasonable workarounds. (#857)
-rw-r--r--.github/workflows/Code-Scanning.yml7
-rw-r--r--.github/workflows/ci-pr.yml4
-rw-r--r--.github/workflows/ci.yml4
-rw-r--r--Build-AllSamples.ps120
-rw-r--r--Build-Sample.ps16
-rw-r--r--Build-SampleSet.ps132
-rw-r--r--Building-Locally.md9
7 files changed, 46 insertions, 36 deletions
diff --git a/.github/workflows/Code-Scanning.yml b/.github/workflows/Code-Scanning.yml
index 86be1ef0..1ba4c660 100644
--- a/.github/workflows/Code-Scanning.yml
+++ b/.github/workflows/Code-Scanning.yml
@@ -48,10 +48,11 @@ jobs:
- name: Retrieve and build all available solutions
id: build-all-samples
run: |
- .\Build-AllSamples.ps1 -Verbose
+ .\Build-AllSamples.ps1 -Verbose -ThrottleLimit 1
env:
- Configuration: Debug
- Platform: x64
+ WDS_Configuration: Debug
+ WDS_Platform: x64
+ WDS_WipeOutputs: ${{ true }}
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml
index c701bd23..fa115e25 100644
--- a/.github/workflows/ci-pr.yml
+++ b/.github/workflows/ci-pr.yml
@@ -36,5 +36,5 @@ jobs:
$changedFiles = "${{ steps.get-changed-files.outputs.all_changed_files }}".Split(',')
.\.github\scripts\Build-ChangedSamples.ps1 -ChangedFiles $changedFiles -Verbose
env:
- Configuration: ${{ matrix.configuration }}
- Platform: ${{ matrix.platform }}
+ WDS_Configuration: ${{ matrix.configuration }}
+ WDS_Platform: ${{ matrix.platform }}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a8063d6e..6b97cfff 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -29,5 +29,5 @@ jobs:
run: |
.\Build-AllSamples.ps1 -Verbose
env:
- Configuration: ${{ matrix.configuration }}
- Platform: ${{ matrix.platform }}
+ WDS_Configuration: ${{ matrix.configuration }}
+ WDS_Platform: ${{ matrix.platform }}
diff --git a/Build-AllSamples.ps1 b/Build-AllSamples.ps1
index fb876d99..2cf7f403 100644
--- a/Build-AllSamples.ps1
+++ b/Build-AllSamples.ps1
@@ -9,14 +9,17 @@ This script searches for all available Visual Studio Solutions (.sln files) and
A regular expression matching the samples to be built. Default is '' that matches all samples. Examples include '^tools.' or '.dchu'.
.PARAMETER Configurations
-A list of configurations to build samples under. Values available are 'Debug' and 'Release'. By default, $env:Configuration will be used as the sole configuration to build for. If this environment variable is not set the default is 'Debug' and 'Release'.
+A list of configurations to build samples under. Values available are 'Debug' and 'Release'. By default, $env:WDS_Configuration will be used as the sole configuration to build for. If this environment variable is not set the default is 'Debug' and 'Release'.
.PARAMETER Platforms
-A list of platforms to build samples under (e.g. 'x64', 'arm64'). By default, $env:Platform will be used as the sole platform to build for. If this environment variable is not set the default is 'x64' and'arm64'.
+A list of platforms to build samples under (e.g. 'x64', 'arm64'). By default, $env:WDS_Platform will be used as the sole platform to build for. If this environment variable is not set the default is 'x64' and'arm64'.
.PARAMETER LogFilesDirectory
Path to a directory where the log files will be written to. If not provided, outputs will be logged to the '_logs' directory within the current working directory.
+.PARAMETER ThrottleLimit
+An integer indicating how many combinations to build in parallel. If 0 or not provided this defaults to 5 x number of logical processors.
+
.INPUTS
None.
@@ -27,16 +30,17 @@ None.
.\Build-AllSamples
.EXAMPLE
-.\Build-AllSamples -Samples '^tools.' -Configurations 'Debug','Release' -Platforms 'x64','arm64' -LogFilesDirectory .\_logs
+.\Build-AllSamples -Samples '^tools.' -Configurations 'Debug','Release' -Platforms 'x64','arm64'
#>
[CmdletBinding()]
param(
[string]$Samples = "",
- [string[]]$Configurations = @([string]::IsNullOrEmpty($env:Configuration) ? ('Debug','Release') : $env:Configuration),
- [string[]]$Platforms = @([string]::IsNullOrEmpty($env:Platform) ? ('x64','arm64') : $env:Platform),
- [string]$LogFilesDirectory = (Join-Path (Get-Location) "_logs")
+ [string[]]$Configurations = @([string]::IsNullOrEmpty($env:WDS_Configuration) ? ('Debug','Release') : $env:WDS_Configuration),
+ [string[]]$Platforms = @([string]::IsNullOrEmpty($env:WDS_Platform) ? ('x64','arm64') : $env:WDS_Platform),
+ [string]$LogFilesDirectory = (Join-Path (Get-Location) "_logs"),
+ [int]$ThrottleLimit
)
$Verbose = $false
@@ -63,6 +67,4 @@ foreach ($file in $solutionFiles) {
}
}
-
-
-.\Build-SampleSet -SampleSet $sampleSet -Configurations $Configurations -Platform $Platforms -LogFilesDirectory $LogFilesDirectory -Verbose:$Verbose
+.\Build-SampleSet -SampleSet $sampleSet -Configurations $Configurations -Platform $Platforms -LogFilesDirectory $LogFilesDirectory -Verbose:$Verbose -ThrottleLimit $ThrottleLimit
diff --git a/Build-Sample.ps1 b/Build-Sample.ps1
index 57f0ce7e..4f8f5b0b 100644
--- a/Build-Sample.ps1
+++ b/Build-Sample.ps1
@@ -140,6 +140,12 @@ $OutLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.out"
Write-Verbose "Building Sample: $SampleName; Configuration: $Configuration; Platform: $Platform {"
msbuild $solutionFile -clp:Verbosity=m -t:clean,build -property:Configuration=$Configuration -property:Platform=$Platform -p:TargetVersion=Windows10 -p:InfVerif_AdditionalOptions="/msft /sw1205 /sw1324 /sw1420 /sw1421" -p:SignToolWS=/fdws -p:DriverCFlagAddOn=/wd4996 -flp1:errorsonly`;logfile=$errorLogFilePath -flp2:WarningsOnly`;logfile=$warnLogFilePath -noLogo > $OutLogFilePath
+if ($env:WDS_WipeOutputs -ne $null)
+{
+ Write-Verbose ("WipeOutputs: "+$Directory+" "+(((Get-Volume ($DriveLetter=(Get-Item ".").PSDrive.Name)).SizeRemaining/1GB)))
+ Get-ChildItem -path $Directory -Recurse -Include x64|Remove-Item -Recurse
+ Get-ChildItem -path $Directory -Recurse -Include arm64|Remove-Item -Recurse
+}
if ($LASTEXITCODE -ne 0)
{
diff --git a/Build-SampleSet.ps1 b/Build-SampleSet.ps1
index 3295c8b4..3ef00efe 100644
--- a/Build-SampleSet.ps1
+++ b/Build-SampleSet.ps1
@@ -1,11 +1,16 @@
[CmdletBinding()]
param(
[hashtable]$SampleSet,
- [string[]]$Configurations = @([string]::IsNullOrEmpty($env:Configuration) ? "Debug" : $env:Configuration),
- [string[]]$Platforms = @([string]::IsNullOrEmpty($env:Platform) ? "x64" : $env:Platform),
- $LogFilesDirectory = (Get-Location)
+ [string[]]$Configurations = @([string]::IsNullOrEmpty($env:WDS_Configuration) ? "Debug" : $env:WDS_Configuration),
+ [string[]]$Platforms = @([string]::IsNullOrEmpty($env:WDS_Platform) ? "x64" : $env:WDS_Platform),
+ $LogFilesDirectory = (Get-Location),
+ [int]$ThrottleLimit
)
+$ThrottleFactor = 5
+$LogicalProcessors = (Get-CIMInstance -Class 'CIM_Processor' -Verbose:$false).NumberOfLogicalProcessors
+$ThrottleLimit = $ThrottleLimit -eq 0 ? ($ThrottleFactor * $LogicalProcessors) : $ThrottleLimit
+
$Verbose = $false
if ($PSBoundParameters.ContainsKey('Verbose')) {
$Verbose = $PsBoundParameters.Get_Item('Verbose')
@@ -18,10 +23,6 @@ $sampleBuilderFilePath = "$LogFilesDirectory\overview.htm"
Remove-Item -Recurse -Path $LogFilesDirectory 2>&1 | Out-Null
New-Item -ItemType Directory -Force -Path $LogFilesDirectory | Out-Null
-$NumberOfLogicalProcessors = (Get-CIMInstance -Class 'CIM_Processor' -Verbose:$false).NumberOfLogicalProcessors
-$Throttlefactor = 5
-$SolutionsInParallel = $Throttlefactor * $NumberOfLogicalProcessors
-
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = "stop"
try {
@@ -58,9 +59,11 @@ Write-Output ("Samples: "+$sampleSet.Count)
Write-Output ("Configurations: "+$Configurations.Count+" ("+$Configurations+")")
Write-Output ("Platforms: "+$Platforms.Count+" ("+$Platforms+")")
Write-Output "Combinations: $SolutionsTotal"
-Write-Output "Logical Processors: $NumberOfLogicalProcessors"
-Write-Output "Throttle factor: $Throttlefactor"
-Write-Output "Throttle limit: $SolutionsInParallel"
+Write-Output "LogicalProcessors: $LogicalProcessors"
+Write-Output "ThrottleFactor: $ThrottleFactor"
+Write-Output "ThrottleLimit: $ThrottleLimit"
+Write-Output "WDS_WipeOutputs: $env:WDS_WipeOutputs"
+Write-Output ("Disk Remaining (GB): "+(((Get-Volume ($DriveLetter=(Get-Item ".").PSDrive.Name)).SizeRemaining/1GB)))
Write-Output ""
Write-Output "T: Combinations"
Write-Output "B: Built"
@@ -78,7 +81,7 @@ $Results = @()
$sw = [Diagnostics.Stopwatch]::StartNew()
-$SampleSet.GetEnumerator() | ForEach-Object -ThrottleLimit $SolutionsInParallel -Parallel {
+$SampleSet.GetEnumerator() | ForEach-Object -ThrottleLimit $ThrottleLimit -Parallel {
$LogFilesDirectory = $using:LogFilesDirectory
$exclusionsSet = $using:exclusionsSet
$Configurations = $using:Configurations
@@ -133,11 +136,11 @@ $SampleSet.GetEnumerator() | ForEach-Object -ThrottleLimit $SolutionsInParallel
($using:jresult).SolutionsUnsupported += $thisunsupported
($using:jresult).SolutionsFailed += $thisfailed
$SolutionsTotal = $using:SolutionsTotal
- $SolutionsInParallel = $using:SolutionsInParallel
+ $ThrottleLimit = $using:ThrottleLimit
$SolutionsBuilt = ($using:jresult).SolutionsBuilt
$SolutionsRemaining = $SolutionsTotal - $SolutionsBuilt
- $SolutionsRunning = $SolutionsRemaining -ge $SolutionsInParallel ? ($SolutionsInParallel) : ($SolutionsRemaining)
- $SolutionsPending = $SolutionsRemaining -ge $SolutionsInParallel ? ($SolutionsRemaining - $SolutionsInParallel) : (0)
+ $SolutionsRunning = $SolutionsRemaining -ge $ThrottleLimit ? ($ThrottleLimit) : ($SolutionsRemaining)
+ $SolutionsPending = $SolutionsRemaining -ge $ThrottleLimit ? ($SolutionsRemaining - $ThrottleLimit) : (0)
$SolutionsBuiltPercent = [Math]::Round(100 * ($SolutionsBuilt / $using:SolutionsTotal))
$TBRP = "T:" + ($SolutionsTotal) + "; B:" + (($using:jresult).SolutionsBuilt) + "; R:" + ($SolutionsRunning) + "; P:" + ($SolutionsPending)
$rstr = "S:" + (($using:jresult).SolutionsSucceeded) + "; E:" + (($using:jresult).SolutionsExcluded) + "; U:" + (($using:jresult).SolutionsUnsupported) + "; F:" + (($using:jresult).SolutionsFailed)
@@ -181,6 +184,7 @@ Write-Output ""
Write-Output "Built all combinations."
Write-Output ""
Write-Output "Elapsed time: $min minutes, $seconds seconds."
+Write-Output ("Disk Remaining (GB): "+(((Get-Volume ($DriveLetter=(Get-Item ".").PSDrive.Name)).SizeRemaining/1GB)))
Write-Output ("Samples: "+$sampleSet.Count)
Write-Output ("Configurations: "+$Configurations.Count+" ("+$Configurations+")")
Write-Output ("Platforms: "+$Platforms.Count+" ("+$Platforms+")")
diff --git a/Building-Locally.md b/Building-Locally.md
index 294ecae8..8f62a609 100644
--- a/Building-Locally.md
+++ b/Building-Locally.md
@@ -15,10 +15,7 @@ You can also just download and mount the EWDK as well and in the following examp
* Mount ISO image
* Open a terminal
* `.\LaunchBuildEnv`
- * `set PLATFORM=`
-
-Note: The last command to clear the PLATFORM variable is added so as to allow the next part to iterate over all platforms automatically without having to add explicit arguments.
-
+
## Step 3: Clone Windows Driver Samples and checkout main branch
```
@@ -33,12 +30,12 @@ cd Windows-driver-samples
pwsh
.\Build-AllSamples
```
-Above builds all samples for all configurations and archictures.
+Above builds all samples for all configurations and platforms.
You can refine, for example as follows:
```
pwsh
-.\Build-AllSamples -Samples 'tools.' -Configurations 'Debug','Release' -Platforms 'x64','arm64' -LogFilesDirectory .\_logs
+.\Build-AllSamples -Samples '^tools.' -Configurations 'Debug','Release' -Platforms 'x64','arm64'
```
Expected output: