Optimize build and generate code in the compilation phase