WAF as an alternative to make in Eclipse

Want to try out WAF as the default build system in Eclipse, with a simple way to revert back to 'make' if you change your mind? Here is one way to do it.

Preparations

1. Install WAF from https://waf.io. Rename the WAF Python executable to 'waf' and save it at the root of the source code tree you want to build. In this example that's /home/ubuntu/git/bade/arm 

2. Add the path to waf (i.e. /home/ubuntu/git/bade/arm) permanently to your OS' system path.

3. Save your wscript file in the same directory as the WAF executable (i.e. /home/ubuntu/git/bade/arm in this example), and make sure you can successfully build your project from the command line like this:

     cd /home/ubuntu/git/bade/arm
     waf configure
     waf build


Configuring Eclipse

4. Create a new Eclipse Environment variable 'GIT_ROOT', to simplify things. We'll name it GIT_ROOT and make it point to the root of our 'bade' git repo.


Notice that we have created the variable for [All configurations].

5. Create a new Build Configuration by clicking Manage Configurations... and Add. Let's name it WAF_Debug,




and make it the active Build Configuration.

6. In the Builder Settings tab, provide the name of the WAF executable in Build command, and the path to your wscript file (and waf executable) in Build directory.





7. In the Behavior tab, provide the WAF commands for cleaning and building a project, i.e. clean and build.



8. Finally, create a new Build Target in the project, to deal with WAF's requirement to run configure after every change to WAF's wscript.



Done!

Because WAF_Debug is your active Build Configuration, Eclipse will now use WAF to build your project. Remember to build the configure Build Target if you update the wscript file.
 
To revert back to make as Eclipse's default build system, simply set the Debug (or Release) Build Configuration as the active one.

(Tested on Elipse Oxygen CDT and WAF 2.0.14)

No comments:

Post a Comment