@@ -0,0 +1,2405 @@
+#!/usr/bin/env python%0Afrom __future__ import print_function%0A%0Aimport argparse%0Aimport os%0Aimport subprocess%0Aimport sys%0Aimport tempfile%0Aimport errno%0Aimport platform%0Aimport shutil%0A%0ABUILD_SCRIPT = os.path.dirname(os.path.abspath(__file__)) + '/build-script.py'%0A%0Adef printerr(message):%0A    print(message, file=sys.stderr)%0A%0Adef note(message):%0A    print(%22--- %25s: note: %25s%22 %25 (os.path.basename(sys.argv%5B0%5D), message))%0A    sys.stdout.flush()%0A%0Adef fatal_error(message):%0A    printerr(message)%0A    sys.exit(1)%0A%0Adef escapeCmdArg(arg):%0A    if '%22' in arg or ' ' in arg:%0A        return '%22%25s%22' %25 arg.replace('%22', '%5C%5C%22')%0A    else:%0A        return arg%0A%0Adef check_call(cmd, env=os.environ):%0A    print(' '.join(%5BescapeCmdArg(arg) for arg in cmd%5D))%0A    return subprocess.check_call(cmd, env=env, stderr=subprocess.STDOUT)%0A%0Adef build(swiftc_exec, build_dir):%0A    check_call(%5BBUILD_SCRIPT, '--release', '--swiftc-exec', swiftc_exec,%0A        '--build-dir', build_dir, '-v'%5D)%0A%0Adef install(swiftc_exec, build_dir, dylib_dir, module_dir):%0A    check_call(%5BBUILD_SCRIPT, '--release', '--install', '--swiftc-exec',%0A        swiftc_exec, '--dylib-dir', dylib_dir, '--swiftmodule-dir', module_dir,%0A        '--build-dir', build_dir, '-v'%5D)%0A%0Adef main():%0A    if not os.geteuid() == 0:%0A        fatal_error(%22%5Cn!!!!!!!!Run this script with root access!!!!!!!!%5Cn%22)%0A    parser = argparse.ArgumentParser(%0A        formatter_class=argparse.RawDescriptionHelpFormatter,%0A        description='''%0ABuild and re-install SwiftSytnax for an existing toolchain.%0A%0AThis script calls ./build-script internally to rebuild SwiftSyntax using an%0Aexisting toolchain and install the build artifacts back to the toolchain.%0A''')%0A%0A    basic_group = parser.add_argument_group('Basic')%0A%0A    basic_group.add_argument('--toolchain-dir', default=None, help='''%0A        Directory of an existing toolchain.%0A        ''')%0A%0A    args = parser.parse_args(sys.argv%5B1:%5D)%0A    build_dir = tempfile.mkdtemp()%0A    swiftc_exec = args.toolchain_dir + '/usr/bin/swiftc'%0A    dylib_dir = args.toolchain_dir + '/usr/lib/swift/macosx'%0A    module_dir = args.toolchain_dir + '/usr/lib/swift/macosx/x86_64'%0A    print('Using swiftc: ' + swiftc_exec)%0A    print('Using build directory: ' + build_dir)%0A    build(swiftc_exec=swiftc_exec, build_dir=build_dir)%0A    install(swiftc_exec=swiftc_exec, build_dir=build_dir, dylib_dir=dylib_dir,%0A        module_dir=module_dir)%0A%0Aif __name__ == '__main__':%0A    main()

add a script to rebuild SwiftSyntax and install it to an existing toolchain.