2

I am trying to set up a C++ project in Eclipse (on Windows) that uses Waf to build. My Eclipse workspace and my source files are in different directories.

  • C:\myproject: Project root
  • C:\myproject\wscript: Waf build script
  • C:\myproject\source: Source code
  • C:\myproject\project\eclipse: Eclipse Workspace
  • C:\myproject\project\eclipse\myproject: Eclipse Project

Waf must be executed from the directory that contains wscript.

In my project properties, under C/C++ Build, my Build command should be python waf. I created a temporary script at C:\myproject\temp.cmd just containing pwd, and set the Build command to ..\..\..\temp.cmd in order to confirm what the working directory is. The build console shows C:\myproject\project\eclipse\myproject when I run the build.

How can I change this so that it will show C:\myproject?

sourcenouveau
  • 29,356
  • 35
  • 146
  • 243

2 Answers2

2

I wrote a wrapper script that sets the proper working directory.

C:\myproject\project\eclipse\waf.cmd
@ECHO OFF
CD ..\..\..
python waf %*

In Eclipse I set Build command to ${WorkspaceDirPath}/waf.cmd.

Community
  • 1
  • 1
sourcenouveau
  • 29,356
  • 35
  • 146
  • 243
  • It would be interesting to know whether you need to restore the working directory at the end of the script. I wouldn't think so since Eclipse is likely creating a new process just for the build that then expires at the end of the script. – Kelly S. French May 03 '13 at 13:52
-1

In C/C++ Build you can set Build directory. Enter C:\myproject there. The build command must be in your PATH for it to work.

ellak
  • 2,531
  • 20
  • 26
  • This does not work. I believe this field is for build output. I set `Build directory` to `C:\myproject` and set `Build command` to `temp.cmd`, but then Eclipse claims it can't find `temp.cmd`. – sourcenouveau May 03 '13 at 13:18
  • 1
    If you make sure that temp.cmd is in your PATH it will work (or just use the full path in your build command). At least it did for me. – ellak May 03 '13 at 13:32