Monday, May 14, 2007

Would you like JDT with that?

In a recent conversation in bugzilla someone asked if it was common for people using CDT to also have the JDT installed. The short answer is "yes" but that's not always because they are developing in Java as well as C++.

When people start with our Carbide.c++ they run a branded installer like you get with most Windows apps and you get an entry in the Start menu etc. We install a JRE and a bunch of Eclipse features but not the JDT. People focused on C++ development didn't want to see "all the Java stuff" so we left it out.

But people who are also doing Java development (sometimes developing plug-ins for Carbide) or who already have Eclipse configured with their favorite plug-ins can just take our Carbide features and merge them in. Corporate IT people often like to have a standard version of Eclipse that usually includes the JDT since it is seen as part of the base platform. Also some plug-ins out there assume the JDT is present and will not work correctly if it isn't. So we've got to assume there is a good chance the JDT will show up at some point.

I recall one of the sessions at EclipseCon this year where the presenter was showing Eclipse with all of the Europa plug-ins (and maybe some others) installed. The UI was an impressive jumble of widgets and completely confusing. Someone said something about capabilities being useful but added that "no one uses them."

I was surprised as we use capabilities extensively to keep the user experience focused on C++ development when people are using Carbide, mostly by hiding CDT UI that isn't used when developing apps for Symbian OS. At some point I'll have to see if we could start including the JDT but keep the UI subdued unless you start working with Java projects.

Monday, May 7, 2007

Structuring C++ Projects in Eclipse

We’ve been struggling with how to represent C++ projects in Eclipse so I thought I would share our story in case anyone can offer any better suggestions:

It’s common for developers to already have their code organized something like this:

/Source/Projects/CPPProjectOne/src – project one specific code
/Source/Projects/CPPProjectTwo/src – project two specific code
/Source/Projects/CPPProjectThree/src – project three specific code
/Source/Projects/Common/src – source common to all CPP projects

We can not copy the source files to another location or move anything around, we have to work with them exactly where they are in the file system. Since for each project we call a custom make builder that doesn’t depend on anything in Eclipse the main thing we want our Eclipse projects to do is contain as much of the code as possible so that all of the splendid IDE features work correctly.

Our first thought was to put the Eclipse projects in the workspace and then stuff them with linked resources to the actual source files and folders. That seemed like a great fit for linked resources and would be fairly straightforward to do. However we discovered that linked resources are not really first class citizens in the workspace: to begin with they don’t work with version control (41929) so we had to abandon that idea.

Our next try was to just locate the Eclipse project and it’s source root where the cpp project’s code actually lives. When we import a cpp project’s make file we can look at the included sources and determine a root location that covers all the files. So using the above example CPPProjectOne’s source root would be /Source/Projects. This works OK, we end up with an Eclipse project that lives at /Source/Projects/.project and includes resources for all of the desired files (plus lots of other stuff too).

The trouble begins when I want to work with CPPProjectTwo at the same time. I find that it has the same common source root location as CPPProjectOne, but I can’t put a second Eclipse project there as a .project file already exists in that location.

The best work around we have been able to think of for now is to have the second project use a more narrowly scoped source root, in this case it could use /Source/Projects/CPPProjectTwo. But that will leave other files it uses, like those from /Source/Projects/Common/src, out of the project.

If we could either put more than one Eclipse project in the same location or tell a project to use something other than its location as a source root (78438) then we could accommodate any number of projects. Or if linked resources worked better we could use those. Just now we’re stuck telling people to try the work around but we need to determine what direction to pursue longer term so we can make this work the way people expect.