|
lexLeo
|
This document defines the standard directory layout options for a module, along with the responsibilities and visibility rules associated with each part.
The goal is to:
IMPORTANT
The layout described in this document represents a maximal, feature-complete envelope. A real module is not expected to provide all of these directories or headers.
Modules must include only the parts that make sense for their nature (stateless vs stateful, core vs adapter, simple vs configurable).
module/
├── CMakeLists.txt
├── include/
│ ├── module.h
│ ├── module_cfg.h (optional, public only if contractual)
│ ├── module_factory.h
│ ├── module_ops.h
│ ├── module_types.h
│ └── internal/
│ ├── module_ctx.h (optional, bootstrap-only configuration)
│ └── module_factory_ctx.h
├── src/
│ ├── module.c
│ └── internal/
│ ├── module_backend.h (if adapter)
│ ├── module_internal.h
│ └── module_state.h
└── tests/
├── CMakeLists.txt
├── include/
│ └── module_test_api.h
├── support/
│ ├── CMakeLists.txt
│ └── fake_provider/
│ ├── CMakeLists.txt
│ ├── include/
│ │ └── module_fake_provider.h
│ └── src/
│ │ └── module_fake_provider.c
├── unit/
│ └── (white_box / black_box)
└── integration/
This layout describes everything a module may contain, not what it must contain.
The include/ directory contains the public, stable API of the module.
It exposes the types and functions required to use a module at runtime, not to assemble or wire it.
Typical contents:
<module>_t);*_cfg_t), only if contractual;*_ops_t);Public headers must:
The include/internal/ directory contains non-public headers reserved for module assembly and lifecycle orchestration.
These headers are intended for:
Typical contents:
*_ctx_t) defining how a module is wired;Key principles:
Visibility rules:
Rationale:
<module>_t, not wiring types.The src/ directory contains the runtime implementation of the module.
It defines:
<module>_t;<module>_t;*_vtbl used to implement the port;The src/internal/ directory contains private headers that are part of the module’s runtime implementation but are not part of any API.
Typical contents:
*_state_t);Rules:
Note
State headers are expected only for stateful modules.
Stateless modules may not require src/internal/ at all.
The tests/ directory contains all tests for the module, as well as test-only utilities.
The tests/include/ directory may contain test-only APIs, such as:
This header:
It must never be installed or exposed as part of the public API.
This directory is exported via:
<module>_test_headers (INTERFACE)The tests/support/ directory contains test-only support libraries owned by this module but intended to be consumed by other modules’ tests.
This code is not part of production builds.
Typical use cases:
<module>_fake_provider — a module-local facade that exposes/configures reusable fakes for this module (reusable fake implementations live in lexleo/tests/test_support/ as fake_<module>).Standard targets:
<module> — runtime library target<module>_wiring_headers — INTERFACE target exporting wiring/injection headers<module>_test_headers — INTERFACE target exporting tests/include/<module>_test_usage_requirements — INTERFACE bundle of module-specific test requirements for the module's own tests (does NOT include global test frameworks)Important
Global unit test frameworks (e.g., cmocka) must be linked explicitly by each test executable. They must not be hidden inside <module>_test_usage_requirements.
| Directory | Responsibility |
|---|---|
| include/ | Runtime-facing public API |
| include/internal/ | Wiring / injection API (bootstrap + tests) |
| src/ | Runtime implementation |
| src/internal/ | Private runtime details |
| tests/ | Unit and integration tests |
| tests/include/ | Module test API (<module>_test_headers) |
| tests/support/ | Module-local test-only support (fake provider facade) |
This layout is explicitly aligned with the Type standards and Test management documents.
Together, they ensure a strict separation between runtime objects, wiring/lifecycle orchestration, and internal implementation details, while remaining flexible enough to support simple modules and complex runtime/adapter architectures.