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):


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@
C:\cygwin\bin\ssh.exe guser@ python """%CURDIR% --- %*"""

  • On the remote machine, I created a 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))

if __name__ == "__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: