Skip to content

Conversation

@0xc0170
Copy link
Contributor

@0xc0170 0xc0170 commented Jul 21, 2020

Summary of changes

Add requirements
Fix cmake folder updates
Fix label function

Plus other small edits

Impact of changes

Migration actions required

Documentation


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[x] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


Copy link
Contributor

@rwalton-arm rwalton-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I have a couple of suggestions around grammar etc.

@0xc0170 0xc0170 force-pushed the feature-cmake-design-update branch from 3f9b678 to 32681f4 Compare July 21, 2020 08:34
@0xc0170
Copy link
Contributor Author

0xc0170 commented Jul 21, 2020

The license check is on master as well, creating a new blocker and will fix.

rwalton-arm
rwalton-arm previously approved these changes Jul 21, 2020
@mergify mergify bot dismissed rwalton-arm’s stale review July 21, 2020 11:10

Pull request has been modified.

@mergify
Copy link

mergify bot commented Jul 21, 2020

This PR cannot be merged due to conflicts. Please rebase to resolve them.

@0xc0170 0xc0170 force-pushed the feature-cmake-design-update branch from f7bf625 to bd80d4d Compare July 21, 2020 12:45
@0xc0170
Copy link
Contributor Author

0xc0170 commented Jul 21, 2020

Rebased to get the travis fix in

All what can be defined should be in CMake files and configuration (app/mbed .json files). Our build system would parse the configuration, create rules and generate top level CMake file that would include others (application CMake files plus also Mbed OS core CMake).
Everything that can be defined should be in CMake files and configuration (mbed_app/mbed_lib.json) files. Our build system would parse the configuration and generate a CMake config file.

To stay backward compatible, we create common rules as follows.
Copy link
Collaborator

@hugueskamba hugueskamba Jul 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To stay backward compatible, we create common rules as follows.
For backward compatibility, the following rules must be respected:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change that to "The following rules must be respected" to avoid duplicating "follow..." in the same sentence.

Comment on lines 18 to 26
An example, to add `TARGET_STM` in the a folder `targets`:

```
./TARGET_STM/qspi/driver_stm_qspi.cpp
./TARGET_STM/peripheral_specific_to_stm/stm_specific_driver.cpp
```

As result, the top level application CMake:

```
add_subdirectory_if_target(STM TARGET_STM/qspi)
add_subdirectory_if_target(STM TARGET_STM/peripheral_specific_to_stm)
mbed_add_cmake_directory_if_labels("TARGET")
```

There would be static CMakes in the `./TARGET_STM/qspi/` and `./TARGET_STM/peripheral_specific_to_stm` that would define what files should be included or specific settins for these modules.
The same could be applied to other labels like features or components.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
An example, to add `TARGET_STM` in the a folder `targets`:
```
./TARGET_STM/qspi/driver_stm_qspi.cpp
./TARGET_STM/peripheral_specific_to_stm/stm_specific_driver.cpp
```
As result, the top level application CMake:
```
add_subdirectory_if_target(STM TARGET_STM/qspi)
add_subdirectory_if_target(STM TARGET_STM/peripheral_specific_to_stm)
mbed_add_cmake_directory_if_labels("TARGET")
```
There would be static CMakes in the `./TARGET_STM/qspi/` and `./TARGET_STM/peripheral_specific_to_stm` that would define what files should be included or specific settins for these modules.
The same could be applied to other labels like features or components.
I.e As the `DISCO_L475VG_IOT01A` target inherits the `STM` label and has the `BLE` feature, the `TARGET_STM` directory in `mbed-os/targets/` and the `FEATURE_BLE` directory in `mbed-os/features/` are processed because their parent directories contain `CMakeLists.txt` files that have each respectively `mbed_add_cmake_directory_if_labels("TARGET")` and `mbed_add_cmake_directory_if_labels("FEATURE")`.

This file statically defines the structure of the component within Mbed OS. It contains conditional statements that are based on the config. We use regular CMake expressions, plus extend it with our own macros, to conditionally include/exclude directories. The rule of thumb: do not expose headers that are internal. We would like to avoid having everything in the include paths as we do now.


`add_subdirectory` always adds the directory to the main CMake.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to explain a CMake function here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove

A user create own CMake file to configure an application, also with `mbed_app.json` configuration file. The building of an app would look like:

1. Parse the arguments provided to build command
2. Parse the application configuration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to carry on using 1 for numbered bullet points so you do not need to remember what the next number is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix


## Application CMake

We should provide application CMake functionality with our own configuration. There are couple of approaches we could take. Statically defined CMake but then this disconnectes config and CMake - as CMake contains configuration for a project (like includes, sources, etc). Our build tool would need to parse CMake to get all paths used in the project or Mbed OS to find out where to look for configuration file. Therefore the build system has a knowledge as it is currently. We use `requires` to include/exclude modules.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are extra spaces in this paragraph.

@mergify
Copy link

mergify bot commented Jul 21, 2020

This PR cannot be merged due to conflicts. Please rebase to resolve them.

@0xc0170
Copy link
Contributor Author

0xc0170 commented Jul 22, 2020

I'll rebase and fix all the reviews comments 👍

@0xc0170 0xc0170 force-pushed the feature-cmake-design-update branch 3 times, most recently from 4b43249 to 4c60dde Compare July 22, 2020 11:53
@0xc0170
Copy link
Contributor Author

0xc0170 commented Jul 23, 2020

Rebased, history fixed as well.

@0xc0170
Copy link
Contributor Author

0xc0170 commented Jul 23, 2020

Ah, wait , lost some changes, fixing that :)

@0xc0170 0xc0170 force-pushed the feature-cmake-design-update branch from c814ea8 to 44a89ad Compare July 23, 2020 09:17
@0xc0170
Copy link
Contributor Author

0xc0170 commented Jul 23, 2020

Rebased and recovered old data from github 🙄 magic here and there. I'll squash once reviewed and approved.


`mbed-tools` has consolidated all of the required modules to build Mbed OS, along with the command line interface, into a single Python package which can be installed using standard python packaging tools.

A user create own CMake file to configure an application, also with `mbed_app.json` configuration file. The building of an app would look like:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is accurate anymore. mbed-tools creates the Mbed configuration CMake file (.mbedbuild/mbed_config.cmake) and we don't expect users to have to edit it manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was about CMakelists.txt in the application, like blinky has in the root directory.

Copy link
Contributor

@rwalton-arm rwalton-arm Jul 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the tools to create a template top-level CMakeLists.txt when the user runs mbedtools init (or whatever the command to create a new workspace ends up being called, it's init currently)?

Copy link
Contributor Author

@0xc0170 0xc0170 Jul 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be ideal, if cmakelists does not exists and they run init, yotta had similar init flow as I recall.

I guess we want to avoid scanning folders , so we let user to fill in the template.

@mergify mergify bot dismissed Patater’s stale review July 23, 2020 11:16

Pull request has been modified.

@0xc0170 0xc0170 force-pushed the feature-cmake-design-update branch from ae99878 to 4d4f4d3 Compare July 23, 2020 11:30
@mergify mergify bot dismissed Patater’s stale review July 23, 2020 12:28

Pull request has been modified.

@0xc0170
Copy link
Contributor Author

0xc0170 commented Jul 23, 2020

I'll rebase for the final CI run

@mergify mergify bot dismissed Patater’s stale review July 23, 2020 12:56

Pull request has been modified.

@0xc0170
Copy link
Contributor Author

0xc0170 commented Jul 23, 2020

Updated

The same could be applied to other labels like features or components.

As result, the top level application CMake:
To migrate to the new build system, we can provide auto scanning of the module and generate CMake based on what we find or use the way as described above. In both cases, we could stay backward compatible.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to fix the grammar here, but I'm not sure what we mean by "auto scanning of the module"; do we mean "auto scanning of Mbed OS module and component directories"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File globbing is what I read

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it, the migration path will come in separate update

Patater
Patater previously approved these changes Jul 23, 2020
Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than the commit history

@mergify mergify bot dismissed stale reviews from rwalton-arm and Patater July 23, 2020 14:01

Pull request has been modified.

Refactor Mbed OS CMake scripts section - details about mbed-os/cmake scripts
Add mbed-tools - how mbed-tools built an application with CMake
@0xc0170 0xc0170 force-pushed the feature-cmake-design-update branch from 28bfd86 to 1f639f7 Compare July 23, 2020 14:07
@0xc0170
Copy link
Contributor Author

0xc0170 commented Jul 23, 2020

History fixed, should be ready now

@0xc0170 0xc0170 merged commit 157ebfb into ARMmbed:feature-cmake Jul 23, 2020
@mergify mergify bot removed the ready for merge label Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants