build: Fix infinite loop bug

The application would fall into an infinite loop if no commands would
have to be ran. In order to prevent this from happening, I added a count
of the total number of commands issued.

The counter, while not necessarily having to be atomic (only one thread
actually writes to it) was indeed implemented as atomic. This is because
if the parsing ever were to be done by multiple threads, this wouldn't
break the build in some opaque way.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>