Wednesday, October 15, 2008

Remote Building on Eclipse

I recently had a need, or desire, to develop c++ code on Eclipse in windows, but have it build remotely on a specially configured linux box. Here's how I did it:

  • Get Cygwin and make sure ssh.exe and rsync.exe are installed with it.
  • I created a make.exe file out of the following (which I put in C:\WINDOWS):


#include
#include

main(int argc, char * argv[])
{

char str[200] = "make.bat";
int i = 0;
for (i = 1; i < tmp =" argv[i];">


  • I created a make.bat out of the following (which I put in C:\WINDOWS):


@echo off
set CURDIR=%cd%
chdir C:\Documents and Settings\g...ROOT OF PROJECT HERE
C:\cygwin\bin\rsync.exe -rave C:\cygwin\bin\ssh.exe . guser@192.168.0.1:~/remoteBuild
C:\cygwin\bin\ssh.exe guser@192.168.0.1 python remoteBuild.py """%CURDIR% --- %*"""

  • On the remote machine, I created a remoteBuild.py with the following (left in my homedir). This code is highly customized, so you will probably need to modify it. What it basically does is it converts C:\.... to a linux style path.

def main():
args = sys.argv

argsFromWindows = args[1]
print "received: " + argsFromWindows

path, buildArgs = argsFromWindows.split("---")

relPath = path.split("CUST")[2].replace("\\","/").strip("/")

print "relPath: " + relPath
print "buildArgs: " + buildArgs

curDir = os.popen('cd remoteBuild/%s; make %s' % (relPath, buildArgs))
print curDir.read()

if __name__ == "__main__":
main()



  • Now I can use eclipse's build button. It creates the makefiles locally on the machine, rsync's them over, builds them, and then spits back any errors/warnings to me.

No comments:

Pyjamas