Skip to content

Developer Build and Configuration

Hugo edited this page Mar 15, 2026 · 1 revision

Developer Build and Configuration

Back to Home

Build System Overview

CoreTrace is a CMake C++20 project (cmake_minimum_required(VERSION 3.11)).

Main target:

  • executable: ctrace

Dependency integration is split between FetchContent and ExternalProject.

Dependencies Pulled by CMake

FetchContent

  • nlohmann/json (v3.11.3 archive)
  • coretrace-stack-analyzer (Git, main)
  • coretrace-log (Git, main)
  • cpp-httplib (Git tag v0.14.3)

ExternalProject

  • tscancode (Git master, built in its own external directory)
  • flawfinder (Git master)

Local Build Commands

cd /Users/hugopayet/Desktop/CLaude/coretrace
mkdir -p build && cd build
cmake .. -DPARSER_TYPE=CLI11 -DUSE_THREAD_SANITIZER=OFF -DUSE_ADDRESS_SANITIZER=OFF
make -j4

Run smoke check:

./ctrace --help

CMake Options

  • PARSER_TYPE: Getopt or CLI11 (default CLI11)
  • USE_THREAD_SANITIZER: ON|OFF
  • USE_ADDRESS_SANITIZER: ON|OFF
  • USE_EXTERNAL_CLI11: download/link external CLI11 when parser type is CLI11

Sanitizer note:

  • ThreadSanitizer and AddressSanitizer should not be enabled together.

Parser Backend Selection

Factory logic (createArgumentParser) chooses:

  • GetoptArgumentParser when USE_GETOPT is defined
  • CLI11ArgumentParser otherwise

USE_GETOPT is set when CMake PARSER_TYPE=Getopt.

Formatting and CI Checks

Local scripts:

./scripts/format.sh
./scripts/format-check.sh

CMake targets:

cmake --build build --target format
cmake --build build --target format-check

CI currently checks:

  • clang-format workflow installs clang-format 17 and runs scripts/format-check.sh
  • build workflow builds on Linux and macOS, and runs ./ctrace -h

LLVM and Toolchain Notes

Project workflows install LLVM/Clang 20 in CI for Linux and macOS builds.

For local parity with CI, prefer LLVM 20 toolchains when working on stack-analyzer integration.

Configuration Flow and Precedence

CLI entry path

  1. Parse CLI options into ArgumentManager.
  2. If --tool-config exists, load JSON into ProgramConfig first.
  3. Apply CLI commands (ConfigProcessor) afterward.

Result: CLI flags/options override overlapping values loaded from tool-config.

HTTP API entry path (POST /api)

  1. Apply boolean request fields.
  2. If tool_config is provided, load JSON.
  3. Apply request string/list fields afterward.

Result: explicit request string/list values can override loaded file values.

tool-config Supported Structure

Current loader supports:

  • Root:
    • invoke
    • input
  • Analyzer section at either:
    • stack_analyzer
    • or tools.ctrace_stack_analyzer

Supported analyzer keys include:

  • Paths: compile_commands, resource_model, escape_model, buffer_model
  • Booleans: demangle, timing, include_compdb_deps, quiet
  • Scalars: stack_limit, analysis-profile/analysis_profile, smt* keys
  • Lists: smt-rules/smt_rules, entry_points

Path values in config file are resolved relative to the config file directory.

Runtime Assumptions to Keep in Mind

  • Some tool executables are invoked with specific paths/commands in implementation.
  • cppcheck path is hardcoded to /opt/homebrew/bin/cppcheck in current code.
  • Environment/runtime setup therefore affects which tools can actually execute.

Back to Home