diff options
Diffstat (limited to 'gui/win32/scripts/_entry.ps1')
| -rw-r--r-- | gui/win32/scripts/_entry.ps1 | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/gui/win32/scripts/_entry.ps1 b/gui/win32/scripts/_entry.ps1 new file mode 100644 index 0000000..1d49e46 --- /dev/null +++ b/gui/win32/scripts/_entry.ps1 @@ -0,0 +1,91 @@ +$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 + Remove: [] + +Diagnostics: + ClangTidy: + Add: + - "*" + Remove: + - modernize-use-trailing-return-type + UnusedIncludes: Strict + +Index: + Background: Build +"@ + +$clangdPath = "..\.clangd" +$clangdContent | Out-File -FilePath $clangdPath -Encoding UTF8 |
