Hello!
I would like to contribute to Plarformio Core by submitting support for mbedignore
file within the project.
I have already written those pre-extra scripts. One of them is mbedignore.py
which may be used as a pre:
script to ignore specific folders within the mbed framework.
The script works in such a way that for each entry in the .mbedignore
within the PIO project, it creates a .mbedignore
file within the mbed-os
framework, which is a package downloaded and maintained by pio
(e.g. on Linux it is ~/.platformio/packages/framework-mbed
). Each entry in the main .mbedignore
is a subdirectory within the mbed-os
framework. In turn, the script puts in each such subdirectory a .mbedignore
file that has content “*” to match everything within that directory. In case the .mbedignore
already exists in that subdirectory, it appends a line with “*” to that .mbedignore
file. The script is able to undo the operations, because it puts the previous, global .mbedignore
(from the root PIO project) to the mbed framework root directory. On each invocation (pio run
runs the pre:
script) this script compares the .mbedignore
from the root directory of the PIO project against the one inside mbed framework. The positive diff are the subdirectories which shall be ignored, and the negative diff are the subdirectories which shall be unignored. This means that switching between projects that use different .mbedignore
files is supported.
As you can see, this is quite a struggle and complex logic. Mbed already supports having a single .mbedignore
within the root repository of the main project. Generally, mbed-only projects use the mbed-cli
to build, run, test, … the project. For such a project, under the mbed-os
subdirectory, the sources of mbed OS are downloaded. The directory tree for such a project looks like that:
|
| ---- .mbedignore
| ---- mbed-os/
| ... others
.mbedignore
contains such entries:
mbed-os/connectivity/cellular/*
mbed-os/connectivity/drivers/cellular/*
mbed-os/connectivity/netsocket/source/Cellular*.*
So as you can see, it takes into account a single .mbedignore
without a need to put .mbedignore
within each subdirectory which is an entry in the file.
Since single .mbedignore
files, within the mbed framework package downloaded by pio, are used normally as mbed-cli
would do it, and I couldn’t find any code within pio-core
repository which reimplements that, my conclusion is that pio-core
utilizes mbed-cli
to build the project. I tried to figure out how does it do it, but with no luck. My main question is then:
How is mbed-cli
used by pio-core
? Could you reference the code which executes it?
Ideally, I would like to reuse the normal mbed-cli
behavior that handles the .mbedignore
within the root directory of the project. Then the complex logic related to ignoring/unignoring based on positive/negative diff would not be needed.
If it is not possible, then I would like to incorporate the script to pio-core
, but some improvements would have to be made, since the mbedignore.py
is not ideal:
- Support “official” file format (thanks @copperbot-d): at least the use of
mbed-os
prefix and*
“match all” suffix. That would allow easier project porting from “mbed-only” projects to “pio-with-mbed” projects. I don’t plan to support the format entirely, especially the?, [seq], [!seq]
patterns. They are used rarely. - Advanced handling of switching between various mbed-based projects. If the user has multiple “pio-with-mbed” projects, and switches between them. It means that some projects may use
.mbedignore
and some not at all. The implementation would have to take that case into account to unignore the subdirectories that has been ignored by the project run previously.
Once again, this would be supported out-of-the-box if we could supply a single .mbedignore
to the mbed-cli
.