Lock the build graph while jobs are running.

All jobs except setting up the project are mutually exclusive, and it is
also forbidden to change the project internally while they are going on.
Currently, ignoring this requirement leads to undefined behavior. Since
we can detect such a condition and react in a defined way, we should do
it.
Note: This is about the API and the in-memory build graph, not about
competing accesses to the stored build graph from different processes.
That's a different (and more difficult) problem.

Change-Id: I2d8a715334b2b73b4f4d32781d0b4f83b1612d40
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>