build-and-test: Make it possible to customize stage 1

Add support for custom subprojects, custom CMake definitions and custom
build flags/targets for the first stage of the build. The subprojects
are preserved for stage 2, but the other flags aren't. They will be
configured separately.

We're still hardcoding the CMake generator, but we can fix that later.

This also extracts a couple of helpers for processing the command line
arguments, which we can use both for this subcommand and for the others.

Change-Id: Id6f8773b075815eb394eddff48adc9a7123f0da9
2 files changed