Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Explain the usage of libhal-bootstrap #13

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
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
37 changes: 37 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ This is a [Conan](https://conan.io/) recipe file. Conan is a package manager for
C and C++ that helps manage dependencies in your project. This file defines how
Conan should build your project and its dependencies.

This conan file utilizes the
[`libhal-bootstrap`](https://github.com/libhal/libhal-bootstrap) extension
library to reduce the amount of replicated code for libhal libraries. This conanfile extends the `libhal-bootstrap.library` class. That class implements:

- `def validate(self)`
- `def layout(self)`
- `def generate(self)`
- `def build(self)`
- `def package(self)`
- `def build_requirements(self)`: which adds the tool packages for `cmake`,
`libhal-cmake-util`, `libhal-mock`, `boost-ext-ut`

The class methods can be extended by implementing your own. The base class
implementations simply get called first. The derived class can then extend
these even further, but in general, most of these should be left untouched.

### `CMakeList.txt`

The root CMake build script for the library. It contains a call to the
Expand Down Expand Up @@ -88,6 +104,27 @@ library. It includes:
function from
[`libhal-cmake-util`](https://github.com/libhal/libhal-cmake-util).

The `demos/conanfile.py` utilizes the
[`libhal-bootstrap`](https://github.com/libhal/libhal-bootstrap) extension
library and extends the `libhal-bootstrap.demos` class. This class provides the
basic building blocks for a demo. The requirements from the base class are not
transitive so:

```python
bootstrap = self.python_requires["libhal-bootstrap"]
bootstrap.module.add_demo_requirements(self)
```

Must be invoked in order to add the appropriate platform libraries to the
`ConanFile` class. These platform libraries are usually `libhal-lpc40`,
`libhal-stm32f1` and `libhal-micromod`. Note that bootstrap must be updated to
support additional platforms. If you attempt to use a profile with a platform
name outside of what is supported by `libhal-bootstrap` then this API does
nothing except include `libhal-util`.

Additional requirements and dependencies can be added after calling
`add_demo_requirements`.

### `include/libhal-__device__/`

This directory contains the header files for the device library. This contains
Expand Down