docs: add AGENTS.md with custom-image dependency install rule #27
@@ -31,6 +31,8 @@ if(SANITIZER STREQUAL "address")
|
|||||||
elseif(SANITIZER STREQUAL "thread")
|
elseif(SANITIZER STREQUAL "thread")
|
||||||
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer -g)
|
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer -g)
|
||||||
add_link_options(-fsanitize=thread)
|
add_link_options(-fsanitize=thread)
|
||||||
|
elseif(NOT SANITIZER STREQUAL "none")
|
||||||
|
message(FATAL_ERROR "Unknown sanitizer: ${SANITIZER}. Supported values: address, thread, none")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(STRICT_WARNINGS "Enable strict warnings" OFF)
|
option(STRICT_WARNINGS "Enable strict warnings" OFF)
|
||||||
@@ -47,7 +49,7 @@ find_package(Threads REQUIRED)
|
|||||||
|
|
||||||
find_library(ZSTD_LIBRARY zstd)
|
find_library(ZSTD_LIBRARY zstd)
|
||||||
if(NOT ZSTD_LIBRARY)
|
if(NOT ZSTD_LIBRARY)
|
||||||
message(FATAL_ERROR "zstd library not found")
|
message(FATAL_ERROR "zstd library not found. Ensure it is in your nix-shell!")
|
||||||
endif()
|
endif()
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
|
|
||||||
@@ -80,13 +82,15 @@ tests/ — test sources (globbed as TEST_SRCS)
|
|||||||
### Dependencies
|
### Dependencies
|
||||||
- **zstd** — found via `find_library(ZSTD_LIBRARY zstd)`
|
- **zstd** — found via `find_library(ZSTD_LIBRARY zstd)`
|
||||||
- **pthreads** — found via `find_package(Threads REQUIRED)`
|
- **pthreads** — found via `find_package(Threads REQUIRED)`
|
||||||
|
- **OpenSSL** — found via `find_package(OpenSSL REQUIRED)`
|
||||||
|
- **xxhash** — fetched via `FetchContent` from GitHub (v0.8.3)
|
||||||
- **C11 standard** — required
|
- **C11 standard** — required
|
||||||
- **CMake 3.22+** — minimum version
|
- **CMake 3.22+** — minimum version
|
||||||
|
|
||||||
## Conventions
|
## Conventions
|
||||||
|
|
||||||
- Use `file(GLOB ...)` for source collection (existing pattern).
|
- Use `file(GLOB ...)` for source collection (existing pattern).
|
||||||
- All targets link `Threads::Threads` and `${ZSTD_LIBRARY}`.
|
- All targets link `Threads::Threads`, `${ZSTD_LIBRARY}`, `OpenSSL::SSL`, `OpenSSL::Crypto`, and `xxhash`.
|
||||||
- Include directories: `src/shared`, `src/server`, `src/client`, `tests` (for test target).
|
- Include directories: `src/shared`, `src/server`, `src/client`, `tests` (for test target).
|
||||||
- Sanitizer support: pass `-DSANITIZER=address` or `-DSANITIZER=thread` to cmake (live option in CMakeLists.txt).
|
- Sanitizer support: pass `-DSANITIZER=address` or `-DSANITIZER=thread` to cmake (live option in CMakeLists.txt).
|
||||||
- Build with `cmake -B build -S . && cmake --build build -j$(nproc)`.
|
- Build with `cmake -B build -S . && cmake --build build -j$(nproc)`.
|
||||||
@@ -104,23 +108,16 @@ tests/ — test sources (globbed as TEST_SRCS)
|
|||||||
|
|
||||||
## Sanitizer Configurations
|
## Sanitizer Configurations
|
||||||
|
|
||||||
### AddressSanitizer (memory errors)
|
Use the project's built-in `-DSANITIZER=` option (matching the CI matrix):
|
||||||
```bash
|
```bash
|
||||||
cmake -B build -S . \
|
cmake -B build -S . -DSANITIZER=address # AddressSanitizer (memory errors)
|
||||||
-DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer -g" \
|
cmake --build build -j$(nproc)
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
|
|
||||||
|
cmake -B build -S . -DSANITIZER=thread # ThreadSanitizer (race conditions)
|
||||||
cmake --build build -j$(nproc)
|
cmake --build build -j$(nproc)
|
||||||
```
|
```
|
||||||
|
|
||||||
### ThreadSanitizer (race conditions)
|
For UndefinedBehaviorSanitizer (no `-DSANITIZER=undefined` option in CMakeLists.txt yet), use the manual flag approach:
|
||||||
```bash
|
|
||||||
cmake -B build -S . \
|
|
||||||
-DCMAKE_C_FLAGS="-fsanitize=thread -g" \
|
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread"
|
|
||||||
cmake --build build -j$(nproc)
|
|
||||||
```
|
|
||||||
|
|
||||||
### UndefinedBehaviorSanitizer
|
|
||||||
```bash
|
```bash
|
||||||
cmake -B build -S . \
|
cmake -B build -S . \
|
||||||
-DCMAKE_C_FLAGS="-fsanitize=undefined -fno-omit-frame-pointer -g" \
|
-DCMAKE_C_FLAGS="-fsanitize=undefined -fno-omit-frame-pointer -g" \
|
||||||
@@ -128,14 +125,6 @@ cmake -B build -S . \
|
|||||||
cmake --build build -j$(nproc)
|
cmake --build build -j$(nproc)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Combined Sanitizers
|
|
||||||
```bash
|
|
||||||
cmake -B build -S . \
|
|
||||||
-DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g" \
|
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined"
|
|
||||||
cmake --build build -j$(nproc)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using ccache (faster rebuilds)
|
### Using ccache (faster rebuilds)
|
||||||
```bash
|
```bash
|
||||||
cmake -B build -S . -DCMAKE_C_COMPILER_LAUNCHER=ccache
|
cmake -B build -S . -DCMAKE_C_COMPILER_LAUNCHER=ccache
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ docker pull gitea.tap-tap.win/taptap/fastsync-ci:v7
|
|||||||
docker tag gitea.tap-tap.win/taptap/fastsync-ci:v7 fastsync-ci:local
|
docker tag gitea.tap-tap.win/taptap/fastsync-ci:v7 fastsync-ci:local
|
||||||
|
|
||||||
# Or build the image from the repo-root Dockerfile
|
# Or build the image from the repo-root Dockerfile
|
||||||
|
# (Note: the prebuilt :v7 image reflects the previous Dockerfile state;
|
||||||
|
# rebuild from source to pick up any newly added packages like lcov/valgrind.)
|
||||||
docker build -t fastsync-ci:local .
|
docker build -t fastsync-ci:local .
|
||||||
|
|
||||||
# Build, run unit tests, and run integration tests inside the container
|
# Build, run unit tests, and run integration tests inside the container
|
||||||
@@ -39,7 +41,7 @@ cmake -B build -S . -DSANITIZER=address # AddressSanitizer (ASan)
|
|||||||
cmake -B build -S . -DSANITIZER=thread # ThreadSanitizer (TSan)
|
cmake -B build -S . -DSANITIZER=thread # ThreadSanitizer (TSan)
|
||||||
```
|
```
|
||||||
|
|
||||||
The CI workflow (`.gitea/workflows/ci.yaml`) runs lint (clang-format, cppcheck), build + test (unit + integration), and sanitizer jobs sequentially.
|
The CI workflow (`.gitea/workflows/ci.yaml`) runs lint (clang-format, cppcheck), build + test (unit + integration), and sanitizer (currently only `address`) jobs sequentially.
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user