Eclipse - Build vs Rebuild (makefile C project)

Viewed 524

I have a makefile C project on Eclipse.

When looking in the menu under Project > Build Targets there are a few options. These two interest me:

  1. Build...
  2. Rebuild Last Target

The basic question is what does Eclipse to differently in both cases? To be more specific:

  1. What build goals does it set in the two cases?
  2. Does it do anything different before invoking make?
  3. Why can you rebuild only the last target?
2 Answers

You can create custom targets (Window -> Show View -> Build Targets). Those targets can have special parameters linked with your Makefile, by example it can change the verbosity, the level of optimization or even change the features included in your software.

When you use the simple Build command, Eclipse will execute the default build command which is usually make all. But when you use your custom target, then it's your custom parameters that are used, which could be by example : make target_foo VERBOSE=1 BAR_OPTION=TRUE OPTIMIZE=TRUE

After this, if you use Rebuild last target it's your custom target which will be built.

As an example, working in embedded systems I usually have a mix of targets that enable or disable :

  • Code optimization (it's often easier to debug a code that wasn't optimized)
  • Debug printfs
  • Debug GPIO

With build targets you are allowed to add/use non-default make targets for your makefile projects. Build targets/build lets you first select target from a list of targets then executes make "selected-target". Build targets/build last target repeats build with last target selected via targets/build.

You might be looking at the wrong menu if you are only looking to build your makefile project. You do that by Project/Build project. This by default executes "make all", but you can configure this via "Project/Properties/C/C++ build/Behavior".

Related