How to Restore a File's Default Build Settings in Eclipse

162 views Asked by At

Due to project size, compiler optimizations are enabled, so that the build binary will fit onto our microcontroller. Optimization for select files is disabled (for debugging purposes) by right-clicking a source file in the Project Explorer >> C/C++ Build >> Settings >> Optimization >> Optimization Level >> Optimize for debugging (-Og). This leaves the file's icon tagged with a little super-icon wrench or key (hard to distinguish). Manually changing the optimization level back to the default of Optimize for size (-Os) does not remove the super-icon.

How can the default file settings be restored? I tried clicking on File Properties >> C/C++ Build >> Restore Defaults, but it seems to have no effect. Is there another way?

We're using Eclipse 4.14. Thanks.

1

There are 1 answers

0
Nate T On BEST ANSWER

As you probably know, eclipse CDT plug in gives you the option to import and export project settings and build configurations in XML format. One solution involves leveraging this feature to solve your issue.

Assuming that your project uses a get repository, or at least some sort of VCS, you can simply branch (if using reset) your project, use git reset or git branch -b old-revision <HEAD-for-desired-revision> to start a new branch pointed at an earlier commit with the settings in the desired state, export those original unaltered settings , and finally import the the settings into your current branch (or else make a parallel branch which you can merge after successfully importing, just to be safe.)

This may sound a bit convoluted and cumbersome at first, but it is actually pretty straightforward. Furthermore, this method gives you control over the process (in other words, doing it all yourself ensures that it gets done...)

As an added bonus, you can restore your configuration not only to default, but to any previous state.

In case you need a refresher on any of these concepts I have included links below:

This article explains in detail how to import and export your CDT project settings. Scroll down to the section titled import/export . It will also provide you with any information you need regarding the XML settings files.

Here is a quick tutorial on restoring an older revision using git -- with git reset or by checking out a new branch pointing to an old revision, just in case you need a refresher.

Also, you should probably export your CDT settings each time you change them. You can create a resource folder somewhere in the dev branch of your project, and keep the all revisions inside in chronological order, just in case you ever need to swap them out in the future.