55 [string ]$Out
66)
77
8- # C:\Program Files\Microsoft Visual Studio\2022
9- $VS2022Root = " $env: ProgramFiles \Microsoft Visual Studio\2022"
10-
11- $clangtidy = $null
12- $clangtidyLocal = $ (
13- # x64
14- " $VS2022Root \Preview\VC\Tools\Llvm\x64\bin\clang-tidy.exe" ,
15- " $VS2022Root \Community\VC\Tools\Llvm\x64\bin\clang-tidy.exe" ,
16- " $VS2022Root \Professional\VC\Tools\Llvm\x64\bin\clang-tidy.exe" ,
17- " $VS2022Root \Enterprise\VC\Tools\Llvm\x64\bin\clang-tidy.exe" ,
18-
19- " $env: ProgramFiles \llvm\bin\clang-tidy.exe"
20- )
21- foreach ($c in $clangtidyLocal ) {
22- if (Test-Path $c ) {
23- $clangtidy = $c
24- break
8+
9+ $llvmArchTable = @ {
10+ " win-x64" = " x64" ;
11+ " win-arm64" = " arm64" ;
12+ }
13+
14+ $RID = [System.Runtime.InteropServices.RuntimeInformation ]::RuntimeIdentifier
15+ # win-x64 win-arm64
16+
17+ $llvmArch = $llvmArchTable [$RID ]
18+
19+ function Get-VSWhere {
20+ $app = Get-Command - CommandType Application " vswhere" - ErrorAction SilentlyContinue
21+ if ($null -ne $app ) {
22+ return $app [0 ].Source
23+ }
24+ $vswhere = Join-Path ${env: ProgramFiles(x86)} - ChildPath " Microsoft Visual Studio\Installer\vswhere.exe"
25+ if (Test-Path $vswhere ) {
26+ return $vswhere
2527 }
28+ return $null
2629}
2730
28- if ($null -eq $clangtidy ) {
29- $clangtidyobj = Get-Command - CommandType Application " clang-tidy" - ErrorAction SilentlyContinue
30- if ($null -eq $clangtidyobj ) {
31- Write-Host - ForegroundColor Red " No clang-tidy to be found"
32- return
31+
32+ function Get-ClangTidy {
33+ $app = Get-Command - CommandType Application " clang-tidy" - ErrorAction SilentlyContinue
34+ if ($null -ne $app ) {
35+ return $app [0 ].Source
36+ }
37+ $clangTidy = Join-Path $env: ProgramFiles - ChildPath " llvm\bin\clang-tidy.exe"
38+ if (Test-Path $clangTidy ) {
39+ return $clangTidy
40+ }
41+ # vswhere.exe -prerelease -latest -requires Microsoft.VisualStudio.Component.VC.Llvm.Clang -property installationPath
42+ $vswhere = Get-VSWhere
43+ if ($null -eq $vswhere ) {
44+ return $null
45+ }
46+ $InstallDir = & $vswhere - prerelease - latest - requires Microsoft.VisualStudio.Component.VC.Llvm.Clang - property installationPath
47+ if ([string ]::IsNullOrEmpty($InstallDir )) {
48+ return $null
3349 }
34- $clangtidy = $clangtidyobj [0 ].Source
50+ $clangTidy = Join-Path $InstallDir - ChildPath " VC\Tools\Llvm\${llvmArch} \bin\clang-tidy.exe"
51+ return $clangTidy
3552}
3653
54+ $clangTidyExe = Get-ClangTidy
55+ if ($null -eq $clangTidyExe ) {
56+ Write-Host - ForegroundColor Red " clang-tidy not found"
57+ exit 1
58+ }
59+
60+ # vswhere -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
61+
3762$SOURCE_DIRS = $ (
3863 " $PSScriptRoot \src\bela" ,
3964 " $PSScriptRoot \src\belahash" ,
@@ -59,6 +84,8 @@ $checks = $(
5984 " -readability-magic-numbers" ,
6085 " -readability-qualified-auto" ,
6186 " -readability-function-cognitive-complexity" ,
87+ " -readability-identifier-length" ,
88+ # "-readability-math-missing-parentheses",
6289 " modernize-*" ,
6390 " -modernize-use-trailing-return-type" ,
6491 " -modernize-avoid-c-arrays" ,
@@ -75,7 +102,7 @@ $inputArgs = $(
75102 " -m64" ,
76103 " -x" ,
77104 " c++" ,
78- " -std=c++20 " ,
105+ " -std=c++23 " ,
79106 " -ferror-limit=1000" ,
80107 " -D_WIN64" ,
81108 " -DNDEBUG" ,
@@ -92,7 +119,7 @@ $inputArgs = $(
92119
93120$inputArgsPrefix = [string ]::Join(" " , $inputArgs )
94121
95- Write-Host " Use $clangtidy `n $inputArgsPrefix "
122+ Write-Host " Use $clangTidyExe `n $inputArgsPrefix "
96123
97124$extensions = (" .cc" , " .cxx" , " .cpp" , " .c++" );
98125
@@ -102,7 +129,7 @@ foreach ($d in $SOURCE_DIRS) {
102129 if ($extensions.Contains ($_.Extension )) {
103130 $FileName = $_.FullName
104131 Write-Host - ForegroundColor Magenta " check $FileName "
105- $exitCode = Start-Process - FilePath $clangtidy - ArgumentList " `" $FileName `" $inputArgsPrefix " - Wait - PassThru - NoNewWindow - WorkingDirectory $PSScriptRoot
132+ $exitCode = Start-Process - FilePath $clangTidyExe - ArgumentList " `" $FileName `" $inputArgsPrefix " - Wait - PassThru - NoNewWindow - WorkingDirectory $PSScriptRoot
106133 $exitCode | Out-Null
107134 }
108135 }
0 commit comments