One (two?) lines!

```python
cwd = kw.get('cwd', getattr(bld, 'cwd', bld.variant_dir))
bld.cwd = kw['cwd'] = cwd
```