Automated Migration of Build Scripts using Dynamic Analysis and Search-Based Refactoring

  • Milos Gligoric ,
  • Wolfram Schulte ,
  • Danny van Velzen ,
  • Iman Narasamdya ,
  • Ben Livshits ,
  • Chandra Prasad

Published by ACM - Association for Computing Machinery

Publication

The efficiency of a build system is an important factor for developer productivity. As a result, developer teams have been increasingly adopting new build systems that allow higher build parallelization. However, migrating the existing legacy build scripts to new build systems is a tedious and error-prone process. Unfortunately, there is insufficient support for automated migration of build scripts, making the migration more problematic.

We propose the first dynamic approach for automated migration of build scripts to new build systems. Our approach works in two phases. First, from a set of execution traces, we synthesize build scripts that accurately capture the intent of the original build. The synthesized build scripts are typically long and hard to maintain. Second, we apply refactorings that raise the abstraction level of the synthesized scripts (e.g., introduce functions for similar fragments). As different refactoring sequences may lead to different build scripts, we use a search-based approach that explores various sequences to identify the best (e.g., shortest) build script. We optimize search-based refactoring with partial-order reduction to faster explore refactoring sequences. We implemented the proposed two-phase migration approach in a tool called Metamorphosis that has been recently used at Microsoft.