C/C++ Eclipse Project Generation

With the landing of bug 973770 (and a few touch up landing this week) the Mozilla build system can now generate a fully working out-of-the-box no hassle eclipse workspace for C++ gecko development. This has been tested for Mac, Fennec and B2G. For Windows please use the Visual Studio project generator. If you find any bugs please file and link off bug 973770.

Didn’t we already support eclipse projects? Yes we did but the setup was quite tedious to setup and maintain. My approach automates some of these instructions and uses the information now available from within moz.build to generate the project. This also means we can remove the build scanning phase which tends to make Eclipse unresponsive.

To use this:

  • Download the latest Eclipse CDT 8.3 package for your platform
  • Build your tree
  • Run |./mach build-backend -b CppEclipse|. For b2g cd into objdir-gecko and use |../gecko/mach build-backend -b CppEclipse|
  • Start eclipse, use $OBJDIR/eclipse_workspace as the workspace
  • File->Import->Existing Project with path $OBJDIR/eclipse_workspace/gecko
  • Let the indexer run on the first start. This can take about 20 mins (long but worth it, see below). This will index your exact mozconfig setup (example -DDEBUG, b2g system libs).

Here are some benefits:


Code Completion

Call Hierarchy

Call Hierarchy

Build, Flash (b2g), Launch

Build, Flash (b2g), Launch

Type Hierarchy

Type Hierarchy

Mozilla Formatter

Mozilla Formatter

If you find yourself tweaking the project let me know so that I can integrate changes into the project generator instead where everyone can benefit.

9 thoughts on “C/C++ Eclipse Project Generation

  1. Are there any plans to do anything with the JS portions of the build process? At the moment all this work (ie the VS integration, too) seems to be useless for frontend folks. 😦

    • I don’t have any plans on doing this myself but I would gladly help someone doing this. We already have separate code for generating a project for Fennec Java development.

      As far as I know Eclipse doesn’t have any fancy support for JS so perhaps all that needs to be done is giving the front end code a non recursive build target (extending build binaries).

    • The generated cpp files? I already get the ipdl files indexed. I don’t work with webidl/xpidl but I imagine if they don’t already work it’s just a matter of finding the settings and updating the project generator.

  2. I appreciate for your post to make me can generate the Eclipse project for B2G. I would like to ask a question about how debug the Firefox OS device on Eclipse. Could you explain it more detailed, especially the debug configuration part. Thanks a lot.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s