开发者

How to build to chroot using Eclipse CDT?

I've got a chroot environment with everything needed for building a complex C++ project, using make (it's for a specific Linux distribution).

I would like to use Eclipse开发者_运维百科 CDT (outside the chroot environment) in this project but make it so that Eclipse, when building, goes into the chroot enviroment and builds in there.

Is it possible?


Yes thats possible. Just select the 'External builder' within the Builder Settings Tab under C/C++ Build. I selected a script that executes the following commands:

sudo chroot $HOME/mychroot/  bash -c 'cd /myproject-location/; make clean; make'

To avoid a password check i added the following line to my /etc/sudoers file:

%sudo   ALL= NOPASSWD: /usr/sbin/chroot

To avoid wrong build failure/syntax error reporting you have to add the include files from within your chroot environment to the eclipse cdt project.


A slightly more elegant way is to make a script compile.sh

#!/bin/bash
sudo chroot $HOME/mychroot bash -c 'cd /workspace/'$1'/; make '$2

and in eclipse write this to you external builder

/pathto/compile.sh ${ProjName}

That makes partial builds possible, because the build targets are passed into the chroot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜