Exclude Source Files from Build in Eclipse

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:

File Excluded from Build

File Excluded from Build

That file gets marked with an icon decorator:

File with Icon Decorator

File with 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:

Resource Configuration to Exclude from Build

Resource Configuration to Exclude from Build

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:

Exclude from Build with Build Configurations

Exclude from Build with Build Configurations

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 🙂

Advertisements

4 thoughts on “Exclude Source Files from Build in Eclipse

    • 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?

      Like

  1. Pingback: Semihosting (again!) with NXP Kinetis SDK V2.0 | MCU on Eclipse

  2. Pingback: Tutorial: Using Eclipse with NXP MCUXpresso SDK v2 and Processor Expert | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s