def set_swift_branch(branch):
    """Configure the library for a specific branch.

    >>> set_swift_branch('master')
    """
    global swift_branch
    swift_branch = branch
    common.set_swift_branch(branch)
Esempio n. 2
0
def main():
    args = parse_args()
    common.set_swift_branch(args.swift_branch)
    common.debug_print('** REPRODUCE **')

    skip_swift_build = args.skip_swift_build
    if args.swiftc:
        skip_swift_build = True

    if not skip_swift_build:
        # Only prompt for deletion if directories exist
        have_existing_dirs = False
        if os.path.exists('./build') or os.path.exists('./swift') or \
           os.path.exists('./cmark'):
            have_existing_dirs = True

        # Optionally clean up previous source/build directories
        should_cleanup = False
        should_clone = False
        if have_existing_dirs and not args.skip_cleanup:
            if not args.no_prompt:
                response = raw_input(
                    'Delete all build and source directories '
                    'in current working directory? (y/n): ').strip().lower()
                if response == 'y':
                    should_cleanup = True
            else:
                should_cleanup = True
            if should_cleanup:
                common.check_execute(
                    ['./cleanup', args.swift_branch, '--skip-ci-steps'])
                should_clone = True
        else:
            should_clone = True

        # Build and install Swift and associated projects
        run_command = [
            './run', args.swift_branch, '--skip-ci-steps', '--skip-runner'
        ]
        if not should_clone:
            run_command += ['--skip-clone']
        if args.assertions:
            run_command += ['--assertions']
        common.check_execute(run_command, timeout=3600)

    # Build specified indexed project. Otherwise, build all indexed projects
    runner_command = [
        './runner.py',
        '--projects',
        'projects.json',
        '--swift-branch',
        args.swift_branch,
        '--swift-version',
        '3',
        '--include-actions',
        'action.startswith("Build")',
    ]
    if args.swiftc:
        runner_command += ['--swiftc', args.swiftc]
    else:
        runner_command += [
            '--swiftc', './build/compat_macos/install/toolchain/usr/bin/swiftc'
        ]
    if args.add_swift_flags:
        runner_command += ['--add-swift-flags=%s' % args.add_swift_flags]
    if args.project_path:
        runner_command += [
            '--include-repos',
            'path == "%s"' % args.project_path
        ]
    if args.sandbox_profile_xcodebuild:
        runner_command += [
            '--sandbox-profile-xcodebuild', args.sandbox_profile_xcodebuild
        ]
    if args.sandbox_profile_package:
        runner_command += [
            '--sandbox-profile-package', args.sandbox_profile_package
        ]
    common.check_execute(runner_command)

    return 0