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

Remove perl dependency #2830

Merged
merged 1 commit into from
Sep 19, 2024
Merged
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
51 changes: 51 additions & 0 deletions Tools/VerifyResourceUsage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
$folderPath = $PSScriptRoot + "/../src"

# Get LogMessages C# files
$files = Get-ChildItem -Path $folderPath -Filter LogMessages.cs -Recurse

# Dictionary to hold constants and their usage status
$constants = @{}

# Extract constants
foreach ($file in $files) {
$content = Get-Content -Path $file.FullName
foreach ($line in $content) {
if (($line -match 'const\s+\w+\s+(\w+)\s*=') -and !($line.Contains("//"))) {
$constantName = $matches[1]
$constants[$constantName] = [PSCustomObject]@{
File = $file.FullName
ConstantName = $constantName
Found = $false
}
}
}
}

$files = Get-ChildItem -Path $folderPath -Filter *.cs -Exclude LogMessages.cs -Recurse
$keys = @($constants.Keys)

# Check for usage
foreach ($file in $files) {
$content = Get-Content -Path $file.FullName
foreach ($constantName in $keys) {
if (Select-String -InputObject $content -Pattern $constantName) {
$constants[$constantName].Found = $true
}
}
}

# Output unused constants
$unusedConstants = $constants.GetEnumerator() | Where-Object { $_.Value.Found -eq $false }
if ($unusedConstants.Count -eq 0) {
Write-Output "No unused constants found."
} else {
Write-Output "Unused constants:"
foreach ($unused in $unusedConstants) {
$constName = $unused.Value.ConstantName
$filePath = $unused.Value.File
$message = "'$constName' in file '$filePath'"
Write-Output $message
}

throw "found unused constants"
}
8 changes: 4 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ $ErrorActionPreference = "Stop"

WriteSectionHeader("VerifyResourceUsage.pl");

Write-Host ">>> Start-Process -Wait -PassThru -NoNewWindow perl $root\src\VerifyResourceUsage.pl"
$verifyResourceUsageResult = Start-Process -Wait -PassThru -NoNewWindow perl $root\src\VerifyResourceUsage.pl
Write-Host ">>> Start-Process -Wait -PassThru -NoNewWindow powershell $root\tools\VerifyResourceUsage.ps1"
$verifyResourceUsageResult = Start-Process -Wait -PassThru -NoNewWindow powershell $root\tools\VerifyResourceUsage.ps1

if($verifyResourceUsageResult.ExitCode -ne 0)
{
throw "VerifyResourceUsage.pl failed."
throw "VerifyResourceUsage.ps1 failed."
}

WriteSectionFooter("End VerifyResourceUsage.pl");
WriteSectionFooter("End VerifyResourceUsage.ps1");

WriteSectionHeader("Build");

Expand Down
93 changes: 0 additions & 93 deletions build/install-strawberry-perl.ps1

This file was deleted.

13 changes: 2 additions & 11 deletions build/template-Build-run-tests-sign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,9 @@ steps:
custom: '--list-sdks'

- task: PowerShell@2
displayName: "Install Strawberry Perl"
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)\$(WilsonSourceDirectory)build\install-strawberry-perl.ps1
arguments: >
-ci_path "$(Build.SourcesDirectory)"
-debug
condition: and(succeeded(), eq(variables['PipelineType'], 'onebranch'))

- powershell: |
perl "$(Build.SourcesDirectory)\$(WilsonSourceDirectory)src\VerifyResourceUsage.pl"
displayName: 'Verify error messages are all used.'
inputs:
filePath: $(Build.SourcesDirectory)\$(WilsonSourceDirectory)Tools\VerifyResourceUsage.ps1

- powershell: |
regedit /s .\build\strongNameBypass.reg
Expand Down
Loading
Loading