This commit is contained in:
David Chen
2025-12-20 03:39:49 +08:00
committed by GitHub
parent 3f2cd50eaa
commit 540b8dc103
8 changed files with 349 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
## setup dev env
### install cmake & ninja
```
# linux
sudo apt install ninja-build
CMAKE_VER=v4.2.1
sudo apt install libssl-dev openssl
git clone --branch $CMAKE_VER --depth 1 https://github.com/Kitware/CMake.git
cd CMake
./bootstrap && make && sudo make install
# mac
brew install cmake ninja
```
### install dependencies
```bash
vcpkg --disable-metrics install --recurse
```
### update vcpkg baseline
```bash
vcpkg --disable-metrics x-update-baseline
```
### show package versions
```bash
vcpkg --disable-metrics list
```
### create `CMakeUserPresets.json`
```json
{
"version": 2,
"configurePresets": [
{
"name": "default",
"inherits": "vcpkg",
"environment": {
"VCPKG_ROOT": "path/to/vcpkg"
}
}
]
}
```
## format
```bash
find . \( -path ./build -o -path ./vcpkg_installed \) -prune -o \
-type f \( -name '*.cc' -o -name '*.h' \) -exec clang-format -i {} +
```
## build
```
cmake --preset=default
cmake --build build
```
## run
spin up a local redis server
```
docker run --name redis -p 6379:6379 -it redis:8.4.0
```
run the binary
```
./build/main
```
push messages with `redis-cli`
```
docker exec -it redis redis-cli -h localhost -p 6379
XADD key_01 * f1 v1 f2 v2
```
## clean
```
rm -rf ./build
rm -rf $HOME/.cache/vcpkg
```