From 30125387254bf43f0766a17bf27ab0234016c4f6 Mon Sep 17 00:00:00 2001 From: neru Date: Wed, 17 Jun 2026 20:59:45 -0300 Subject: [PATCH] feat: add format and project gen scripts --- create-project.ps1 | 53 ++++++++++++++++++++++++++++++++++++++++++++++ format-code.ps1 | 9 ++++++++ 2 files changed, 62 insertions(+) create mode 100644 create-project.ps1 create mode 100644 format-code.ps1 diff --git a/create-project.ps1 b/create-project.ps1 new file mode 100644 index 0000000..483f2ef --- /dev/null +++ b/create-project.ps1 @@ -0,0 +1,53 @@ +$projectFolder = "proj" +$slnName = "hex-unlocked" + +function Initialize-Project { + # generation + Write-Host "Generating project" + Set-Location $projectFolder + + cmake .. -G "Visual Studio 17 2022" -A x64 ` + -DCMAKE_CONFIGURATION_TYPES="Debug;Release" ` + -DCMAKE_VS_PLATFORM_NAME="x64" ` + -DUNLOCKER_DUMPER=ON + + dotnet restore "$slnName.sln" --arch x64 + + $exitCode = $LASTEXITCODE + + if ($exitCode -ne 0) { + Write-Host "CMake generation failed with exit code: $exitCode" -ForegroundColor Red + exit 1 + } + + Set-Location .. + + # 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 diff --git a/format-code.ps1 b/format-code.ps1 new file mode 100644 index 0000000..8c9afe5 --- /dev/null +++ b/format-code.ps1 @@ -0,0 +1,9 @@ +Write-Host "Formatting sources..." + +$extensions = "*.cpp", "*.h", "*.cs" +Get-ChildItem -Path "src" -Include $extensions -Recurse | ForEach-Object { + Write-Host "Formatting: $($_.FullName)" + clang-format -i "$($_.FullName)" +} + +Write-Host "Done!" \ No newline at end of file