diff options
| author | Adonais Romero González <[email protected]> | 2022-08-26 14:48:11 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-08-26 14:48:11 -0700 |
| commit | d504c54cf595e9185617a3e611e417617be8c0b8 (patch) | |
| tree | f0d7d3e09abe2cf55ad646380488c8cde685f727 /Build-Project.ps1 | |
| parent | 73c55fdc2e3d407ee39521ff4a1b2ea6791f134e (diff) | |
Add CI workflows for building and validating driver samples (#775)
* Add scripts to build a set of samples, as well as individual solution folders.
* Add GitHub workflows to use these scripts and build all samples on push and changed samples on pull request.
For now samples will be built under Windows 2019 but eventually workflow will be moved to run under Windows 2022.
Diffstat (limited to 'Build-Project.ps1')
| -rw-r--r-- | Build-Project.ps1 | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Build-Project.ps1 b/Build-Project.ps1 new file mode 100644 index 00000000..1f79b679 --- /dev/null +++ b/Build-Project.ps1 @@ -0,0 +1,64 @@ +param( + $Directory, + [string]$ProjectName, + $LogFilesDirectory = "_logfiles", + [string]$Configuration = "Debug", + [string]$Platform = "x64" +) + +# TODO Validate $Directory and $LogFilesDirectory +New-Item -ItemType Directory -Force -Path $LogFilesDirectory | Out-Null + +if ([string]::IsNullOrWhitespace($ProjectName)) +{ + $ProjectName = (Resolve-Path $Directory).Path.Replace((Get-Location), '').Replace('\', '.').Trim('.').ToLower() +} + +$solutionFile = Get-ChildItem -Path $Directory -Filter *.sln | Select-Object -ExpandProperty FullName -First 1 + +$configurationIsSupported = $false +$inSolutionConfigurationPlatformsSection = $false +foreach ($line in Get-Content -Path $solutionFile) +{ + if (-not $inSolutionConfigurationPlatformsSection -and $line -match "\s*GlobalSection\(SolutionConfigurationPlatforms\).*") + { + $inSolutionConfigurationPlatformsSection = $true; + continue; + } + elseif ($line -match "\s*EndGlobalSection.*") + { + $inSolutionConfigurationPlatformsSection = $false; + continue; + } + + if ($inSolutionConfigurationPlatformsSection) + { + [regex]$regex = ".*=\s*(?<ConfigString>(?<Configuration>.*)\|(?<Platform>.*))\s*" + $match = $regex.Match($line) + if ([string]::IsNullOrWhiteSpace($match.Groups["ConfigString"].Value) -or [string]::IsNullOrWhiteSpace($match.Groups["Platform"].Value)) + { + Write-Warning "Could not parse configuration entry $line from file $solutionFile." + continue; + } + if ($match.Groups["Configuration"].Value.Trim() -eq $Configuration -and $match.Groups["Platform"].Value.Trim() -eq $Platform) + { + $configurationIsSupported = $true; + } + } +} + +if (-not $configurationIsSupported) +{ + Write-Output "[$ProjectName] ⏩ Skipped. Configuration $Configuration|$Platform not supported." + exit 0 +} + +$errorLogFilePath = "$LogFilesDirectory\$ProjectName.err" +$warnLogFilePath = "$LogFilesDirectory\$ProjectName.wrn" +Write-Output "[$ProjectName] ⚒️ Building project..." +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 +if ($LASTEXITCODE -ne 0) +{ + Write-Warning "❌ Build failed. Log available at $errorLogFilePath" + exit 1 +} |
