|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +aos_core_lib_cpp is a C++17 library for the Aos Edge platform, providing Control Manager (cm), |
| 8 | +Service Manager (sm), Identity & Access Management (iam), and shared utilities (common). |
| 9 | + |
| 10 | +## Build Commands |
| 11 | + |
| 12 | +```bash |
| 13 | +# Build (Debug by default) |
| 14 | +./build.sh build |
| 15 | +./build.sh build --build-type Release |
| 16 | +./build.sh build --clean # clean rebuild |
| 17 | + |
| 18 | +# Run all tests |
| 19 | +./build.sh test |
| 20 | + |
| 21 | +# Run a single test binary directly |
| 22 | +./build/bin/<test_name> |
| 23 | +# Or with gtest filter: |
| 24 | +./build/bin/<test_name> --gtest_filter="TestSuite.TestName" |
| 25 | + |
| 26 | +# Code coverage (requires lcov 2.0+) |
| 27 | +./build.sh coverage |
| 28 | + |
| 29 | +# Static analysis |
| 30 | +./build.sh lint |
| 31 | + |
| 32 | +# Generate docs |
| 33 | +./build.sh doc |
| 34 | +``` |
| 35 | + |
| 36 | +## Build System |
| 37 | + |
| 38 | +- CMake 3.23+ with Conan package manager for dependencies (GTest 1.14.0, OpenSSL 3.2.1) |
| 39 | +- Key CMake options: `WITH_TEST`, `WITH_COVERAGE`, `WITH_DOC` |
| 40 | +- Custom CMake functions in `cmake/AddModule.cmake`: `add_module()`, `add_test()`, `add_exec()` |
| 41 | +- Compiler flags: `-Wall -Werror -Wextra -Wpedantic` |
| 42 | + |
| 43 | +## Code Architecture |
| 44 | + |
| 45 | +```text |
| 46 | +src/core/ |
| 47 | +├── cm/ # Control Manager - orchestration (alerts, launcher, imagemanager, etc.) |
| 48 | +├── sm/ # Service Manager - service lifecycle (launcher, resourcemanager, etc.) |
| 49 | +├── common/ # Shared utilities (crypto, logging, monitoring, types, tools, ocispec, etc.) |
| 50 | +└── iam/ # Identity & Access Management |
| 51 | +``` |
| 52 | + |
| 53 | +- **Interface-driven design**: Interfaces live in `*/itf/` subdirs and use `*Itf` suffix with pure virtual methods |
| 54 | +- **Error handling**: Custom `Error` type, not exceptions. |
| 55 | + Pattern: `if (!err.IsNone()) { return err; }` with `AOS_ERROR_WRAP(err)` for context |
| 56 | +- **Crypto abstraction**: Dual OpenSSL and mbed TLS backends via conditional compilation |
| 57 | +- **Custom containers**: `StaticArray`, `StaticString`, `Array`, `String` instead of STL; |
| 58 | + `UniquePtr` for smart pointers |
| 59 | + |
| 60 | +## Testing |
| 61 | + |
| 62 | +- Google Test + Google Mock in `*/tests/` subdirectories within each module |
| 63 | +- Mocks in `*/tests/mocks/` (use `MOCK_METHOD`), stubs in `*/tests/stubs/` |
| 64 | +- Integration tests in `src/core/{cm,sm}/tests/` |
| 65 | +- Test config constants in `src/core/testconfig.hpp` |
| 66 | + |
| 67 | +## Coding Conventions |
| 68 | + |
| 69 | +- **Formatting**: WebKit-based clang-format, 120 char line limit |
| 70 | +- **Header guards**: `#ifndef AOS_CORE_<PATH>_HPP_` / `#define` / `#endif` |
| 71 | +- **Namespaces**: nested `aos::sm::launcher`, `aos::core::cm`, etc. |
| 72 | +- **Naming**: `m` prefix for members (`mGroups`), `c` prefix for constants (`cMaxNumGroups`), |
| 73 | + `Itf` suffix for interfaces, `Mock` suffix for mocks |
| 74 | +- **License header**: All files require SPDX Apache-2.0 header with EPAM copyright |
| 75 | +- **Module CMakeLists**: Follow the pattern using `add_module()` / `add_test()` from `cmake/AddModule.cmake` |
| 76 | + |
| 77 | +## CI Checks |
| 78 | + |
| 79 | +GitHub Actions runs on push/PR: Debug build + test, Release build, |
| 80 | +clang-format + cmake-format + markdownlint checks, cppcheck lint, SonarQube analysis. |
0 commit comments