Skip to content

Build System Spec ​

Overview ​

UVHTTP uses CMake as its build system. This spec defines the build configuration, C standard, compiler flags, and CI build matrix.

C Standard ​

  • Standard: C99 (CMAKE_C_STANDARD 99)
  • Enforcement: CMAKE_C_STANDARD_REQUIRED ON
  • Compiler support: GCC 4.8+, Clang 3.4+

Build Types ​

TypeCMake PresetFlagsUse Case
Debug-DCMAKE_BUILD_TYPE=Debug-g -O0Development, ASan
Release-DCMAKE_BUILD_TYPE=Release-O2 -DNDEBUGProduction, benchmarks
Coverage-DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON--coverageTest coverage analysis
ASan-DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON-fsanitize=addressMemory safety
UBSan-DCMAKE_BUILD_TYPE=Debug -DENABLE_UBSAN=ON-fsanitize=undefinedUB detection
Benchmark-DCMAKE_BUILD_TYPE=Release -DBUILD_BENCHMARKS=ON-O2 -DNDEBUGPerformance testing

Compiler Flags (All Builds) ​

cmake
-Wall -Wextra -Wformat=2 -Wformat-security
-fstack-protector-strong
-fno-common
-Werror
-Werror=implicit-function-declaration
-Werror=format-security
-Werror=return-type
-D_FORTIFY_SOURCE=2

Linker Flags (All Builds) ​

cmake
-Wl,-z,relro -Wl,-z,now

Feature Flags ​

FlagDefaultDescription
BUILD_WITH_WEBSOCKETONWebSocket support
BUILD_WITH_HTTPSONTLS support (mbedtls)
BUILD_WITH_MIMALLOCOFFUse mimalloc allocator
BUILD_WITH_COMPRESSIONOFFCompression support (zlib)
BUILD_TESTINGONBuild test suite
BUILD_EXAMPLESOFFBuild example programs
BUILD_BENCHMARKSOFFBuild benchmark server
UVHTTP_FEATURE_STATIC_FILESONStatic file serving
UVHTTP_FEATURE_RATE_LIMITONRate limiting
UVHTTP_FEATURE_LRU_CACHEONLRU cache
UVHTTP_FEATURE_MIDDLEWAREONMiddleware support
UVHTTP_ALLOCATOR_TYPE00=system, 1=mimalloc, 2=custom

Allocator ​

The allocator is selected at compile time via UVHTTP_ALLOCATOR_TYPE:

  • 0: System allocator (malloc/free)
  • 1: mimalloc (when BUILD_WITH_MIMALLOC=ON)
  • 2: Custom allocator (user-provided)

CI Build Matrix ​

WorkflowTriggerScope
ci-pr.ymlEvery PRBuild, unit tests, ASan gate, code quality
ci-nightly.ymlNightlyFull build matrix, coverage, stress, ASan+UBSan
ci-fuzz.ymlNightlylibFuzzer + ASan (60s per target)
deploy-docs.ymlPush to mainBuild and deploy VitePress docs

Makefile Targets ​

TargetDescription
make buildDebug build
make build-releaseRelease build
make testRun tests
make verify-memory-safetyASan + UBSan gate
make docsBuild all documentation
make docs-cleanClean generated docs
make benchBenchmark build

Test Registration ​

  • Unit tests: 91 test files, discovered via file(GLOB_RECURSE ...)
  • Each test file becomes its own CTest test
  • Integration tests: standalone server programs (not registered with CTest)
  • Fuzz tests: libFuzzer harness (not registered with CTest)

Directory Structure ​

uvhttp/
├── src/           # Source files (17 .c files)
├── include/       # Public headers (28 .h files)
├── test/          # Test files
│   ├── unit/      # Google Test unit tests
│   ├── integration/  # Integration test servers
│   ├── mock/      # libuv mock library
│   └── fuzz/      # libFuzzer harnesses
├── deps/          # Vendored dependencies (git submodules)
├── examples/      # Example programs
├── benchmark/     # Benchmark server
├── docs/          # Documentation (VitePress)
└── scripts/       # Build and utility scripts

Released under MIT License