I'm writing an external library (a component controller) for use with mbed 5 and plan to make it available in the mbed repositories. I want to write tests to confirm that my code is working properly, but they're just regular ordinary unit tests and don't need to be run on an embedded controller. I'm looking at Catch as my framework, which provides a main
for the test suite.
When I build my project with the mbed
CLI or Eclipse CDT (using an exported project), what .cpp
files are included, and what .o
files are linked into the embedded image? Does the image only include code pulled in from my main.cpp
file via includes, or does it compile and link all of the .cpp
files visible (potentially including my test cases)? If the latter, is there a clean way to exclude them that won't collide with the built-in utest functionality?
All .cpp
files are included, but there are some exceptions. FEATURE_
and TARGET_
folders are special, and are only added when your board has a certain feature (or is part of a certain target). I think there's something special about TESTS
as well.
You can see the exact commands that are fed into the compiler / linker via mbed compile -v
, or if you want a neat list, export to a makefile via mbed export -i make_gcc_arm
, which will list all files.
If you want to learn more about the inner specifics, or want to script around these, all logic is implemented in a Python module, and you can use this in your own Python scripts to get lists of headers / symbols / defines / etc. that will be included. For example, see vscode/__init.py__
.
Note: if you want to exclude a certain file or folder, you can do so via .mbedignore.