Sometimes I have source files in my project which I do not want to get compiled (or excluded from build). Because as I’m using the ‘managed make’, all source files matching certain extensions (like *.c) are automatically included into the build.
To exclude a file from build, I right-click on it to get to the properties. There I can select a check box to have it excluded from the build:
That file gets marked with an icon decorator:
To include it again into the build, simply remove that check mark again.
Another way is to use the ‘Exclude from build’ context menu which does the same:
Here it offers a dialog with the choice of build configurations where I can set a check mark from which build configuration I want to have it excluded:
This applies to all sources files to be compiled (usually *.c, *.cpp, *.cxx) and even linker files (*.ld, …). But what about header files????? The answer is that for header files it does not make any sense to exclude them: they are included by the compiler based on the include path (compiler) settings. So you cannot ‘exclude’ a single header file to be included. What you could do is to remove a path from the compiler settings, but then all header files will not be included.
Happy Excluding 🙂
Great post! Perhaps in a future post you can also explain how to bring back some of the excluded files, since this is a bit tricky.
Bringing the excluded files has not been a problem for me? Only if I exclude a file, then delete it, and add it again it is still excluded. But otherwise it is simple as removing that checkbox again. Or are you referring to something different?
Pingback: Semihosting (again!) with NXP Kinetis SDK V2.0 | MCU on Eclipse
Pingback: Tutorial: Using Eclipse with NXP MCUXpresso SDK v2 and Processor Expert | MCU on Eclipse
Pingback: Tutorial: Porting BLE+NRF Kinetis Design Studio Project to MCUXpresso IDE | MCU on Eclipse
Pingback: Tutorial: FreeRTOS 10.0.1 with NXP S32 Design Studio 2018.R1 | MCU on Eclipse
Pingback: Porting Processor Expert Projects to MCUXpresso IDE | MCU on Eclipse
Pingback: Tutorial: HD44780 Display Driver with NXP MCUXpresso SDK | MCU on Eclipse
Using KDS 3.0 I’ve created a processor expert project which contains FreeRTOS. I’m trying to use a C++ wrapper for FreeRTOS, which works if I rename main.c to main.cpp.
When I regenerate the code it creates main.c again and will ignore my main.cpp.
I follow the instructions above and the file is decorated with the slash and greyed out indicated it is no longer in the build, however, when I clean and build it still uses the main.c file!
If I then delete the main.c file, but forget to clean before I build, it still uses the main.o that was compiled before main.c was deleted.
I’d like to be able to just “Exclude from Build” the main.c so it doesn’t matter if it gets regenerated.
Any idea how to do this?
I don’t see what you describe with ‘clean’?
Here is how I do it:
– copy main.c to main.cpp
– exclude main.c from build
Note that Processor Expert still will update main.c (it will re-create it if I would delete it), so if there are any important changes I would have to copy them to main.cpp too.
The other approach is to prevent Processor Expert touching the main.c (see https://mcuoneclipse.com/2012/03/23/disable-my-code-generation/). Go to the project properties > Processor Expert and disable ‘Main module update’.
I hope this helps?
The first method did not work. Even with the main.c existing and set to “Exclude from build” it includes it anyway. The auto-generated makefiles simply include %.c (all c files).
The second method worked:
Project -> Properties -> Processor Expert; set “Main Module Update” to “Do not generate”.
Of course, I will have to regenerate main if there are any substantial changes and copy my code over, but that’s not a problem once the project is stabilized.
Pingback: Tutorial: RAK813 LoRaWAN+BLE+GPS Sensor Node with Eclipse IDE | MCU on Eclipse
Pingback: Debug and Execute Code from FLASH on the Seeed Arch Mix NXP i.MX RT1052 Board | MCU on Eclipse
Project -> Properties -> C/C++ General -> Indexer -> Build configuration the for indexer. Select the “Use active build configuration”
Yes, indeed: with this the indexer reflects the active build configuration.