From b4e40d44c4006c8aa25e1b815a2881539ffd7dc4 Mon Sep 17 00:00:00 2001 From: elpatron Date: Fri, 29 Aug 2025 09:49:42 +0200 Subject: [PATCH] chore(windows): replace PowerShell build with build_windows.bat; update README and release script --- README.md | 43 ++++--------- .../{build_thinkpad.bat => build_windows.bat} | 5 +- scripts/build_windows.ps1 | 62 ------------------- scripts/create_release.ps1 | 12 ++-- 4 files changed, 20 insertions(+), 102 deletions(-) rename scripts/{build_thinkpad.bat => build_windows.bat} (96%) delete mode 100644 scripts/build_windows.ps1 diff --git a/README.md b/README.md index d179981..3c769b1 100644 --- a/README.md +++ b/README.md @@ -89,35 +89,20 @@ The project includes several build scripts in the `scripts/` directory for diffe ### Windows Build Scripts -#### PowerShell Build (Recommended) -**File:** `scripts/build_windows.ps1` -**Requirements:** PowerShell, Visual Studio 2022 Build Tools (C++), vcpkg (will be bootstrapped), Git - -```powershell -# Run from project root -powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_windows.ps1 -``` - -This script: -- Automatically bootstraps vcpkg if not present -- Configures CMake with Visual Studio 2022 generator -- Builds the project in Release configuration -- Creates a Windows distribution package with all artifacts - -#### Command Line Build -**File:** `scripts/build_thinkpad.bat` -**Requirements:** Visual Studio 2022 Build Tools/Community with C++ workload, vcpkg +#### Windows Build (Recommended) +**File:** `scripts/build_windows.bat` +**Requirements:** Visual Studio 2022 Build Tools/Community with C++ workload, vcpkg, Git ```cmd # Run from project root -scripts\build_thinkpad.bat +scripts\build_windows.bat ``` This script: -- Automatically detects and initializes Visual Studio environment -- Handles vcpkg bootstrapping -- Configures CMake with proper toolchain -- Builds the project using MSVC compiler +- Automatically detects and initializes the Visual Studio environment +- Bootstraps vcpkg if not present +- Configures CMake with the Visual Studio 2022 generator and vcpkg toolchain +- Builds the project in Release configuration using MSVC ### Linux Build Scripts @@ -196,16 +181,10 @@ This script: ### Compilation -#### Windows (PowerShell) - Build via scripts/build_windows.ps1 -```powershell -# Requires: PowerShell, Visual Studio 2022 Build Tools (C++), vcpkg (will be bootstrapped), Git -powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_windows.ps1 -``` - -#### Windows (Command Line) - Build via scripts/build_thinkpad.bat +#### Windows - Build via scripts/build_windows.bat ```cmd -# Requires: Visual Studio 2022 Build Tools/Community with C++ workload, vcpkg -scripts\build_thinkpad.bat +# Requires: Visual Studio 2022 Build Tools/Community with C++ workload, vcpkg, Git +scripts\build_windows.bat ``` #### Linux - Automated Build via scripts/build.sh diff --git a/scripts/build_thinkpad.bat b/scripts/build_windows.bat similarity index 96% rename from scripts/build_thinkpad.bat rename to scripts/build_windows.bat index cae737d..d2b694b 100644 --- a/scripts/build_thinkpad.bat +++ b/scripts/build_windows.bat @@ -21,10 +21,10 @@ if errorlevel 1 ( REM Ensure vswhere is on PATH (both PF and PF(x86)) set "PATH=%ProgramFiles%\Microsoft Visual Studio\Installer;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer;%PATH%" REM First try well-known VsDevCmd from BuildTools/Community to avoid vswhere dependency - set "VSINSTALL=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" + set "VSINSTALL=C:\ Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" set "VSDEVCMD_CANDIDATE=%VSINSTALL%\Common7\Tools\VsDevCmd.bat" if not exist "%VSDEVCMD_CANDIDATE%" ( - set "VSINSTALL=C:\Program Files\Microsoft Visual Studio\2022\Community" + set "VSINSTALL=C:\ Program Files\Microsoft Visual Studio\2022\Community" set "VSDEVCMD_CANDIDATE=%VSINSTALL%\Common7\Tools\VsDevCmd.bat" ) if exist "%VSDEVCMD_CANDIDATE%" ( @@ -126,3 +126,4 @@ if %BUILD_ERROR% EQU 0 ( popd exit /b %BUILD_ERROR% + diff --git a/scripts/build_windows.ps1 b/scripts/build_windows.ps1 deleted file mode 100644 index 308ec3f..0000000 --- a/scripts/build_windows.ps1 +++ /dev/null @@ -1,62 +0,0 @@ -# Requires: PowerShell, Visual Studio 2022 Build Tools (C++), vcpkg (will be bootstrapped), Git -# Usage: -# powershell -NoProfile -ExecutionPolicy Bypass -File .\build_windows.ps1 - -Set-StrictMode -Version Latest -$ErrorActionPreference = 'Stop' - -Write-Host "Building PrivateBin API C++ (Windows, x64, Release)" -ForegroundColor Cyan - -# Resolve vcpkg root -if (-not $env:VCPKG_ROOT) { - $env:VCPKG_ROOT = Join-Path $env:USERPROFILE 'vcpkg' -} - -if (-not (Test-Path $env:VCPKG_ROOT)) { - Write-Host "Cloning vcpkg into $env:VCPKG_ROOT ..." - git clone https://github.com/microsoft/vcpkg $env:VCPKG_ROOT - & "$env:VCPKG_ROOT\bootstrap-vcpkg.bat" -} - -# Choose generator (VS 2022) -$generator = 'Visual Studio 17 2022' -$arch = 'x64' - -# Clean and configure -if (Test-Path build) { Remove-Item -Recurse -Force build } -cmake -S . -B build -G "$generator" -A $arch -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake" - -# Build -cmake --build build --config Release - -Write-Host "Build completed." -ForegroundColor Green - -# Package artifacts (zip) -$dist = Join-Path (Get-Location) 'dist\windows' -if (Test-Path $dist) { Remove-Item -Recurse -Force $dist } -New-Item -ItemType Directory -Force -Path $dist | Out-Null - -# Collect artifacts -$binDir = Join-Path (Get-Location) 'build\Release' -$exampleDir = Join-Path (Get-Location) 'build\example\Release' - -$dll = Join-Path $binDir 'privatebinapi.dll' -$lib = Join-Path $binDir 'privatebinapi.lib' -$pdb = Join-Path $binDir 'privatebinapi.pdb' -$exe = Join-Path $exampleDir 'example.exe' - -Copy-Item -Path $dll -Destination $dist -ErrorAction SilentlyContinue -Copy-Item -Path $lib -Destination $dist -ErrorAction SilentlyContinue -Copy-Item -Path $pdb -Destination $dist -ErrorAction SilentlyContinue -Copy-Item -Path $exe -Destination $dist -ErrorAction SilentlyContinue -Copy-Item -Path (Join-Path (Get-Location) 'include') -Destination $dist -Recurse -Copy-Item -Path (Join-Path (Get-Location) 'README.md') -Destination $dist -Copy-Item -Path (Join-Path (Get-Location) 'LICENSE') -Destination $dist -ErrorAction SilentlyContinue - -$zipPath = Join-Path (Get-Location) 'dist\lib-privatebin-v0.1.1.3-windows-x64.zip' -if (Test-Path $zipPath) { Remove-Item -Force $zipPath } -Compress-Archive -Path (Join-Path $dist '*') -DestinationPath $zipPath - -Write-Host "Windows artifact packaged:" -ForegroundColor Cyan -Write-Host " $zipPath" - diff --git a/scripts/create_release.ps1 b/scripts/create_release.ps1 index e554dad..f70b04b 100644 --- a/scripts/create_release.ps1 +++ b/scripts/create_release.ps1 @@ -43,12 +43,12 @@ if ($lastTag -match "^v(\d+)\.(\d+)\.(\d+)(.*)$") { # Build durchführen Write-Host "Führe Build durch..." -ForegroundColor Yellow -if (Test-Path "scripts\build_thinkpad.bat") { - Write-Host "Verwende scripts\build_thinkpad.bat..." -ForegroundColor Yellow - cmd /c scripts\build_thinkpad.bat +if (Test-Path "scripts\build_windows.bat") { + Write-Host "Verwende scripts\build_windows.bat..." -ForegroundColor Yellow + cmd /c scripts\build_windows.bat } else { - Write-Host "Verwende scripts\build_windows.ps1..." -ForegroundColor Yellow - powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_windows.ps1 + Write-Host "Fehler: scripts\build_windows.bat nicht gefunden!" -ForegroundColor Red + exit 1 } if ($LASTEXITCODE -ne 0) { Write-Host "Build fehlgeschlagen!" -ForegroundColor Red @@ -69,7 +69,7 @@ git tag -a $newVersion -m "Release $newVersion" git push origin $newVersion # Release erstellen -$releaseBody = "## What is New in $newVersion`n`n- AUTOMATED: Release created by script`n- VERSION: Bumped from $lastTag to $newVersion`n- BUILD: Automatic build with build_thinkpad.bat`n`n## Build Artifacts`n`nBuild-Artefakte werden automatisch hochgeladen und hier angezeigt.`n`nTypische Artefakte:`n- privatebinapi.dll - Windows Dynamic Link Library`n- privatebinapi.lib - Windows Import Library`n- example.exe - Combined example program`n- privatebinapi.h - C++ header file" +$releaseBody = "## What is New in $newVersion`n`n- AUTOMATED: Release created by script`n- VERSION: Bumped from $lastTag to $newVersion`n- BUILD: Automatic build with build_windows.bat`n`n## Build Artifacts`n`nBuild-Artefakte werden automatisch hochgeladen und hier angezeigt.`n`nTypische Artefakte:`n- privatebinapi.dll - Windows Dynamic Link Library`n- privatebinapi.lib - Windows Import Library`n- example.exe - Combined example program`n- privatebinapi.h - C++ header file" $releaseData = @{ tag_name = $newVersion