Tests: add live integration test (optional via PRIVATEBIN_IT), fix WinHTTP host/port + TLS opts, robust JSON parser (meta.time_to_live), CTest wiring; Add LLVM/clang-cl coverage option and docs; add build_thinkpad.bat; README updates

This commit is contained in:
mbusc
2025-08-28 15:22:00 +02:00
parent 7a125a4c9c
commit 0f58d40f52
10 changed files with 467 additions and 39 deletions

128
build_thinkpad.bat Normal file
View File

@ -0,0 +1,128 @@
@echo off
setlocal ENABLEDELAYEDEXPANSION
echo Building PrivateBin API C++ DLL...
REM Proaktiv: VS-Entwicklungsumgebung initialisieren, wenn bekannt
set "VSINSTALL_HINT=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
set "VSDEVCMD_HINT=%VSINSTALL_HINT%\Common7\Tools\VsDevCmd.bat"
if not exist "%VSDEVCMD_HINT%" (
set "VSINSTALL_HINT=C:\Program Files\Microsoft Visual Studio\2022\Community"
set "VSDEVCMD_HINT=%VSINSTALL_HINT%\Common7\Tools\VsDevCmd.bat"
)
if exist "%VSDEVCMD_HINT%" (
echo Initializing MSVC environment from "%VSDEVCMD_HINT%" for x64...
call "%VSDEVCMD_HINT%" -arch=x64 >nul
set "VCPKG_VISUAL_STUDIO_PATH=%VSINSTALL_HINT%"
)
REM Ensure MSVC environment is loaded (cl.exe). Try via vswhere if not present.
where cl >nul 2>&1
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 "VSDEVCMD_CANDIDATE=%VSINSTALL%\Common7\Tools\VsDevCmd.bat"
if not exist "%VSDEVCMD_CANDIDATE%" (
set "VSINSTALL=C:\Program Files\Microsoft Visual Studio\2022\Community"
set "VSDEVCMD_CANDIDATE=%VSINSTALL%\Common7\Tools\VsDevCmd.bat"
)
if exist "%VSDEVCMD_CANDIDATE%" (
echo Initializing MSVC environment from "%VSDEVCMD_CANDIDATE%" for x64...
call "%VSDEVCMD_CANDIDATE%" -arch=x64 >nul
REM Provide VS path hint for vcpkg
set "VCPKG_VISUAL_STUDIO_PATH=%VSINSTALL%"
REM Re-check if cl is now available; if so, skip vswhere path
where cl >nul 2>&1
if not errorlevel 1 goto :after_vs_env
)
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%VSWHERE%" (
set "VSWHERE=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
)
if not exist "%VSWHERE%" (
set "VSWHERE=c:\tools\vswhere.exe"
)
if exist "%VSWHERE%" (
for /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSINSTALL=%%i"
if defined VSINSTALL (
set "VSDEVCMD=%VSINSTALL%\Common7\Tools\VsDevCmd.bat"
if exist "%VSDEVCMD%" (
echo Initializing MSVC environment from "%VSDEVCMD%" for x64...
call "%VSDEVCMD%" -arch=x64 >nul
set "VCPKG_VISUAL_STUDIO_PATH=%VSINSTALL%"
) else (
echo VsDevCmd.bat not found under "%VSINSTALL%". cl.exe may be unavailable.
)
) else (
echo Visual Studio with C++ tools not found. Install "Desktop development with C++" workload.
)
) else (
echo vswhere.exe not found. Consider installing Visual Studio 2022 with C++ tools.
)
)
:after_vs_env
REM Detect or bootstrap vcpkg
if not defined VCPKG_ROOT (
set "VCPKG_ROOT=%USERPROFILE%\vcpkg"
)
if not exist "%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake" (
echo vcpkg not found at "%VCPKG_ROOT%". Cloning and bootstrapping...
if not exist "%VCPKG_ROOT%" (
git clone https://github.com/microsoft/vcpkg.git "%VCPKG_ROOT%"
if errorlevel 1 (
echo Failed to clone vcpkg
exit /b 1
)
)
call "%VCPKG_ROOT%\bootstrap-vcpkg.bat"
if errorlevel 1 (
echo Failed to bootstrap vcpkg
exit /b 1
)
)
REM Ensure vcpkg manifest/config has a baseline; create vcpkg-configuration.json if missing
REM Baseline wird außerhalb des Skripts gesetzt (vcpkg x-update-baseline)
REM Reset build directory to avoid stale CMake cache (e.g., CMAKE_GENERATOR_INSTANCE)
if exist "build" rd /s /q build
mkdir build
pushd build
REM Generate build files with CMake and vcpkg (manifest mode with auto-baseline)
set "VCPKG_DEFAULT_TRIPLET=x64-windows"
REM Ensure no stale generator instance is leaking from environment
set "CMAKE_GENERATOR_INSTANCE="
REM Ensure vcpkg manifest has a builtin-baseline (adds if missing)
if exist "vcpkg.json" (
"%VCPKG_ROOT%\vcpkg.exe" x-update-baseline --add-initial-baseline 1>nul 2>nul
)
REM Use user vcpkg toolchain
set "TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake"
cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE="%TOOLCHAIN_FILE%"
if errorlevel 1 (
echo CMake configuration failed
popd
exit /b 1
)
REM Build the project
cmake --build . --config Release
set BUILD_ERROR=%ERRORLEVEL%
if %BUILD_ERROR% EQU 0 (
echo Build completed successfully!
) else (
echo Build failed with error level %BUILD_ERROR%
)
popd
exit /b %BUILD_ERROR%