Description
Description
BuildPlan.swift has grown to include a ton of specific tool flags, and often has to account for the variations between Darwin, Linux, Windows, WASI, etc. Little by little, this morass of minutiae is growing as new special cases get added and new platforms get supported.
This ticket tracks the work of factoring out all the details of BuildPlan.swift and into separate types that are responsible for constructing command lines based on higher-level semantic choices. That would leave BuildPlan to do the actual planning at a high level, and would make it easier to test the more details construction of command lines as well the semantic intent of the plan.
One way to do this could be to use protocols for the various kinds of tools — compilers, linkers, archivers, etc — with semantically meaningful properties that the BuildPlan would control, and then have concrete types implementing the details.
In a case such as #5720 we could then have different implementations of linkers or archivers for various target platforms.
Not only would it be easier to test the command line generation based on canned values for the semantic properties, but it would also be easier to test the BuildPlan logic by mocking the tools to check the semantic decisions it is making rather than the details of command line switches.