forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_prefast_error.ps1
More file actions
44 lines (36 loc) · 1.31 KB
/
check_prefast_error.ps1
File metadata and controls
44 lines (36 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#-------------------------------------------------------------------------------------------------------
# Copyright (C) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
#-------------------------------------------------------------------------------------------------------
param (
[string]$directory,
[string]$logFile = ""
)
. "$PSScriptRoot\util.ps1"
if ((Test-Path $directory) -eq 0) {
Write-Error ("ERROR: Directory {0} does not exist. Cannot scan for prefast defects" -f $directory);
Exit(-1)
}
if (Test-Path -Path $logFile) {
Remove-Item $logFile -Force
}
# load all prefast results
$files = Get-ChildItem -recurse ("{0}\vc.nativecodeanalysis.all.xml" -f $directory)
$filecount = 0;
$count = 0;
foreach ($file in $files) {
$filecount++;
[xml]$x = Get-Content $file
foreach ($d in $x.DEFECTS.DEFECT) {
WriteErrorMessage ("{0}{1}({2}): warning C{3}: {4}" -f $d.SFA.FILEPATH, $d.SFA.FILENAME, $d.SFA.LINE, $d.DEFECTCODE, $d.DESCRIPTION)
$count++;
}
}
if ($count -ne 0) {
WriteErrorMessage ("ERROR: {0} prefast warning detected" -f $count)
} elseif ($filecount -ne 0) {
WriteMessage "No prefast warning detected"
} else {
WriteMessage "No prefast result found"
}
exit $count