buildsys: move file regeneration logic to the script itself