2

I am building an embedded C++ project with eclipse. I want to set-up a continuous integration system where a build server would compile and run unit tests each time a commit is made to the github repo.

My problem is that the C++ project uses eclipse for development and I don't know how to automate a build with a .cproject/.project the same way you would do it with a makefile and a CI framework like TravisCI or Jenkins.

I thought I about maybe using the "generate makefile" feature but I don't want to have to regenerate a new makefile each time I make a change on a .project or .cproject file.

Anyone have any suggestions?

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Alex C
  • 217
  • 2
  • 11

2 Answers2

5

After some research, I think the best approach is to use what is called a headless build. It takes the .project and .cproject and compiles it.

$ eclipse \
--launcher.suppressErrors \
-nosplash \
-application org.eclipse.cdt.managedbuilder.core.headlessbuild \
-data /path/to/workspace \
-cleanBuild "project/configuration"

The result of the above command is a clean build of the given project configuration from the given workspace.

http://gnuarmeclipse.github.io/advanced/headless-builds/

Alex C
  • 217
  • 2
  • 11
0

You can rather use a custom Makefile project, than letting Eclipse building a Makefile for you.

You'll need to invest some time to develop a generic build system, that auto detects source files to be included to your build and handles all of their dependencies.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
  • I thought about doing this, but I'd rather not have to maintain a separate build system from the one that we use to develop the software. One of the goals of the CI system would be to detect compilation errors if one arises after a push to the source code repository. – Alex C Jan 04 '16 at 19:54
  • @AlexC _"but I'd rather not have to maintain a separate build system from the one that we use to develop the software"_ I'm not talking about a _separate build system_, but using the same one for Eclipse and the CI system. – πάντα ῥεῖ Jan 04 '16 at 20:02
  • Oh ok, you mean instead of using the eclipse .project files to build the project, to use makefiles to build the project and make eclipse use that makefile to perform builds? – Alex C Jan 04 '16 at 20:56
  • @AlexC Yes, that's the better approach as far I've experienced. – πάντα ῥεῖ Jan 04 '16 at 21:01
  • The big advantage of Alex's apporach is that Eclipse recreates its makefiles when launched. So, if you have added/renamed/deleted any files, Eclipse will take care care of that, which reusing the old makefile might not. – Mawg says reinstate Monica Oct 06 '16 at 15:33
  • 1
    @Mawg With a good build system I prefer to control the makefiles myself anyways. – πάντα ῥεῖ Oct 06 '16 at 16:35
  • I quite understand :-) I just thought that I would point that out for the lazy ones like me. headless Exclipse CDT and Jenkins really help us. – Mawg says reinstate Monica Oct 06 '16 at 16:56