Run pre/post compile hooks with sub-env so vars are set.