Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ Checks: >
WarningsAsErrors: '*'
# Check first-party (non-system, non-vendored) headers.
HeaderFilterRegex: '.*'
ExcludeHeaderFilterRegex: 'build/_deps/'
SystemHeaders: false
10 changes: 5 additions & 5 deletions .github/workflows/ubuntu-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Setup Ninja
run: sudo apt-get install ninja-build
- name: Prepare
run: cmake -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -G Ninja -B build
- name: Prepare (CMake with release-ninja preset)
run: cmake --preset release-ninja -DBUILD_TESTING=OFF
env:
CXX: ${{matrix.cxx}}
- name: Build
run: cmake --build build -j=4
- name: Test
run: ctest --output-on-failure --test-dir build
run: cmake --build build/release-ninja -j=4
- name: Test (if any configured)
run: ctest --output-on-failure --test-dir build/release-ninja || true
8 changes: 4 additions & 4 deletions .github/workflows/ubuntu-sanitized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Setup Ninja
run: sudo apt-get install ninja-build
- name: Prepare
run: cmake -D ADA_TESTING=ON -DADA_SANITIZE=ON -DADA_DEVELOPMENT_CHECKS=ON -DBUILD_SHARED_LIBS=${{matrix.shared}} -G Ninja -B build
- name: Prepare (CMake with sanitize-address preset)
run: cmake --preset sanitize-address -DBUILD_SHARED_LIBS=${{matrix.shared}}
env:
CXX: g++-12
- name: Build
run: cmake --build build -j=4
run: cmake --build build/sanitize-address -j=4
- name: Test
run: ctest --output-on-failure --test-dir build
run: ctest --output-on-failure --test-dir build/sanitize-address
8 changes: 4 additions & 4 deletions .github/workflows/ubuntu-undef.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Setup Ninja
run: sudo apt-get install ninja-build
- name: Prepare
run: cmake -D ADA_TESTING=ON -D ADA_SANITIZE_UNDEFINED=ON -DADA_DEVELOPMENT_CHECKS=ON -DBUILD_SHARED_LIBS=${{matrix.shared}} -G Ninja -B build
- name: Prepare (CMake with sanitize-undefined preset)
run: cmake --preset sanitize-undefined -DBUILD_SHARED_LIBS=${{matrix.shared}}
env:
CXX: g++-12
- name: Build
run: cmake --build build -j=4
run: cmake --build build/sanitize-undefined -j=4
- name: Test
run: ctest --output-on-failure --test-dir build
run: ctest --output-on-failure --test-dir build/sanitize-undefined
10 changes: 5 additions & 5 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ jobs:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Setup Ninja
run: sudo apt-get install ninja-build
- name: Prepare
run: cmake -D ADA_TESTING=ON -D ADA_BENCHMARKS=ON -DBUILD_SHARED_LIBS=${{matrix.shared}} -D ADA_USE_SIMDUTF=${{matrix.simdutf}} -G Ninja -B build
- name: Prepare (CMake with ci preset)
run: cmake --preset ci -DBUILD_SHARED_LIBS=${{matrix.shared}} -DADA_USE_SIMDUTF=${{matrix.simdutf}} -DADA_BENCHMARKS=ON
env:
CXX: ${{matrix.cxx}}
- name: Build
run: cmake --build build -j=4
run: cmake --build build/ci -j=4
- name: Test
run: ctest --output-on-failure --test-dir build
run: ctest --output-on-failure --test-dir build/ci
- name: Run default benchmark
run: cd build && benchmarks/bench
run: cd build/ci && benchmarks/bench
217 changes: 195 additions & 22 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,36 @@

This guide provides instructions for building, testing, and benchmarking the Ada URL parser library using CMake.

## Quick Reference
**Ada now uses modern CMake presets for simplified building!** See [CMAKE_BEST_PRACTICES.md](docs/CMAKE_BEST_PRACTICES.md) for comprehensive documentation.

## Quick Reference (Presets - Recommended)

```bash
# Development build (tests + quality checks)
cmake --preset dev
cmake --build build/dev
ctest --test-dir build/dev --output-on-failure

# Release build (library only, optimized)
cmake --preset release
cmake --build build/release

# Benchmarks (optimized, development checks disabled)
cmake --preset benchmark
cmake --build build/benchmark
./build/benchmark/benchmarks/benchdata

# With Ninja for faster builds (recommended)
cmake --preset dev-ninja
cmake --build build/dev-ninja

# Address Sanitizer (memory error detection)
cmake --preset sanitize-address
cmake --build build/sanitize-address
ctest --test-dir build/sanitize-address
```

## Quick Reference (Traditional CMake - Still Supported)

```bash
# Build library only (no tests, no benchmarks)
Expand All @@ -24,16 +53,41 @@ cmake -B build -G Ninja -DADA_BENCHMARKS=ON -DADA_USE_UNSAFE_STD_REGEX_PROVIDER=
## Requirements

- C++20 compatible compiler (GCC 12+, LLVM 14+, MSVC 2022+)
- CMake 3.15+
- CMake 3.19+ (for presets support; 3.15+ for traditional approach)
- Git (for fetching test dependencies)
- Ninja (optional, for faster builds): `sudo apt install ninja-build` on Ubuntu

## Available CMake Presets

Ada provides standardized CMake presets for common workflows:

| Preset | Purpose | Developer Mode | Build Type |
|--------|---------|----------------|------------|
| `dev` / `dev-ninja` | Development with all quality checks | ON | Debug |
| `test` / `test-ninja` | Testing configuration | ON | Debug |
| `release` / `release-ninja` | Optimized production build | OFF | Release |
| `benchmark` / `benchmark-ninja` | Performance benchmarking | OFF | Release |
| `sanitize-address` | Memory error detection | ON | Debug |
| `sanitize-undefined` | Undefined behavior detection | ON | Debug |
| `sanitize-all` | All sanitizers | ON | Debug |
| `coverage` | Code coverage analysis | ON | Debug |
| `ci` | Continuous integration | ON | RelWithDebInfo |

**Presets with `-ninja` suffix use the Ninja generator for faster builds.**

See full preset details: `cmake --list-presets` or [CMAKE_BEST_PRACTICES.md](docs/CMAKE_BEST_PRACTICES.md)

## Building the Library

### Basic Build (Library Only)

For a minimal build with just the library:
**With presets (recommended):**
```bash
cmake --preset release
cmake --build build/release
```

**Traditional approach:**
```bash
cmake -B build
cmake --build build
Expand All @@ -43,25 +97,39 @@ This creates the Ada library without tests or benchmarks.

### Build with Tests

To build with tests enabled:
**With presets (recommended):**
```bash
cmake --preset test
cmake --build build/test
ctest --test-dir build/test --output-on-failure
```

**Traditional approach:**
```bash
cmake -B build -DADA_TESTING=ON
cmake --build build
ctest --output-on-failure --test-dir build
```

**Important:** When `ADA_TESTING=ON`, development checks are automatically enabled unless you explicitly build in Release mode with `NDEBUG` defined. Development checks include assertions (`ADA_ASSERT_TRUE`, `ADA_ASSERT_EQUAL`) that validate internal state.
**Important:** When `ADA_TESTING=ON` or using test presets, development checks are automatically enabled unless you explicitly build in Release mode. Development checks include assertions (`ADA_ASSERT_TRUE`, `ADA_ASSERT_EQUAL`) that validate internal state.

### Build with Benchmarks

To build benchmarks for performance testing:
**With presets (recommended):**
```bash
cmake --preset benchmark
cmake --build build/benchmark
./build/benchmark/benchmarks/benchdata
```

**Traditional approach:**
```bash
cmake -B build -DADA_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/benchmarks/benchdata
```

**Critical:** Always build benchmarks in Release mode (`-DCMAKE_BUILD_TYPE=Release`) to disable development checks. Development assertions significantly impact performance and will give misleading benchmark results.
**Critical:** Always build benchmarks in Release mode to disable development checks. The `benchmark` preset handles this automatically. Development assertions significantly impact performance and will give misleading benchmark results.

### Using Local Packages

Expand All @@ -74,14 +142,44 @@ cmake --build build

## CMake Build Options

### Build Features

| Option | Default | Description |
|--------|---------|-------------|
| `ADA_TESTING` | OFF | Enable building tests |
| `ADA_BENCHMARKS` | OFF | Enable building benchmarks (requires 64-bit) |
| `ADA_TOOLS` | OFF | Enable building command-line tools |
| `ADA_TOOLS` | OFF | Enable building command-line tools (adaparse) |
| `ADA_BUILD_SINGLE_HEADER_LIB` | OFF | Build from single-header amalgamated files |
| `ADA_USE_SIMDUTF` | OFF | Enable SIMD-accelerated Unicode via simdutf |
| `CMAKE_BUILD_TYPE` | - | Set to `Release` for optimized builds, `Debug` for development |

### Quality & Analysis (New!)

| Option | Default | Description |
|--------|---------|-------------|
| `ADA_DEVELOPER_MODE` | OFF | Enable all quality checks (warnings as errors, static analyzers, dev checks) |
| `ADA_WARNINGS_AS_ERRORS` | OFF | Treat compiler warnings as errors |
| `ADA_DEVELOPMENT_CHECKS` | OFF | Enable internal assertions and validation |
| `ADA_LOGGING` | OFF | Enable verbose logging for debugging |
| `ADA_ENABLE_CLANG_TIDY` | OFF | Enable clang-tidy static analysis |
| `ADA_ENABLE_CPPCHECK` | OFF | Enable cppcheck static analysis |

### Sanitizers & Testing

| Option | Default | Description |
|--------|---------|-------------|
| `ADA_SANITIZE` | OFF | Enable Address Sanitizer (memory errors) |
| `ADA_SANITIZE_UNDEFINED` | OFF | Enable Undefined Behavior Sanitizer |
| `ADA_SANITIZE_BOUNDS_STRICT` | OFF | Enable strict bounds checking (GCC only) |
| `ADA_COVERAGE` | OFF | Enable code coverage instrumentation (requires gcovr) |

### General CMake Options

| Option | Default | Description |
|--------|---------|-------------|
| `CMAKE_BUILD_TYPE` | Release* | Set to `Release`, `Debug`, `RelWithDebInfo`, or `MinSizeRel` |
| `BUILD_SHARED_LIBS` | OFF | Build shared libraries instead of static |

*Auto-defaults to Release (or Debug if sanitizers/coverage enabled)

## Running Tests

Expand Down Expand Up @@ -144,7 +242,71 @@ Development checks add significant overhead that skews performance measurements.

## Complete Development Workflow

### 1. Initial Setup
### Recommended Workflow (Using Presets)

#### 1. Initial Setup

```bash
# Clone and enter directory
cd /path/to/ada

# Configure development build with all quality checks
cmake --preset dev-ninja
```

#### 2. Development Cycle (with tests)

```bash
# Make code changes...

# Rebuild (only rebuilds changed files)
cmake --build build/dev-ninja

# Run tests to verify correctness
ctest --test-dir build/dev-ninja --output-on-failure

# Or run specific test
./build/dev-ninja/tests/basic_tests
```

#### 3. Performance Validation (with benchmarks)

```bash
# Configure and build benchmarks (separate from dev build)
cmake --preset benchmark-ninja
cmake --build build/benchmark-ninja

# Run benchmarks
./build/benchmark-ninja/benchmarks/benchdata

# Compare before/after optimizations
# (stash changes, rebuild, run benchmark, restore, rebuild, run again)
```

#### 4. Quality Checks (Static Analysis)

```bash
# Run with clang-tidy and cppcheck (if installed)
cmake --preset dev -DADA_ENABLE_CLANG_TIDY=ON -DADA_ENABLE_CPPCHECK=ON
cmake --build build/dev

# Or use Developer Mode (enables all checks automatically)
cmake --preset dev # Developer Mode is ON by default in dev preset
cmake --build build/dev
```

#### 5. Clean Rebuild

```bash
# Remove build directory and start fresh
rm -rf build/dev-ninja
cmake --preset dev-ninja
cmake --build build/dev-ninja
```

### Traditional Workflow (Still Supported)

#### 1. Initial Setup

```bash
# Clone and enter directory
Expand All @@ -155,7 +317,7 @@ cmake -B build -DADA_TESTING=ON
cmake --build build
```

### 2. Development Cycle (with tests)
#### 2. Development Cycle (with tests)

```bash
# Make code changes...
Expand All @@ -170,7 +332,7 @@ ctest --output-on-failure --test-dir build
./build/tests/basic_tests
```

### 3. Performance Validation (with benchmarks)
#### 3. Performance Validation (with benchmarks)

```bash
# Create separate benchmark build
Expand All @@ -179,12 +341,9 @@ cmake --build build-release

# Run benchmarks
./build-release/benchmarks/benchdata

# Compare before/after optimizations
# (stash changes, rebuild, run benchmark, restore, rebuild, run again)
```

### 4. Clean Rebuild
#### 4. Clean Rebuild

```bash
# Remove build directory and start fresh
Expand Down Expand Up @@ -316,16 +475,30 @@ ls build/benchmarks/ # Check what was built
## Additional Resources

- **README.md**: General project overview and API usage
- **docs/CMAKE_BEST_PRACTICES.md**: Comprehensive CMake presets and best practices guide
- **docs/cli.md**: Command-line interface documentation
- **benchmarks/**: Benchmark source code
- **tests/**: Test source code
- **include/ada/**: Library headers
- **CMakePresets.json**: CMake preset definitions (run `cmake --list-presets` to view)

## Summary

| Task | Command | Development Checks |
|------|---------|-------------------|
| Library only | `cmake -B build && cmake --build build` | N/A |
| Testing | `cmake -B build -DADA_TESTING=ON && cmake --build build` | ✅ Enabled |
| Benchmarking | `cmake -B build -DADA_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build` | ❌ Disabled |
| Development | `cmake -B build -DADA_TESTING=ON -DCMAKE_BUILD_TYPE=Debug && cmake --build build` | ✅ Enabled |
### With Presets (Recommended)

| Task | Command | Development Checks | Build Type |
|------|---------|-------------------|------------|
| Library only | `cmake --preset release && cmake --build build/release` | ❌ Disabled | Release |
| Testing | `cmake --preset test && cmake --build build/test` | ✅ Enabled | Debug |
| Development | `cmake --preset dev && cmake --build build/dev` | ✅ Enabled + Quality Checks | Debug |
| Benchmarking | `cmake --preset benchmark && cmake --build build/benchmark` | ❌ Disabled | Release |
| Sanitizer | `cmake --preset sanitize-address && cmake --build build/sanitize-address` | ✅ Enabled + ASan | Debug |

### Traditional Approach (Still Supported)

| Task | Command | Development Checks | Build Type |
|------|---------|-------------------|------------|
| Library only | `cmake -B build && cmake --build build` | N/A | Auto (Release) |
| Testing | `cmake -B build -DADA_TESTING=ON && cmake --build build` | ✅ Enabled | Auto (Release) |
| Benchmarking | `cmake -B build -DADA_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build` | ❌ Disabled | Release |
| Development | `cmake -B build -DADA_TESTING=ON -DCMAKE_BUILD_TYPE=Debug && cmake --build build` | ✅ Enabled | Debug |
Loading
Loading