-
-
Notifications
You must be signed in to change notification settings - Fork 842
Expand file tree
/
Copy pathformat-code.ps1
More file actions
37 lines (30 loc) · 960 Bytes
/
format-code.ps1
File metadata and controls
37 lines (30 loc) · 960 Bytes
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
$ErrorActionPreference = "Stop"
# Run from repo root (script is in repo root)
$CF = Join-Path $PSScriptRoot "tools\clang-format.ps1"
if (-not (Test-Path $CF)) {
throw "ERROR: $CF not found. Did you commit tools\clang-format.ps1 and the pinned binaries?"
}
# Print version for traceability
& $CF --version | Write-Host
# Collect files (PowerShell-native; avoids xargs/find differences on Windows)
$roots = @(
"firmware/common",
"firmware/baseband",
"firmware/application",
"firmware/test/application",
"firmware/test/baseband"
)
$files = foreach ($r in $roots) {
if (Test-Path $r) {
Get-ChildItem -Path $r -Recurse -File -ErrorAction SilentlyContinue |
Where-Object { $_.Extension -in @(".h", ".hpp", ".c", ".cpp") } |
ForEach-Object { $_.FullName }
}
}
if (-not $files -or $files.Count -eq 0) {
Write-Host "No matching source files found."
exit 0
}
# Format in place
& $CF -style=file -i -- $files
exit $LASTEXITCODE