Make CACHE_DIR and BUILD_DIR available to the custom build script

so that it could be more efficient (e.g. cache stuff between builds).