From 58310fc96772a8b72fe48db73c3f6b0509784d34 Mon Sep 17 00:00:00 2001 From: neru Date: Fri, 20 Mar 2026 03:59:03 -0300 Subject: [PATCH] build: add build script and task --- .gitignore | 1 + .vscode/tasks.json | 16 ++++++++++++++++ create-project.ps1 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/tasks.json create mode 100644 create-project.ps1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..146b237 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/proj/* \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..57b3989 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Create project", + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + }, + "windows": { + "command": "${workspaceRoot}\\create-project.ps1" + }, + } + ], +} \ No newline at end of file diff --git a/create-project.ps1 b/create-project.ps1 new file mode 100644 index 0000000..a15c8bd --- /dev/null +++ b/create-project.ps1 @@ -0,0 +1,44 @@ +$projectFolder = "proj" +$slnName = "dbd-unlocker" + +function Initialize-Project { + # generation + Write-Host "Generating project" + Set-Location $projectFolder + $cmakeProcess = Start-Process -FilePath cmake -ArgumentList @("..") -NoNewWindow -Wait -PassThru + Set-Location .. + + if ($cmakeProcess.ExitCode -ne 0) { + Write-Host "CMake generation failed" + exit 1 + } + + # sln open + try { + $slnPath = "$projectFolder\$slnName.sln" + + $solutionFile = Get-Item -Path $slnPath -ErrorAction Stop + $solutionFullName = $solutionFile.FullName + + $vsProcesses = Get-CimInstance -Query "SELECT CommandLine FROM Win32_Process WHERE Name = 'devenv.exe'" + $pattern = [Regex]::Escape($solutionFullName) + $isOpen = $vsProcesses | Where-Object { $_.CommandLine -match $pattern } + + if (-not $isOpen) { + Write-Host "Starting Visual Studio..." -ForegroundColor Cyan + Start-Process -FilePath $solutionFullName + } + else { + Write-Host "Solution '$($solutionFile.Name)' is already open." -ForegroundColor Yellow + } + } + catch { + Write-Error "Failed to open solution: $($_.Exception.Message)" + } +} + +if (-not (Test-Path $projectFolder)) { + New-Item -ItemType Directory -Path $projectFolder | Out-Null +} + +Initialize-Project \ No newline at end of file