The ability to define a specific file for the mbed compile --source <path-to-file>/<file-name>.c exist _but_ apparently there is no way to define a specific headers only folder (*.h) that will suppress *.c or *.cpp files assuming we would like to avoid using .mbedignore for this matter.
i.e.: mbed compile --source main.cpp --source_incs some_path_to_folder/inner_folder
The --source_incs directive (if was exist) suppresses anything that is not *.h
@jenia81
@screamerbg
ARM Internal Ref: IOTMORF-347
I would propose --include , as we got --source, and includes could be either a path or a file (extension check as mentioned above).
I'm not sure why we aren't considering a --source directory to also be an include directory. This would be consistent with the way our scanner works.
It sounds like the feature request here is to be able to include a folder but only allow certain types of files to be included? Maybe instead of creating a --include, we could just add globing support to --source? So something like --source=myproj/source/*.h ?
Actually that will blow up in bash :)
@bogdanm We are. This is a feature request to have a --source like argument that only searches for includes.
@mottigondabi Is there a reason the source is organized in this way? It seems like a very unusual use case. It seems like the quickest way forward would be to just move the .h files into a separate folder and include that.
This is a feature request to have a --source like argument that only searches for includes.
Sorry, I've apparently mistaken this with another issue.
Hi all, hi @bridadan, hi @theotherjimmy ,
As a prove of concept, I want to build (using tools/build.py) a small application using code external to mbed. To be able to quickly build this application without copying source code, I would like to include header files using the GCC -I flag.
When diving into the mbed python code I noticed the following:
Now my question is: What is the ‘mbed way of working’ to include external header files? Is there a configuration file which I’m missing?
Some notes:
• Do I need to add definitions to tools/settings.py or tools/private_settings.py?
• I noticed that there is a file automatically generated which has some (‘default’) -Ixxxxxx parameters, “./.build/mbed/.temp/TARGET_FOOBAR/TOOLCHAIN_ARM_STD/.includes_c08fabc2ca06f19fcd6a2883245a3dae.txt”.
It’s clear to me that the build_library function eventually fills in its parameters into this file, but can you point me out in code where the ‘default’ values are written to this file?
I hope you guys can help me out?
Thanks in advance,
Kr,
Simon
@sima-gp You bring up an interesting point. The most logical reason I can think of why an equivalent -I option isn't available from the build.py CLI is that it was never needed! build.py historically knew how to build all the libraries (aka, knew which directories to include/not include). It didn't rely on input from the command line, but rather data stored in the python tools (if you're curious, libraries.py is where this data is kept). It was never intended to be a general purpose build system, so this kind of a general flag was never added.
The "mbed way" in the past has always been to just copy the source into your working directory and let the tools do the rest. The 'default' values for the include file you mentioned is built up from the source in your working directory.
What is the ‘mbed way of working’ to include external header files?
At the moment that works as follows:
--source flagIs there a configuration file which I’m missing?
There is not, unless you consider tools/libraries.py a 'configuration file'.
I still think there is a case for this. When you submodule other projects there sometimes are files you do not want to include in the build (like test.cpp that also has a main function). You can explicitly add the source files, but there is no way to point it to the headers.
I am aware you could exclude files using mbedignore, but that means you would have to fork the repo.
@jorisa .mbedignore files work across repo boundaries.
That is:
.
├── README.md
├── main.cpp
├── mbed-os
├── .mbedignore
└── mbed-os.lib
The .mbedignore here can ignore files within the mbed-os directory. This allows me to ignore things in sub-repos without a fork of the sub-repo.
Most helpful comment
@mottigondabi Is there a reason the source is organized in this way? It seems like a very unusual use case. It seems like the quickest way forward would be to just move the
.hfiles into a separate folder and include that.