Better build process

@shaohua Review?
does this need to be checked in?