尝试适配vs

This commit is contained in:
2026-05-08 18:32:28 +08:00
parent a0bae4b6b8
commit fd383481fd
7 changed files with 501 additions and 138 deletions
+75
View File
@@ -0,0 +1,75 @@
param(
[switch]$Run
)
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent $MyInvocation.MyCommand.Path
$ProjectDir = Join-Path $Root "src"
$IncludeDir = Join-Path $ProjectDir "include"
$SourceDir = Join-Path $ProjectDir "source"
$ResourceDir = Join-Path $ProjectDir "resources"
$AssetIconDir = Join-Path $Root "assets\icons"
$BuildDir = Join-Path $Root ".vscode-build\vs2026"
$ExePath = Join-Path $BuildDir "Tetris.exe"
$ResPath = Join-Path $BuildDir "Tetris.res"
$RcPath = Join-Path $ResourceDir "Tetris.rc"
if (-not (Get-Command cl.exe -ErrorAction SilentlyContinue)) {
throw "cl.exe not found. Open Visual Studio 2026: Tools -> Command Line -> Developer PowerShell, then run this script again."
}
if (-not (Get-Command rc.exe -ErrorAction SilentlyContinue)) {
throw "rc.exe not found. Install the Windows SDK from the Visual Studio Installer C++ desktop workload."
}
New-Item -ItemType Directory -Force -Path $BuildDir | Out-Null
$Sources = Get-ChildItem -Path $SourceDir -Recurse -Filter "*.cpp" |
Sort-Object FullName |
Select-Object -ExpandProperty FullName
if ($Sources.Count -lt 10) {
throw "Too few source files found under src\source. The render, app, logic, rogue, common, and extension modules must all be compiled."
}
& rc.exe `
/nologo `
/i $IncludeDir `
/i $AssetIconDir `
/fo $ResPath `
$RcPath
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
& cl.exe `
/nologo `
/utf-8 `
/std:c++17 `
/EHsc `
/Zi `
/Od `
/DUNICODE `
/D_UNICODE `
/D_WINDOWS `
/I $IncludeDir `
$Sources `
$ResPath `
/Fe:$ExePath `
/link `
/SUBSYSTEM:WINDOWS `
winmm.lib `
gdiplus.lib `
gdi32.lib `
user32.lib `
shell32.lib
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
if ($Run) {
Start-Process -FilePath $ExePath -WorkingDirectory $Root
}