PDB-234 Reduce duplicate code for compile-* functions

Signed-off-by: Ken Barber <ken@bob.sh>