-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Move mbed-stubs-platform to the platform directory #14773
Conversation
@rwalton-arm, thank you for your changes. |
|
||
add_library(mbed-stubs-platform) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stubs or doubles (the folder is named doubles but we talk or used stubs). Was there a reason to name the folder differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought doubles was more "correct" as some of these are stubs, some are a bit more like fakes. I can revert the folder name back to stubs if we think that's better/less confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doubles is fine then.
@rwalton-arm, thank you for your changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me this looks like a good, minimal-impact approach. The stub headers and sources are unchanged but just moved into the platform directory, with CMake definitions adjusted accordingly and decoupled.
Let's see if others from @ARMmbed/mbed-os-core agree with this approach.
@@ -31,7 +31,9 @@ target_link_options(mbed-stubs-platform | |||
--coverage | |||
) | |||
target_link_libraries(mbed-stubs-platform | |||
PRIVATE | |||
mbed-headers | |||
PUBLIC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR approach is good and minimal-impact but Initially, we have a discussion to use PRIVATE instead of stubs libraries target link libraries with PUBLIC refer #14285 (comment) & #14285 (comment), please share your thoughts
This pull request has automatically been marked as stale because it has had no recent activity. @ARMmbed/mbed-os-maintainers, please start CI to get the PR merged. |
@@ -17,14 +26,17 @@ target_sources(mbed-stubs-platform | |||
randLIB_stub.c | |||
randLIB_stub.cpp | |||
) | |||
|
|||
target_include_directories(mbed-stubs-platform | |||
PUBLIC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding all the platform stub headers into mbed-stubs-platform with PUBLIC again, this will be a problem if library unittest (example ATCmdParser unittest) don't want to include stub platform headers but target link aginst mbed-stubs-platform brought those the platform stub headers. Initially, that was one of the reasons we added a mbed-stubs-headers library, it is better to add a new library mbed-stubs-platform-headers INTERFACE library with all platform stub headers refer our discussion #14285 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I'm seeing the issue with the example use case you've given. Why wouldn't you want the headers to be available if you specifically linked to the stub library? I could see the inverse of this being a potential problem: you want the "stub header" but want to provide another implementation yourself. However, if a stub has some "public headers" (every header in this mbed-stubs-headers
lib is "public") it seems better to expose them as part of the stub library they belong to. Pulling all the headers out into a monolithic header-only library that requires non-obvious dependencies before you can use it seems like an anti-pattern. Also creating a separate "stub header" library for each stub seems unnecessary to me, unless there's a real issue we're solving by adding the extra library.
Maybe I'm missing something, so if you could show me an example of where this is actually an issue it would help me understand why we need to do this. It doesn't seem to cause a problem with the ATCmdParser
test you mentioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the original discussion @rajkan01 linked, @paul-szczepanek-arm said
If they are PUBLIC then if you depend on this library you also depend on the libraries it depends on.
This is like a header relying on another header to include something rather than including it itself. I think it's better if things are self contained and just exposing thing they are meant to expose and not what they are using themselves.
My interpretation of the concern is, if stub libraries A and B both have PUBLIC headers, and B depends on A, and a test T directly depends on B, then A will be "inadvertently" be exposed to T, is this the concern? But in order for compilation to succeed (because of how preprocessors work), this exposure is necessary IMO - otherwise how can T #include
something from B which then #include
something from A? Both A and B need to be in the include path.
Another thing is, the stub headers are for unit tests only which work within mbed-os, not intended for general use by other repositories, so flexibility isn't a concern and we should prioritise simplicity in my opinion. We are not messing with any "actual" Mbed OS libraries.
(Sorry if I completely misunderstood the original concern!)
Based on the review comment above, set to as needs: work. Rob is away this week so will get back to this one the next week. |
Hopefully this can get in after a rebase, as it's our initial PR to figure out how to refactor stubs of one module. |
50a6830
to
6c54ac1
Compare
Pull request has been modified.
This PR cannot be merged due to conflicts. Please rebase to resolve them. |
Move the platform stub library into the platform component directory. This change is so we can avoid duplicating the mbed-os source tree in a central UNITTESTS folder.
Move the header-only mbed-headers-platform library the unit test stubs depend on into the platform component directory. This makes the platform stubs more self contained and improves composition of the library.
Previously the platform stub library depended on `mbed-headers`, which is a collection of all available headers in mbed-os. To make it easier to separate the library, only depend on the headers we're actually using.
We have a central collection of "stub headers", which makes reasoning about dependencies rather difficult, as it forces every stub library to depend on all available stub headers. The standard approach would be for each stub library to expose its public headers, and its dependents to explicitly specify a dependency on the stub library containing the headers it needs. This is a more modular design than creating a header-only monolith library. Move the platform stub headers from this central library into the mbed-stubs-platform library to increase modularity. mbed-stubs-connectivity now depends on the mbed-stubs-platform because it requires some headers which were moved to mbed-stubs-platform.
We set the --coverage flag globally in UNITTESTS/CMakeLists.txt. We shouldn't need to also set it on mbed-stubs-platform, so remove it.
6c54ac1
to
55f77ea
Compare
Rebased. |
@0xc0170 Can we get this in today? |
@ARMmbed/mbed-os-maintainers |
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
Fixes #14795
This PR makes the mbed-stubs-platform library more self-contained by
removing the dependencies on the monolithic header libraries we created to
make implementing the stubs easier. We also move the files to the platform
directory so the stubs live with the associated component.
Now the mbed-stubs-platform library should only depend on the headers it
uses. It also now owns and exposes it's own public headers rather than
depending on every available stub header from the mbed-stubs-headers library.
This change makes the flow of dependencies easier to see and allows for a
more modular architecture moving forward.
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers