{ "version": "2.0.0", "tasks": [ { "label": "Silent Auto-Pull", "type": "shell", "command": "git pull", "runOptions": { "runOn": "folderOpen" }, "presentation": { "reveal": "never", "panel": "shared", "showReuseMessage": false, "clear": true } }, { "label": "C/C++: build active file", "type": "shell", "command": "$sep1='─────────────────────────────────────────'; $sep2='═════════════════════════════════════════'; $compiler=if('${fileExtname}' -eq '.cpp'){'C:\\MinGW\\bin\\g++.exe'}else{'C:\\MinGW\\bin\\gcc.exe'}; $exe='${fileDirname}\\${fileBasenameNoExtension}.exe'; Write-Host ('• Building ${fileBasename}...') -ForegroundColor Yellow -NoNewline; $bsw=[System.Diagnostics.Stopwatch]::StartNew(); & $compiler -fdiagnostics-color=always -g '${file}' -o $exe 2>&1; $bsw.Stop(); $bms=$bsw.ElapsedMilliseconds; if ($LASTEXITCODE -ne 0) { Write-Host ' failed' -ForegroundColor Red; exit 1 }; if ($bms -ge 1000) { $bt=([math]::Round($bms/1000,2).ToString()+' s') } else { $bt=($bms.ToString()+' ms') }; Write-Host (' done ('+$bt+')') -ForegroundColor Green; Write-Host $sep2 -ForegroundColor DarkGray", "args": [], "options": { "cwd": "${fileDirname}", "shell": { "executable": "powershell.exe", "args": ["-NoProfile", "-Command"] } }, "problemMatcher": ["$gcc"], "group": "build", "detail": "Auto-selects gcc for .c and g++ for .cpp" }, { "label": "C/C++: build and run active file", "type": "shell", "command": "$sep1='─────────────────────────────────────────'; $sep2='═════════════════════════════════════════'; $compiler=if('${fileExtname}' -eq '.cpp'){'C:\\MinGW\\bin\\g++.exe'}else{'C:\\MinGW\\bin\\gcc.exe'}; $exe='${fileDirname}\\${fileBasenameNoExtension}.exe'; Write-Host ('• Building ${fileBasename}...') -ForegroundColor Yellow -NoNewline; $bsw=[System.Diagnostics.Stopwatch]::StartNew(); & $compiler -fdiagnostics-color=always -g '${file}' -o $exe 2>&1; $bsw.Stop(); $bms=$bsw.ElapsedMilliseconds; if ($LASTEXITCODE -ne 0) { Write-Host ' failed' -ForegroundColor Red; exit 1 }; if ($bms -ge 1000) { $bt=([math]::Round($bms/1000,2).ToString()+' s') } else { $bt=($bms.ToString()+' ms') }; Write-Host (' done ('+$bt+')') -ForegroundColor Green; $size=0; if (Test-Path $exe) { $size=[math]::Round((Get-Item $exe).length / 1KB, 2) }; Write-Host ('• Running ${fileBasenameNoExtension}.exe') -ForegroundColor Cyan; Write-Host $sep1 -ForegroundColor Blue; $sw=[System.Diagnostics.Stopwatch]::StartNew(); & $exe; $exit=$LASTEXITCODE; $sw.Stop(); $ms=$sw.ElapsedMilliseconds; Remove-Item $exe -Force -ErrorAction SilentlyContinue; Write-Host ([char]10 + $sep1) -ForegroundColor Blue; if ($ms -ge 1000) { $rt=([math]::Round($ms/1000,2).ToString()+' s ('+$ms.ToString()+' ms)') } else { $rt=($ms.ToString()+' ms') }; if ($exit -eq 0) { Write-Host ('• Clean Exit (Code 0)') -ForegroundColor Green } else { Write-Host ('• Error Exit (Code '+$exit+')') -ForegroundColor Red }; Write-Host ('• Time : '+$rt) -ForegroundColor Magenta; Write-Host ('• Size : '+$size+' KB') -ForegroundColor DarkYellow; Write-Host $sep2 -ForegroundColor DarkGray", "args": [], "options": { "cwd": "${fileDirname}", "shell": { "executable": "powershell.exe", "args": ["-NoProfile", "-Command"] } }, "problemMatcher": ["$gcc"], "group": { "kind": "build", "isDefault": true }, "presentation": { "echo": false, "reveal": "always", "focus": true, "panel": "shared", "showReuseMessage": true, "clear": true }, "detail": "Builds, runs, deletes exe — only runs if build succeeds" } ] }