Sunday, July 3, 2011

Eclipse CDT: removing non-existent include paths

It seems that Eclipse CDT doesn't like it when you have a non-existent path in the list of project include paths. Fair enough. You can selectively remove the non-existent paths from your project via some mouse-clicking.

But if you are generating your Eclipse project via, say, CMake and you're unfortunate enough that you can't reasonably change the CMake project files (think of evil upstream and you not wanting to patch their overly complex build system changing with every release), what do you do? After a bunch of project regenerations removing of the include paths by hand becomes annoying.

As I was experiencing this issue, I decided to hack together an Eclipse plugin to resolve this for me. And here is the result: fixincludes Eclipse CDT plugin.

It's pretty basic. Nevertheless it proved to not to be all that easy to write, as it seems the CDT devel side lacks (good, up-to-date) documentation. Or I have not found it.

Anyway, there is both a binary archive and a source archive. It should work with both Eclipse Indigo + CDT 8.0, or Eclipse Helios + CDT 7.0.

To install the binary one: Just grab the binary jar and put it into the dropins subdirectory inside your Eclipse install directory. After starting Eclipse you should see a new item in the Project menu: Fix Includes.... Clicking that should fire up a dialog asing you for CDT projects to operate on. In turn it should remove all non-existent include paths. Or at least most of them. :-)

To get the sources: You need to have the Eclipse Plug-in Development Environment installed. In File/Import... select Plug-in Development/Plug-ins and Fragments. Then point the import wizard to the directory where you downloaded the source jar (Import From: Directory). Import As: Project with source folders. Then select the project in the next screen and you should be ready to go.

P.S. To install the Plug-in Development Environment click Help/Install New Software... (Obvious, isn't it? :-)) and then select General Purpose Tools/Eclipse Plug-in Development Environment. To build the jars, use File/Export..., Plug-in Development/Deployable plug-ins and fragments.

P.P.S. While there are some bugs and some TODOs, it works enough for me. I'm putting it here in case someone else finds that useful too.

No comments:

Post a Comment