Chapter 5. Build copies and variants

Table of Contents

Using several build folders
Defining variants
Cloning task generators

Using several build folders

It is not possible to use several Waf instances concurrently over the same build folder. Yet, several Waf instances may use the project at the same time. For this, two options must be set:

  • The environment variable WAFCACHE
  • The build directory, using a command-line option

Here is an example for a simple project located in /tmp/smallfolder:

srcdir = '.'
blddir = 'out_directory'

def configure(conf):
	pass

def build(bld):
	bld(rule='touch ${TGT}', target='foo.txt')
			

Upon execution, the results will be the following:

$  export WAFLOCK=.lock-debug 1

$  waf distclean configure -b debug 2
'distclean' finished successfully (0.002s)
'configure' finished successfully (0.001s)

$  waf
Waf: Entering directory `/tmp/smallproject/debug'
[1/1] foo.txt:  -> debug/default/foo.txt 3
Waf: Leaving directory `/tmp/smallproject/debug'
'build' finished successfully (0.012s)

$  export WAFLOCK=.lock-release

$  waf distclean configure -b release
'distclean' finished successfully (0.001s)
'configure' finished successfully (0.176s)

$  waf
Waf: Entering directory `/tmp/smallproject/release' 4
[1/1] foo.txt:  -> release/default/foo.txt
Waf: Leaving directory `/tmp/smallproject/release'
'build' finished successfully (0.034s)

$  tree -a
.
|-- .lock-debug 5
|-- .lock-release
|-- debug
|   |-- .wafpickle-7
|   |-- c4che
|   |   |-- build.config.py
|   |   `-- default.cache.py
|   |-- config.log
|   `-- default
|       `-- foo.txt
|-- release
|   |-- .wafpickle-7
|   |-- c4che
|   |   |-- build.config.py
|   |   `-- default.cache.py
|   |-- config.log
|   `-- default
|       `-- foo.txt
`-- wscript
			

1

The environment variable WAFLOCK points at the configuration of the project in use.

2

The lockfile is created during the configuration.

3

The files are output in the build directorydebug

4

The configuration release is used with a different lock file and a different build directory.

5

The contents of the project directory contain the two lock files and the two build folders.