Extract setup_project as a single function

Extract the setup_project logic into a single function for clarity
and reusability.

Change-Id: I7ac3dd3f25b05487bbafc6a18242aa6c61f227c8
Merge "Extract setup_project as a single function"