示例#1
0
def gather_msvc_2017_versions(conf, windows_kit, versions):

    # Prepare a hashing object to construct an md5 fingerprint of the collected vc_paths that was read from the
    # registry.  If the hash changes, we will force a read-read of the VCVARS.BAT environment variablkes
    hasher = hashlib.md5()
    hasher.update(LMBR_WAF_VERSION_TAG) # Include to force a re-cache if this changes

    vc_paths = []

    vswhere_exe = find_vswhere()
    if not vswhere_exe == '':
        version_string = ''
        path_string = ''
        try:
            vs_where_args = conf.options.win_vs2017_vswhere_args.lower().split()
            version_string = subprocess.check_output([vswhere_exe, '-property', 'installationVersion'] + vs_where_args)
            if not version_string:
                try:
                    version_arg_index = vs_where_args.index('-version')
                    Logs.warn('[WARN] VSWhere could not find an installed version of Visual Studio matching the version requirements provided (-version {}). Attempting to fall back on any available installed version.'.format(vs_where_args[version_arg_index + 1]))
                    Logs.warn('[WARN] Lumberyard defaults the version range to the maximum version tested against before each release. You can modify the version range in the WAF user_settings\' option win_vs2017_vswhere_args under [Windows Options].')
                    del vs_where_args[version_arg_index : version_arg_index + 2]
                    version_string = subprocess.check_output([vswhere_exe, '-property', 'installationVersion'] + vs_where_args)
                except ValueError:
                    pass

            version_parts = version_string.split('.')
            version_string = version_parts[0]
            path_string = subprocess.check_output([vswhere_exe, '-property', 'installationPath'] + vs_where_args)
            path_string = path_string[:len(path_string)-2]
            vc_paths.append((version_string, path_string))

            hasher.update('{}/{}'.format(version_string, path_string))
        except:
            pass

    paths_hash = hasher.hexdigest()

    # Gather all the version information independent of the input winkit
    all_versions = []
    for version, vc_path in vc_paths:
        Logs.info_once('[INFO] Using Visual Studio version {} installed at: {}'.format(version_string, path_string))
        conf.gather_msvc_2017_targets(paths_hash, all_versions, version, windows_kit, vc_path)

    # Populate the version list
    for check_version in all_versions:
        # The winkit is embedded in the first item of the tuple, split by the '/' character
        version_and_winkit = check_version[0].split('/')
        version_lst = check_version[1]
        if windows_kit == version_and_winkit[1]:
            # Rebuild the tuple with only the msvc version string and the version list information
            versions.append([version_and_winkit[0], version_lst])