This function was overly complicated, and it turns out unnecessary, so I removed it and changed the functions' APIs to just accept a build_dir as a parameter.

This function was also why we were experiencing the bug that this PR addresses, because it didn't ensure the build_dir was empty.