Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous improvements to build scripts #1240

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions Build-Sample.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -147,39 +147,42 @@ $myexit=0
# If we fail at first, but succeed at either of next two attempts, then it is a sporadic failure.
# If we even at third attempt fail, then it is a true failure.
#
for ($i=0; $i -le 2; $i++) {
for ($i = 0; $i -lt 3; $i++)
{
$binLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.binlog"
$errorLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.err"
$warnLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.wrn"
$OutLogFilePath = "$LogFilesDirectory\$SampleName.$Configuration.$Platform.$i.out"

msbuild $solutionFile -clp:Verbosity=m -t:rebuild -property:Configuration=$Configuration -property:Platform=$Platform -p:TargetVersion=Windows10 -p:InfVerif_AdditionalOptions="$InfVerif_AdditionalOptions" -warnaserror -flp1:errorsonly`;logfile=$errorLogFilePath -flp2:WarningsOnly`;logfile=$warnLogFilePath -noLogo > $OutLogFilePath
if ($env:WDS_WipeOutputs -ne $null)
msbuild $solutionFile -clp:Verbosity=m -t:rebuild -property:Configuration=$Configuration -property:Platform=$Platform -p:TargetVersion=Windows10 -p:InfVerif_AdditionalOptions="$InfVerif_AdditionalOptions" -warnaserror -binaryLogger:LogFile=$binLogFilePath`;ProjectImports=None -flp1:errorsonly`;logfile=$errorLogFilePath -flp2:WarningsOnly`;logfile=$warnLogFilePath -noLogo > $OutLogFilePath
if ($null -ne $env:WDS_WipeOutputs)
{
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
Write-Verbose ("WipeOutputs: " + $Directory + " " + (((Get-Volume (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 -eq 0)
{
# We succeeded building.
# If at first attempt, then $myexit=0
# If at later attempt, then $myexit=2
# If it was at a later attempt, let the caller know with a different exit code.
if ($i -eq 0)
{
$myexit=0
$myexit = 0
}
else
{
$myexit=2
$myexit = 2
}
break;
# Remove binlog on success to save space; keep otherwise to diagnose issues.
Remove-Item $binLogFilePath
break;
}
else
{
# We failed building.
# Let us sleep for a bit.
# Then let the while loop do its thing and re-run.
sleep 1
Start-Sleep 1
if ($Verbose)
{
Write-Warning "`u{274C} Build failed. Retrying to see if sporadic..."
Expand Down
18 changes: 12 additions & 6 deletions Build-SampleSet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $root = Get-Location
if (-not $env:VSCMD_VER) {
Import-Module (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*")
cd $root
Set-Location $root
}

$ThrottleFactor = 5
Expand Down Expand Up @@ -97,19 +97,25 @@ else {

# Dump all environment variables so as to help debug error:
Write-Output "Environment variables {"
gci env:* | sort-object name
Get-ChildItem env:* | Sort-Object name
Write-Output "Environment variables }"

Write-Error "Could not determine build environment."
exit 1
}
#
# Get the WDK extension version from installed packages
$wdk_extension_ver = ls "${env:ProgramData}\Microsoft\VisualStudio\Packages\Microsoft.Windows.DriverKit,version=*" | Select -ExpandProperty Name
$wdk_extension_ver = Get-ChildItem "${env:ProgramData}\Microsoft\VisualStudio\Packages\Microsoft.Windows.DriverKit,version=*" | Select-Object -ExpandProperty Name
$wdk_extension_ver = ([regex]'(\d+\.)(\d+\.)(\d+\.)(\d+)').Matches($wdk_extension_ver).Value
if (-not $wdk_extension_ver) {
Write-Error "No version of the WDK Visual Studio Extension could be found. The WDK Extension is not installed."
exit 1
# Be lenient with EWDK builds that do not include the package information
if ($build_environment -match '^EWDK') {
$wdk_extension_ver = "(package not found)"
}
else {
Write-Error "No version of the WDK Visual Studio Extension could be found. The WDK Extension is not installed."
exit 1
}
}
#
#
Expand Down Expand Up @@ -348,7 +354,7 @@ $Results = $jresult.Results
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 ("Disk Remaining (GB): " + (((Get-Volume (Get-Item ".").PSDrive.Name).SizeRemaining / 1GB)))
Write-Output ("Samples: " + $sampleSet.Count)
Write-Output ("Configurations: " + $Configurations.Count + " (" + $Configurations + ")")
Write-Output ("Platforms: " + $Platforms.Count + " (" + $Platforms + ")")
Expand Down