Just in case you haven't seen it already, Gwynne did a lot of work in https://github.com/apple/swift/pull/23256 and I did some pieces (some repeated) in Python-only build script by drodriguez · Pull Request #23038 · apple/swift · GitHub (sadly mixed with other changes).