unified common logic
bug fix. print build_dirname