Build Configurations in Eclipse

Eclipse based IDE’s have a powerful feature to make ‘variants’ of the same projects: Build Configurations. Build configurations are a powerful thing in Eclipse: they allow me to make ‘variants’ of a project. The project will share the common things, and I can simply tweak things one way or the other for example to produce a ‘release’ or a ‘debug’ binary of my application without duplicate the project.

Build configurations are manged through either the context menu on the project or with the top menu:

Eclipse Project Build Configuration

Eclipse Project Build Configuration

I’m showing in this post screenshots from NXP Kinetis Design Studio V3.2.0, but things are applicable to pretty much any Eclipse based IDE.

💡 Build configurations only apply to the build settings, and not to the debug settings.

With the ‘Manage’ option I can manage my configurations:

Managing Build Configuration Dialog

Managing Build Configuration Dialog

For example I can add a ‘Release’ configuration with the ‘New’ button:

💡 See “Debug vs. Release?” for more thoughts on that topic.

Creating New Configuration

Creating New Configuration

I give a name and an optional description. I usually ‘clone’ from an existing configuration. That way I get a new configuration with a good starting point.

One configuration is always active, and the ‘manage’ dialog can be used to change the active configuration:

Active Build Configuration

Active Build Configuration

The active build configuration shows up in the list of configuration e.g. under the build ‘hammer’:

Active Build

Active Build

So how can I specify settings for a configuration? For this there configuration area in the project settings:

Configurations in Project Settings

Configurations in Project Settings

There is a button to manage the configurations, and a drop down to select the configuration which I want to affect. There is as well one item in the list as [All Configurations]: when using that item, changes are ‘pushed’ to all configurations.

For example I can set a different compiler optimization for the Release configuration:

Release Configuration with high optimimzation

Release Configuration with high optimimzation

💡 When using multiple configurations, always check to which configuration you are making the changes.

The configuration name is used as the name for the output folder name:

Configuration Name in Output Folder

Configuration Name in Output Folder

That way for each configuration separate binaries are built.

If I want to build multiple build configurations in one build, then I have a workspace option for this. The build scope option is a ‘global’ option and is used for all projects in the workspace:

build scope

build scope

Summary

Eclipse configurations are a great way to make different variants of projects. A new configuration can be cloned from an existing one, and then tweaked for example to build a release binary or to use custom build settings.

Happy Building 🙂

24 thoughts on “Build Configurations in Eclipse

  1. This comes in handy for more than Debug and Release. I’ve written code that builds for multiple Arduino boards using ToddlerEclipse. I’ve used it to debug code on my desktop that is then targeted for the Raspberry Pi. That’s using Eclipse Mars.

    Like

  2. Pingback: GNU Code Coverage on Embedded Target with Eclipse Neon and ARM gcc 5 | MCU on Eclipse

  3. Hello,
    I am playing around in S32 Design Studio IDE (still Eclipse based) for a couple of days.
    This post is very useful.
    But I still don’t understand how to go further.
    I have my Release build configured. Now I am try to run the project in Release mode.
    For that I make a new “Run Configuration”. After setting up, I still have issues launching the .elf file.
    I already checked if the proper elf is loaded. What else should I check?
    Some guide will be really helpful.
    Thank you !

    Like

  4. so I’m trying to get this to also include (or in Eclipse parlance “exclude”) particular .c files (or any other resource I should think) in each configuration. This is using KDS 3.2

    If I right click on a .c file, there is an entry “Resource Configurations->exclude from build… where it presents you a list of configurations (which are created as you note above) with checkboxes so you select which configuration to exclude the build of this resource on.

    When it excludes the resource from a configuration, it shows it in the explorer window as grey with a slashed icon (indicating not being used). This is what I expect.

    The problem I’m having with it is that even when I set the active configuration to the second one, the display (and compiles) all looks like they use only the first configuration (what would be your default). Every place that tells me what configuration is in use agrees with each other, just not project explorer (it never changes what it has greyed out).

    Not working as I expect it to but then again, maybe I’m expecting the wrong thing.

    Like

  5. Interesting…. I’ve created a third configuration here assuming the default one is “special” and assigned the .c files that should have been in that configuration to the new one.

    So now none of the conditional ones are excluded from any profile according to the project explorer view. Basically the behaviour is that everything that is showing excluded in the default “debug” configuration actually is excluded but if it’s excluded in any other configuration, it is not excluded. so this first configuration is somehow special or there is something that can’t tell the difference.

    This is on KDS 3.2.0

    Like

    • One thought (about something fooled me sometimes): do a Refresh/F5 in that Project Explorer view, maybe this helps.
      Other than that: open the .cproject with a text editor and search for that file: I guess something is wrong in there, and you might be able to fix it with the text editor?

      Erich

      Like

      • got this to work be deleting the default debug configuration basically….

        Chalk it up to a confused KDS — works fine now.

        thanx

        Like

  6. hello Eric,
    Thanks for sharring this intresting article for me at least.
    However what am i really searching is a brief explanation about c/c++ eclipses tools used to set
    the build configurations and i can not find something on it.
    Please If you have any good source to propose share it.
    Thanks,
    Nick

    Like

    • Hi Nick,
      not sure what you mean with ‘c/c++ eclipse tools to set the build configuration’? In Ecipse you can change/create/delete the build configurations as shown with this article. Or what I’m missing?
      Otherwise you could use XML parsing/creating tools to modify the .cproject file?

      Like

  7. Pingback: Linking Bootloader Applications with Eclipse and FreeMarker Scripts | MCU on Eclipse

  8. I’ve been using Build Configurations in Eclipse (KDS) for many years now and I can’t imagine how difficult it would be to manage all of my variants without it.
    But my project has grown to support over 30 variants and each has a Debug and Release configuration, so Eclipse is now struggling to manage 60+ configurations of the same project. The file “.cproject” is almost 2MB! So I’m now looking for an alternative method.

    The only difference between the 30+ configurations is one defined symbol. I use that symbol in my code to select a particular header file with variant-specific options.

    i.e. One of the Eclipse configuration sets the symbol “APP_CONFIG_ARIES_TWOCOLOR” (in proj properties -> C/C++ Build -> Settings -> Cross ARM C Compiler -> Preprocessor)

    And in a header I have:
    #if defined APP_CONFIG_ARIES_TWOCOLOR
    #include “app_config_ARIES_TwoColor.h”
    #elif defined APP_CONFIG_ARIES_SPECTRUM
    #include “app_config_ARIES_Spectrum.h”

    #elif defined APP_CONFIG_CC2_WdBd
    #include “app_config_CC2_WdBd.h”

    #endif

    I’m looking at the “Make Target” option in Eclipse as an alternative. Could I reduce my Configurations to 1 or 2 (for debug) and instead use Project -> Make Target to select one of the 30 variants? Is there a way to pass a preprocessor define into Make?

    Like

    • Wow, 60 configurations!
      I’m not aware of a way that the make would directly read a define/variable: but it can get variables on the make command line or read them in from a file.
      I’m using preprocessor defines too, but I tend to use the -include option with an external file (see https://mcuoneclipse.com/2019/02/23/different-ways-of-software-configuration/).
      You could create a script (or somthing similar) to write/change that config file as part of the build?

      Like

      • That’s an interesting idea to run a script that selects the variant to build before invoking a single generic build through KDS. (similar to how make menuconfig creates sdkconfig file) I would structure it so that the chosen variant setting is ignored and not committed to my VCS.

        Going further, a complete build script sounds like a good approach. Do you have an article about scripting the build process for KDS? (even better if I don’t have to launch KDS to build, since I’m primarily using VScode as editor now)

        Thanks for your help Erich! You’re a great mentor.

        Like

  9. Pingback: LoRaWAN with NXP LPC55S16 and ARM Cortex-M33 | MCU on Eclipse

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.