Automated Migration of Build Scripts using Dynamic Analysis and Search-Based Refactoring
The efficiency of a build system is an important enabler of the productivity of software developers. As a result, developer teams have been adopting build systems that allow them to maximize build parallelization. However, migrating the existing legacy build scripts to new build systems is tedious and error-prone. Yet, there has been no prior work that automate migration of build scripts.
This paper proposes the first approach for migrating legacy build scripts to new build systems. Our approach works in two phases. In the first phase, from a set of build execution traces, we synthesize build scripts that accurately capture the intent of the original build. However, the synthesized build scripts are typically long and hard to maintain. In the second phase, we apply refactorings that raise the level of abstraction of the synthesized scripts (e.g., extracting common code). As the application order of refactorings may lead to different build scripts, we use a search-based approach that explores various refactoring sequences to identify the best (e.g., shortest) build script. We optimize search-based refactoring with state matching and partial-order reduction to explore more sequences in the same amount of time. We implemented the proposed two-phase migration approach in a tool, called Metamorphosis, which has recently been used within Microsoft.