blob: fcb7208cb4a9930d82f66c9c253caa172a1d3e47 (
plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
$pathsToPreserve = @()
$originalPath = $env:PATH -split ';'
foreach ($pathEntry in $originalPath) {
if ($pathEntry -match 'CMake|Python|Git|System32|WindowsApps') {
$pathsToPreserve += $pathEntry
}
}
Get-ChildItem env: | Where-Object { $_.Name -match "^INCLUDE$|^LIB$|^LIBPATH$" } | ForEach-Object {
Remove-Item "env:\$($_.Name)"
}
$env:Path = $pathsToPreserve -join ';'
$vcTools = "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717"
$vcHost = "Hostx64\x64"
$clPath = "$vcTools\bin\$vcHost"
$env:Path = "$clPath;$env:Path"
$sdkBase = "C:\Program Files (x86)\Windows Kits\10"
$sdkVersions = Get-ChildItem "$sdkBase\Include" -Directory |
Where-Object { $_.Name -match "^\d+\.\d+" } |
Sort-Object Name -Descending
if ($sdkVersions) {
$latestSdk = $sdkVersions[0].Name
$sdkBin = "$sdkBase\bin\$latestSdk\x64"
$env:Path = "$sdkBin;$env:Path"
$includePaths = @(
"$vcTools\include",
"$sdkBase\Include\$latestSdk\um",
"$sdkBase\Include\$latestSdk\shared",
"$sdkBase\Include\$latestSdk\ucrt"
)
$env:INCLUDE = ($includePaths -join ';')
$libPaths = @(
"$vcTools\lib\x64",
"$sdkBase\Lib\$latestSdk\um\x64",
"$sdkBase\Lib\$latestSdk\ucrt\x64"
)
$env:LIB = ($libPaths -join ';')
$env:LIBPATH = "$vcTools\lib\x64;$sdkBase\Lib\$latestSdk\um\x64"
} else {
Write-Host "Warning: Using generic SDK path" -ForegroundColor Yellow
$env:Path = "$sdkBase\bin\x64;$env:Path"
$env:INCLUDE = "$vcTools\include"
$env:LIB = "$vcTools\lib\x64"
}
$libFiles = @(
"$vcTools\lib\x64\MSVCRTD.lib",
"$vcTools\lib\x64\MSVCRT.lib"
)
foreach ($lib in $libFiles) {
if (-not (Test-Path $lib)) {
Write-Host "$(Split-Path $lib -Leaf)" -ForegroundColor Red
}
}
# Generate .clangd configuration file
$clangdContent = @"
CompileFlags:
CompilationDatabase: build/
Add:
- -I$sdkBase\Include\$latestSdk\um
- -I$sdkBase\Include\$latestSdk\shared
- -I$sdkBase\Include\$latestSdk\ucrt
- -I$vcTools\include
- -I`${workspaceFolder}/include
- -I`${workspaceFolder}/../../.temp/target/release
Remove: []
Diagnostics:
ClangTidy:
Add:
- "*"
Remove:
- modernize-use-trailing-return-type
UnusedIncludes: Strict
Index:
Background: Build
"@
$clangdPath = "..\.clangd"
$clangdContent | Out-File -FilePath $clangdPath -Encoding UTF8
|