Sometimes it is very useful to clean or build a selected set of files. For this I select the file(s) in the Eclipse Project Explorer and use the context menu:
This is handy to quickly check if a source modification builds fine, without the need to rebuild a large set of files:
09:55:47 **** Building Selected Files of configuration Debug for project FRDM-K64F_Fusion **** Info: Internal Builder is used for build arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -g3 "-I..\\Generated_Code" -I../Sources -I../Project_Settings/Startup_Code "-IC:\\nxp\\KDS_3.2.0\\eclipse\\ProcessorExpert/lib/Kinetis/iofiles" "-IC:\\nxp\\KDS_3.2.0\\eclipse\\ProcessorExpert/lib/Kinetis/pdd/inc" "-IC:/Users/Erich Styger/Data/HSLU/Vorlesung/nemesis/CCE/Eck/KDS/FRDM_K64F_Fusion/Sources" "-IC:/Users/Erich Styger/Data/HSLU/Vorlesung/nemesis/CCE/Eck/KDS/FRDM_K64F_Fusion/Generated_Code" "-IC:\\nxp\\KDS_3.2.0\\eclipse\\ProcessorExpert/Repositories/Kinetis_Repository/lib/Kinetis/pdd2/MK64FN1M0LL12/system" -std=gnu11 -c -o "Sources\\Application.o" "..\\Sources\\Application.c" arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -g3 "-I..\\Generated_Code" -I../Sources -I../Project_Settings/Startup_Code "-IC:\\nxp\\KDS_3.2.0\\eclipse\\ProcessorExpert/lib/Kinetis/iofiles" "-IC:\\nxp\\KDS_3.2.0\\eclipse\\ProcessorExpert/lib/Kinetis/pdd/inc" "-IC:/Users/Erich Styger/Data/HSLU/Vorlesung/nemesis/CCE/Eck/KDS/FRDM_K64F_Fusion/Sources" "-IC:/Users/Erich Styger/Data/HSLU/Vorlesung/nemesis/CCE/Eck/KDS/FRDM_K64F_Fusion/Generated_Code" "-IC:\\nxp\\KDS_3.2.0\\eclipse\\ProcessorExpert/Repositories/Kinetis_Repository/lib/Kinetis/pdd2/MK64FN1M0LL12/system" -std=gnu11 -c -o "Sources\\main.o" "..\\Sources\\main.c" arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -g3 "-I..\\Generated_Code" -I../Sources -I../Project_Settings/Startup_Code "-IC:\\nxp\\KDS_3.2.0\\eclipse\\ProcessorExpert/lib/Kinetis/iofiles" "-IC:\\nxp\\KDS_3.2.0\\eclipse\\ProcessorExpert/lib/Kinetis/pdd/inc" "-IC:/Users/Erich Styger/Data/HSLU/Vorlesung/nemesis/CCE/Eck/KDS/FRDM_K64F_Fusion/Sources" "-IC:/Users/Erich Styger/Data/HSLU/Vorlesung/nemesis/CCE/Eck/KDS/FRDM_K64F_Fusion/Generated_Code" "-IC:\\nxp\\KDS_3.2.0\\eclipse\\ProcessorExpert/Repositories/Kinetis_Repository/lib/Kinetis/pdd2/MK64FN1M0LL12/system" -std=gnu11 -c -o "Sources\\Shell.o" "..\\Sources\\Shell.c" 09:55:48 Build Finished (took 987ms)
In the screenshots I’m using NXP Kinetis Design Studio v3.2.0 which is Eclipse Luna based, but things should apply to any other Eclipse distribution.
The menus to build and clean selected files is only available if ‘Build Automatically’ is *not* enabled:
This is a workspace setting under Window > Preferences:
Troubleshooting
There has been (and still are?) some Eclipse CDT glitches around this. I have seen cases on my system that sometimes the ‘Clean Selected Files(s)’ and ‘Build Selected File(s)’ are still grayed out. In that case:
- Verify that ‘Build automatically’ is disabled, both in the Project menu and in the workspace preferences. Change the setting to make sure it gets written to the settings, then restart Eclipse.
- Try with a new workspace, first with a ‘new’ project, then import your existing project into that new workspace and try it out. If this works, then it is probably a setting in your old/existing workspace. If somehow only works with the new workspace, you probably should go with the new workspace and import your existing project into it. I had this issue with a workspace I carried through different Eclipse versions.
- Make sure you select only files you can build, e.g. not a *.h file.
Summary
Building or cleaning only a few files which I select is a nice feature. It only works if ‘build automatically’ is disabled.
Happy Building 🙂
This is very useful! Do you know if there is a way to force a clean on a particular file every time a build is initiated? Ihave a file that embeds a time stamp using __TIME__ and would like an easy way to have that file always build. My current method deletes the .o in a prebuild step, but due to some Eclipse oddities it doesn’t always rebuild if using parallel compilation. Thanks!
LikeLike
Hi Michael,
I would have suggested a pre-build step too, so not sure what is going wrong with parallel build here. It could be that Eclipse has cached some of the file status and does not realize that the object file has been removed. Another way would be to ‘touch’ the file and change the file timestamp?
Erich
LikeLike
Eclipse ignores pre- and postbuild steps, when parallel build is used with internal builder, it’s f(…) ridiculous, because it makes it unusable for larger projects, but it isn’t fixed since 2007… https://bugs.eclipse.org/bugs/show_bug.cgi?id=199758
LikeLike
That’s why I’m mostly using external builder in Eclipse 😦
LikeLike