Compare commits
6 Commits
v0.1.1
...
d04fae8bbd
| Author | SHA1 | Date | |
|---|---|---|---|
| d04fae8bbd | |||
| 48eec02cca | |||
| 8c4926cbae | |||
| bafe712020 | |||
| 063800df12 | |||
|
|
df74c8a1af |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,6 +2,8 @@
|
|||||||
build/
|
build/
|
||||||
cmake-build-*/
|
cmake-build-*/
|
||||||
|
|
||||||
|
dist/
|
||||||
|
|
||||||
# Compiled object files
|
# Compiled object files
|
||||||
*.o
|
*.o
|
||||||
*.obj
|
*.obj
|
||||||
|
|||||||
16
CHANGELOG.md
Normal file
16
CHANGELOG.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
## v0.1.1.3 (2025-08-28)
|
||||||
|
|
||||||
|
- Docs: Added Linux (WSL/Ubuntu) quick start, build and test instructions in `README.md`.
|
||||||
|
- Build: `build.sh` now bootstraps vcpkg and uses the vcpkg toolchain; builds library, tests, and example.
|
||||||
|
|
||||||
|
## v0.1.1.2 (2025-08-28)
|
||||||
|
|
||||||
|
- Example: Made `example/CMakeLists.txt` platform-neutral; links against in-tree target `privatebinapi`.
|
||||||
|
- Linux HTTP client: Fixed delete operation to use HTTP POST (required by PrivateBin API) instead of DELETE; resolves 405 errors when deleting.
|
||||||
|
- Build: Verified successful build on Linux (WSL/Ubuntu) via vcpkg toolchain.
|
||||||
|
- Tests: `test_basic` runs successfully via `ctest`.
|
||||||
|
|
||||||
|
## v0.1.1.1 and earlier
|
||||||
|
|
||||||
|
- Initial cross-platform library skeleton with Crypto++ and nlohmann-json via vcpkg.
|
||||||
|
|
||||||
@@ -70,6 +70,7 @@ install(FILES ${HEADERS} DESTINATION include/privatebinapi)
|
|||||||
include(CTest)
|
include(CTest)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
add_subdirectory(example)
|
||||||
|
|
||||||
# ===================== LLVM/clang-cl Coverage (optional) =====================
|
# ===================== LLVM/clang-cl Coverage (optional) =====================
|
||||||
option(ENABLE_LLVM_COVERAGE "Enable LLVM/clang-cl coverage instrumentation" OFF)
|
option(ENABLE_LLVM_COVERAGE "Enable LLVM/clang-cl coverage instrumentation" OFF)
|
||||||
|
|||||||
74
README.md
74
README.md
@@ -70,6 +70,60 @@ cmake -S example -B example/build -DCMAKE_BUILD_TYPE=Release
|
|||||||
cmake --build example/build --config Release
|
cmake --build example/build --config Release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Linux (WSL/Ubuntu) – Quick start
|
||||||
|
|
||||||
|
Prerequisites (Ubuntu/Debian):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt-get update -y && sudo apt-get install -y \
|
||||||
|
build-essential cmake git pkg-config libcurl4-openssl-dev \
|
||||||
|
curl zip unzip tar ninja-build ca-certificates
|
||||||
|
```
|
||||||
|
|
||||||
|
Bootstrap vcpkg (once):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/microsoft/vcpkg.git "$HOME/vcpkg"
|
||||||
|
"$HOME/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
|
||||||
|
```
|
||||||
|
|
||||||
|
Build (library, tests, example):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export VCPKG_ROOT="$HOME/vcpkg"
|
||||||
|
cmake -S . -B build -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
cmake --build build --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
Or simply use the helper script:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash ./build.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Run the example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./build/example/example
|
||||||
|
```
|
||||||
|
|
||||||
|
Run tests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ctest --test-dir build --output-on-failure
|
||||||
|
```
|
||||||
|
|
||||||
|
Artifacts:
|
||||||
|
|
||||||
|
- Library: `build/libprivatebinapi.so`
|
||||||
|
- Example binary: `build/example/example`
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
- vcpkg dependencies (`cryptopp`, `nlohmann-json`) are installed automatically during CMake configure when the toolchain file is provided.
|
||||||
|
- On Linux the example links directly against the in-tree target `privatebinapi`. On Windows it additionally copies the DLL next to the example executable after build.
|
||||||
|
- PrivateBin delete operation is performed via HTTP POST (per API), not HTTP DELETE.
|
||||||
|
|
||||||
### Windows (PowerShell) – Build via build_thinkpad.bat
|
### Windows (PowerShell) – Build via build_thinkpad.bat
|
||||||
|
|
||||||
For systems with Visual Studio 2022 Build Tools (C++ workload) and vcpkg in the user profile, there is a robust build script:
|
For systems with Visual Studio 2022 Build Tools (C++ workload) and vcpkg in the user profile, there is a robust build script:
|
||||||
@@ -225,3 +279,23 @@ cmd /c "call ""C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Co
|
|||||||
Notes:
|
Notes:
|
||||||
- If Ninja is not available, you can use the VS generator, but Ninja is recommended for clang.
|
- If Ninja is not available, you can use the VS generator, but Ninja is recommended for clang.
|
||||||
- You can override `LLVM_PROFDATA` and `LLVM_COV` cache variables to absolute tool paths if needed.
|
- You can override `LLVM_PROFDATA` and `LLVM_COV` cache variables to absolute tool paths if needed.
|
||||||
|
|
||||||
|
### Windows – Quick start (vcpkg + VS 2022)
|
||||||
|
|
||||||
|
Build and package using the helper script:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:VCPKG_ROOT = "$env:USERPROFILE\vcpkg"
|
||||||
|
if (-not (Test-Path $env:VCPKG_ROOT)) { git clone https://github.com/microsoft/vcpkg $env:VCPKG_ROOT; & "$env:VCPKG_ROOT\bootstrap-vcpkg.bat" }
|
||||||
|
powershell -NoProfile -ExecutionPolicy Bypass -File .\build_windows.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
Artifacts:
|
||||||
|
|
||||||
|
- DLL/LIB in `build\Release` and packaged zip at `dist\lib-privatebin-v0.1.1.3-windows-x64.zip`
|
||||||
|
- Example: `build\example\Release\example.exe` (also included in the zip if present)
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
- Ensure Visual Studio 2022 Build Tools (C++ workload) and Windows 11 SDK are installed.
|
||||||
|
- The example links against the in-tree library target. The script copies DLL/LIB/PDB (if available), headers, README, and LICENSE into the package.
|
||||||
27
build.sh
27
build.sh
@@ -1,15 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo "Building PrivateBin API C++ DLL..."
|
set -euo pipefail
|
||||||
|
echo "Building PrivateBin API C++ (library + example)"
|
||||||
|
|
||||||
# Create build directory
|
# Ensure vcpkg exists
|
||||||
mkdir -p build
|
VCPKG_ROOT="${VCPKG_ROOT:-$HOME/vcpkg}"
|
||||||
cd build
|
if [ ! -d "$VCPKG_ROOT" ]; then
|
||||||
|
echo "vcpkg not found under $VCPKG_ROOT, cloning..."
|
||||||
|
git clone https://github.com/microsoft/vcpkg.git "$VCPKG_ROOT"
|
||||||
|
"$VCPKG_ROOT/bootstrap-vcpkg.sh" -disableMetrics
|
||||||
|
fi
|
||||||
|
|
||||||
# Generate build files with CMake
|
# Clean and configure
|
||||||
cmake ..
|
rm -rf build
|
||||||
|
cmake -S . -B build -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
|
||||||
# Build the project
|
# Build all targets
|
||||||
make
|
cmake --build build --config Release
|
||||||
|
|
||||||
echo "Build completed!"
|
echo "Build completed. Artifacts:"
|
||||||
cd ..
|
echo " - Library: build/libprivatebinapi.so"
|
||||||
|
echo " - Example: build/example/example"
|
||||||
62
build_windows.ps1
Normal file
62
build_windows.ps1
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# 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"
|
||||||
|
|
||||||
@@ -3,25 +3,15 @@ project(PrivateBinAPIExample)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
# Use the prebuilt library from the parent build directory
|
# Build example and link against the in-tree target
|
||||||
set(PRIVATEBINAPI_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../build")
|
|
||||||
set(PRIVATEBINAPI_RELEASE_LIB "${PRIVATEBINAPI_BUILD_DIR}/Release/privatebinapi.lib")
|
|
||||||
|
|
||||||
if(EXISTS "${PRIVATEBINAPI_RELEASE_LIB}")
|
|
||||||
set(PRIVATEBINAPI_LIB "${PRIVATEBINAPI_RELEASE_LIB}")
|
|
||||||
else()
|
|
||||||
# Fallback: try the build root (multi-config generators may place libs differently)
|
|
||||||
find_library(PRIVATEBINAPI_LIB privatebinapi PATHS "${PRIVATEBINAPI_BUILD_DIR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT PRIVATEBINAPI_LIB)
|
|
||||||
message(FATAL_ERROR "privatebinapi library not found. Please run build.bat in the project root first.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(example example.cpp)
|
add_executable(example example.cpp)
|
||||||
|
target_link_libraries(example PRIVATE privatebinapi)
|
||||||
|
|
||||||
target_link_libraries(example PRIVATE ${PRIVATEBINAPI_LIB} winhttp)
|
# On Windows, copy the DLL next to the example for easy execution
|
||||||
|
if(WIN32)
|
||||||
target_include_directories(example PRIVATE
|
add_custom_command(TARGET example POST_BUILD
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../include
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
)
|
$<TARGET_FILE:privatebinapi>
|
||||||
|
$<TARGET_FILE_DIR:example>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
@@ -585,7 +585,7 @@ bool HttpClient::delete_req(const std::string& url, const std::string& data, std
|
|||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
// PrivateBin API erwartet POST für delete
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
|
||||||
|
|||||||
@@ -26,3 +26,12 @@ target_include_directories(test_basic PRIVATE
|
|||||||
|
|
||||||
# Register the test with CTest
|
# Register the test with CTest
|
||||||
add_test(NAME test_basic COMMAND test_basic)
|
add_test(NAME test_basic COMMAND test_basic)
|
||||||
|
|
||||||
|
# Optional example run as a test (requires network and live server)
|
||||||
|
# Example-Test nur aktiv, wenn PRIVATEBIN_IT=1 gesetzt ist
|
||||||
|
add_test(NAME example_run COMMAND $<TARGET_FILE:example>)
|
||||||
|
if(DEFINED ENV{PRIVATEBIN_IT} AND NOT "$ENV{PRIVATEBIN_IT}" STREQUAL "0")
|
||||||
|
set_tests_properties(example_run PROPERTIES DISABLED FALSE)
|
||||||
|
else()
|
||||||
|
set_tests_properties(example_run PROPERTIES DISABLED TRUE)
|
||||||
|
endif()
|
||||||
Reference in New Issue
Block a user