Refactor build script with introducing build_common.py