|
| 1 | +# 3. Define directory structure |
| 2 | + |
| 3 | +Date: 2020-12-01 |
| 4 | + |
| 5 | +## Status |
| 6 | + |
| 7 | +Accepted |
| 8 | + |
| 9 | +## Context |
| 10 | + |
| 11 | +There will be many services contributed by multiple people. We need a common way of structuring the services |
| 12 | +so it's easy for the user to pick up any one service. |
| 13 | + |
| 14 | +Some services might want to share some common code. We want to have that code structured so that include path shouldn't |
| 15 | +change if these extensions are included into Mbed OS. |
| 16 | + |
| 17 | +## Decision |
| 18 | + |
| 19 | +### Services |
| 20 | + |
| 21 | +Each service will be its own library. All services will be in the services directory. |
| 22 | +Each service will contain at least an include folder and a mbed_lib.json. |
| 23 | + |
| 24 | +An example service called `example` would look like this: |
| 25 | + |
| 26 | +``` |
| 27 | +services/example/include/ble-service-example/example.h |
| 28 | +services/example/source/example.cpp |
| 29 | +services/example/mbed_lib.json |
| 30 | +``` |
| 31 | + |
| 32 | +and the mbed_lib.json would contain at least: |
| 33 | + |
| 34 | +``` |
| 35 | +{ |
| 36 | + "name": "ble-service-example" |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +This way a user can clone the repo and include an individual service without getting unwanted includes. |
| 41 | + |
| 42 | +### Extensions |
| 43 | + |
| 44 | +If a service needs to share some common code between multiple services this code can be made into an extension. |
| 45 | + |
| 46 | +Extensions are common code, extending the mbed-os ble feature. They are libraries of their own and each service that |
| 47 | +wants to use them needs a `requires` section that pulls it in as a dependency. |
| 48 | + |
| 49 | +And `example` extension library: |
| 50 | + |
| 51 | +``` |
| 52 | +extensions/example/include/ble/gatt |
| 53 | +extensions/example/include/ble/gap |
| 54 | +extensions/example/include/ble/common |
| 55 | +extensions/example/source/... |
| 56 | +extensions/example/mbed_lib.json |
| 57 | +``` |
| 58 | + |
| 59 | +and the extension mbed_lib.json would contain at least: |
| 60 | + |
| 61 | +``` |
| 62 | +{ |
| 63 | + "name": "ble-extension-example" |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +and the service needs it's mbed_lib.json expanded with a |
| 68 | + |
| 69 | +``` |
| 70 | + requires: ["ble-extension-example"] |
| 71 | +``` |
| 72 | + |
| 73 | +### Tests |
| 74 | + |
| 75 | +Unit tests and integration tests go into the tests directory: |
| 76 | + |
| 77 | +``` |
| 78 | +tests/UNITTESTS |
| 79 | +tests/TESTS |
| 80 | +``` |
| 81 | + |
| 82 | +`TESTS` and `UNITTESTS` are automatically ignored by mbed tools when not building tests. Any other files or directories in |
| 83 | +the tests folder need to be added to `.mbedignore` in order to avoid compilation when the repo is included with the |
| 84 | +intention to use one of the services. |
| 85 | + |
| 86 | +## Consequences |
| 87 | + |
| 88 | +All PRs amended to follow the structure. All future PRs comply with the structure. |
0 commit comments