def windows_msvc(context, force=False):
    'Bootstrapper for MSVC building on Windows.'
    deps_dir = os.path.join(context.sharedir, 'msvc-dependencies')
    deps_url = 'https://servo-deps-2.s3.amazonaws.com/msvc-deps/'

    def version(package):
        return packages.WINDOWS_MSVC[package]

    def package_dir(package):
        return os.path.join(deps_dir, package, version(package))

    def check_cmake(version):
        cmake_path = find_executable('cmake')
        if cmake_path:
            cmake = subprocess.Popen([cmake_path, '--version'], stdout=PIPE)
            cmake_version_output = six.ensure_str(cmake.stdout.read()).splitlines()[0]
            cmake_version = cmake_version_output.replace('cmake version ', '')
            if (LooseVersion(cmake_version) >= LooseVersion(version)):
                return True
        return False

    def prepare_file(zip_path, full_spec):
        if (not os.path.isfile(zip_path)):
            zip_url = '{}{}.zip'.format(deps_url, urllib.parse.quote(full_spec))
            download_file(full_spec, zip_url, zip_path)
        print('Extracting {}...'.format(full_spec), end='')
        try:
            extract(zip_path, deps_dir)
        except BadZipfile:
            print(('\nError: %s.zip is not a valid zip file, redownload...' % full_spec))
            os.remove(zip_path)
            prepare_file(zip_path, full_spec)
        else:
            print('done')
    to_install = {}
    for package in packages.WINDOWS_MSVC:
        if ((package == 'cmake') and check_cmake(version('cmake'))):
            continue
        if (not os.path.isdir(package_dir(package))):
            to_install[package] = version(package)
    if (not to_install):
        return 0
    print('Installing missing MSVC dependencies...')
    for package in to_install:
        full_spec = '{}-{}'.format(package, version(package))
        parent_dir = os.path.dirname(package_dir(package))
        if (not os.path.isdir(parent_dir)):
            os.makedirs(parent_dir)
        zip_path = (package_dir(package) + '.zip')
        prepare_file(zip_path, full_spec)
        extracted_path = os.path.join(deps_dir, full_spec)
        os.rename(extracted_path, package_dir(package))
    return 0
Bootstrapper for MSVC building on Windows.
def windows_msvc(context, force=False):
    
    deps_dir = os.path.join(context.sharedir, 'msvc-dependencies')
    deps_url = 'https://servo-deps-2.s3.amazonaws.com/msvc-deps/'

    def version(package):
        return packages.WINDOWS_MSVC[package]

    def package_dir(package):
        return os.path.join(deps_dir, package, version(package))

    def check_cmake(version):
        cmake_path = find_executable('cmake')
        if cmake_path:
            cmake = subprocess.Popen([cmake_path, '--version'], stdout=PIPE)
            cmake_version_output = six.ensure_str(cmake.stdout.read()).splitlines()[0]
            cmake_version = cmake_version_output.replace('cmake version ', )
            if (LooseVersion(cmake_version) >= LooseVersion(version)):
                return True
        return False

    def prepare_file(zip_path, full_spec):
        if (not os.path.isfile(zip_path)):
            zip_url = '{}{}.zip'.format(deps_url, urllib.parse.quote(full_spec))
            download_file(full_spec, zip_url, zip_path)
        print('Extracting {}...'.format(full_spec), end=)
        try:
            extract(zip_path, deps_dir)
        except BadZipfile:
            print(('\nError: %s.zip is not a valid zip file, redownload...' % full_spec))
            os.remove(zip_path)
            prepare_file(zip_path, full_spec)
        else:
            print('done')
    to_install = {}
    for package in packages.WINDOWS_MSVC:
        if ((package == 'cmake') and check_cmake(version('cmake'))):
            continue
        if (not os.path.isdir(package_dir(package))):
            to_install[package] = version(package)
    if (not to_install):
        return 0
    print('Installing missing MSVC dependencies...')
    for package in to_install:
        full_spec = '{}-{}'.format(package, version(package))
        parent_dir = os.path.dirname(package_dir(package))
        if (not os.path.isdir(parent_dir)):
            os.makedirs(parent_dir)
        zip_path = (package_dir(package) + '.zip')
        prepare_file(zip_path, full_spec)
        extracted_path = os.path.join(deps_dir, full_spec)
        os.rename(extracted_path, package_dir(package))
    return 0