Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Programmatically excluding files from build "on-the-fly"

I am new to CDT, trying to write an extension for it, and hoping some of the experts here will be able to help me out with finding the best way of achieving my goal before I possibly invest too much work going in a suboptimal direction.

We are building a specialized IDE on top of CDT (currently CDT 7.0.1 on Eclipse 3.6.1) for a C++ codebase whose characteristic it is that we have a number of source files always present on the file system, but only a subset of them, depending on various circumstances, needs to be compiled and linked into the build product for any given build (this is a requirement that cannot be changed).

Our current prototype achieves this by inserting another builder that runs before the CDT builder, evaluates the conditions to determine the subset of files to be built, and sets the source folders and exclusion patterns of the active configuration, i.e. the "exclude from build" setting of each file (these are the same thing, right?), accordingly.

This appears to work, but has a few disadvantages (not deal-breakers, but maybe there's a way of avoiding them):

- The source folders are persisted in the .cproject file, which means this file changes every time our subset changes (actually, it currently doesn't do that reliably, but that's something I need to fix, but haven't figured out how yet), creating unwanted diffs in version control. For our purposes, this information is redundant and doesn't need to be stored, since it is regenerated (from information stored elsewhere) on every build.

- Overwriting the "exclude from build" settings / source folders and exclude patterns means that users can't use them for their own purposes anymore, as their manual modifications will be wiped out at the next build. This is confusing at best and a loss of functionality at worst.

Is there a better way of achieving what I want? Ideally I would like to hook into the CDT makefile generator and tell it which files to consider on the fly, without clobbering any persistent user settings, but I haven't found any extension point that would allow me to do that - and replacing the entire thing looks like a daunting task.

 -Christian


Back to the top