Skip to content

Latest commit

 

History

History
93 lines (68 loc) · 4.38 KB

AGENTS.md

File metadata and controls

93 lines (68 loc) · 4.38 KB

AGENTS.md

This file provides guidance to AI coding agents when working with code in this repository.

Project Overview

This repository aggregates third-party C++ dependencies for the ECMWF C++ stack. Each dependency is a git submodule with a corresponding build script. The repo does not contain application code — it only vendors and builds external libraries.

Current dependencies: CLI11 (2.6.1), libfmt (12.1.0), libaec (1.1.6), nlohmann/json (3.12.0), pybind11 (3.0.4), qhull (2020.2), SQLite3 (3.53.0), PROJ (9.8.1), libpq (18.3), libpqxx (7.10.5).

Build Commands

Prerequisites

After cloning, initialize submodules:

git submodule update --init --recursive

Standalone install (shell-based)

# Build all dependencies into ./deps (default)
./build.sh

# Build to a custom prefix
./build.sh --install-path ~/stack-deps

# Control build artifact location
./build.sh --install-path ~/stack-deps --build-path /tmp/build

CMake integration (bundle mode)

The top-level CMakeLists.txt is designed for two modes:

  • Standalone (cmake -S . -B build): installs to build/deps-install by default
  • Sub-project: used via ecbuild_bundle() in downstream projects with RECURSIVE to pull submodules. Appends the install path to CMAKE_PREFIX_PATH in the parent scope. The CMakeLists.txt early-returns unless ENABLE_BUNDLED_DEPENDENCIES is ON or the project is top-level. ecbuild_bundle() sets this automatically; plain add_subdirectory() callers must set it manually.

A sentinel file stack_deps_built in the install prefix prevents redundant rebuilds.

Architecture

build.sh                  # Entry point: uses BUILD_ORDER to iterate scripts, calls build() in each
build-scripts/
  cli11.sh                # Per-dependency build script (defines a build() function)
  fmt.sh
  libaec.sh
  nlohmann_json.sh
  pybind11.sh
  qhull.sh
  sqlite3.sh
  proj.sh
  libpq.sh
  libpqxx.sh
CMakeLists.txt            # CMake wrapper that invokes build.sh at configure time
CLI11/                    # Git submodule
fmt/                      # Git submodule
json/                     # Git submodule (nlohmann/json)
libaec/                   # Git submodule
PROJ/                     # Git submodule
pybind11/                 # Git submodule
qhull/                    # Git submodule
sqlite/                   # Git submodule (SQLite3)
postgres/                 # Git submodule (libpq)
libpqxx/                  # Git submodule

Build script contract

Each file in build-scripts/ must define a build() shell function. The function receives these environment variables:

  • SOURCE_ROOT — repo root (use to locate submodule sources)
  • INSTALL_PREFIX — where to install (-DCMAKE_INSTALL_PREFIX)
  • BUILD_PATH — where to place build artifacts (create a subfolder per dependency)

Scripts are sourced in a subshell for isolation — variables and failures don't leak between scripts. Build order is controlled by the BUILD_ORDER array in build.sh — dependencies must appear before their dependents (e.g. sqlite3 before proj). Use CMAKE_PREFIX_PATH=$INSTALL_PREFIX to find previously built deps.

Adding a New Dependency

  1. Add the library as a git submodule at the repo root
  2. Create build-scripts/<name>.sh with a build() function following existing scripts as templates
  3. Add <name> to the BUILD_ORDER array in build.sh (position it after any deps it requires)
  4. Register the dependency in CMakeLists.txt via add_dependency_option(NAME <NAME> SCRIPT <name> DESCRIPTION "..." OUTPUT _stack_dep_map DEFAULT ${_stack_dep_default}). If it has transitive deps, add DEPENDENCIES <DEP1> <DEP2> and a corresponding DEP_REQUIRES_<name>="dep1 dep2" in build.sh
  5. Update the dependency table in README.md

All build scripts use -DCMAKE_BUILD_TYPE=RelWithDebInfo by convention.

Gotchas

  • Skipped rebuilds: The CMake path writes a stack_deps_built sentinel file. To force a rebuild, delete <install-prefix>/stack_deps_built.
  • Build order: Controlled by the BUILD_ORDER array in build.sh, not alphabetical. Every script must be listed in this array. New scripts that are missing from BUILD_ORDER will cause a runtime error.
  • Transitive dependencies: If a dependency requires other deps, declare them via DEPENDENCIES in CMakeLists.txt and DEP_REQUIRES_<name> in build.sh. Both CMake and build.sh --with-deps auto-enable transitive deps.