<commit_before>param (
    [ValidateSet("x86", "x64", "ARM", "ARM64")]
    [String]$Arch = "x64",
    [String]$InstanceId,
    [Switch]$Sdklow = $false
)

Function Invoke-Vcvarsall {
    param(
        [Parameter(Mandatory = $true)]
        [string] $Path,
        [string] $ArgumentList
    )
    Set-StrictMode -Version Latest
    $tempFile = [IO.Path]::GetTempFileName()
    cmd /c " `"$Path`" $argumentList && set > `"$tempFile`" "
    ## Go through the environment variables in the temp file.
    ## For each of them, set the variable in our local environment.
    Get-Content $tempFile | Foreach-Object {
        if ($_ -match "^(.*?)=(.*)$") {
            Set-Content "env:\$($matches[1])" $matches[2]
        }
    }
    Remove-Item $tempFile
}

$IsWindows64 = [System.Environment]::Is64BitOperatingSystem


if ($InstanceId.Contains("11.0") -or $InstanceId.Contains("10.0")) {
    $ArchListX86 = @{
        "x86"   = "x86";
        "x64"   = "x86_amd64";
        "ARM"   = "x86_arm";
        "ARM64" = "unknwon"
    }

    $ArchListX64 = @{
        "x86"   = "x86";
        "x64"   = "amd64";
        "ARM"   = "x86_arm";
        "ARM64" = "unknwon"
    }
}
else {
    $ArchListX86 = @{
        "x86"   = "x86";
        "x64"   = "x86_amd64";
        "ARM"   = "x86_arm";
        "ARM64" = "x86_arm64"
    }

    $ArchListX64 = @{
        "x86"   = "amd64_x86";
        "x64"   = "amd64";
        "ARM"   = "amd64_arm";
        "ARM64" = "amd64_arm64"
    }
}


if ($IsWindows64) {
    $ArgumentList = $ArchListX64[$Arch]
}
else {
    $ArgumentList = $ArchListX86[$Arch]
}


## Always JSON Array

$vsinstances = vswhere -prerelease -legacy -format json|ConvertFrom-JSON
$vsinstance = $vsinstances|Where-Object {$_.instanceId -eq $InstanceId}

Write-Host "Use Visual Studio $($vsinstance.installationVersion)"

if ($vsinstance.instanceId.StartsWith("VisualStudio")) {
    $vcvarsall = "$($vsinstance.installationPath)\VC\vcvarsall.bat"
    if ($InstallId -eq "VisualStudio.14.0" -and $Sdklow) {
        Write-Host "Attention Please: Use Windows 8.1 SDK"
        $ArgumentList += " 8.1"
    }
    if (!(Test-Path $vcvarsall)) {
        Write-Host "$vcvarsall not found"
        return 1;
    }
    Invoke-Vcvarsall -Path $vcvarsall -ArgumentList $ArgumentList
    return 
}



$FixedVer = [System.Version]::Parse("15.3.26730.8")
$ver = [System.Version]::Parse($vsinstance.installationVersion)
$vercmp = $ver.CompareTo($FixedVer)
if ($Arch -eq "ARM64" -and $vercmp -le 0) {
    Write-Host "Use Enterprise WDK support ARM64"
    Invoke-Expression "$PSScriptRoot\EnterpriseWDK.ps1"
    return ;
}
$vcvarsall = "$($vsinstance.installationPath)\VC\Auxiliary\Build\vcvarsall.bat"
if ($Sdklow) {
    Write-Host "Attention Please: Use Windows 8.1 SDK"
    $ArgumentList += " 8.1"
}

if (!(Test-Path $vcvarsall)) {
    Write-Host "$vcvarsall not found"
    return 1;
}

<commit_msg>Now 15.4.26823.1 support ARM64,(Old use EWDK)<commit_after>param (
    [ValidateSet("x86", "x64", "ARM", "ARM64")]
    [String]$Arch = "x64",
    [String]$InstanceId,
    [Switch]$Sdklow = $false
)

Function Invoke-Vcvarsall {
    param(
        [Parameter(Mandatory = $true)]
        [string] $Path,
        [string] $ArgumentList
    )
    Set-StrictMode -Version Latest
    $tempFile = [IO.Path]::GetTempFileName()
    cmd /c " `"$Path`" $argumentList && set > `"$tempFile`" "
    ## Go through the environment variables in the temp file.
    ## For each of them, set the variable in our local environment.
    Get-Content $tempFile | Foreach-Object {
        if ($_ -match "^(.*?)=(.*)$") {
            Set-Content "env:\$($matches[1])" $matches[2]
        }
    }
    Remove-Item $tempFile
}

$IsWindows64 = [System.Environment]::Is64BitOperatingSystem


if ($InstanceId.Contains("11.0") -or $InstanceId.Contains("10.0")) {
    $ArchListX86 = @{
        "x86"   = "x86";
        "x64"   = "x86_amd64";
        "ARM"   = "x86_arm";
        "ARM64" = "unknwon"
    }

    $ArchListX64 = @{
        "x86"   = "x86";
        "x64"   = "amd64";
        "ARM"   = "x86_arm";
        "ARM64" = "unknwon"
    }
}
else {
    $ArchListX86 = @{
        "x86"   = "x86";
        "x64"   = "x86_amd64";
        "ARM"   = "x86_arm";
        "ARM64" = "x86_arm64"
    }

    $ArchListX64 = @{
        "x86"   = "amd64_x86";
        "x64"   = "amd64";
        "ARM"   = "amd64_arm";
        "ARM64" = "amd64_arm64"
    }
}


if ($IsWindows64) {
    $ArgumentList = $ArchListX64[$Arch]
}
else {
    $ArgumentList = $ArchListX86[$Arch]
}


## Always JSON Array

$vsinstances = vswhere -prerelease -legacy -format json|ConvertFrom-JSON
$vsinstance = $vsinstances|Where-Object {$_.instanceId -eq $InstanceId}

Write-Host "Use Visual Studio $($vsinstance.installationVersion)"

if ($vsinstance.instanceId.StartsWith("VisualStudio")) {
    $vcvarsall = "$($vsinstance.installationPath)\VC\vcvarsall.bat"
    if ($InstallId -eq "VisualStudio.14.0" -and $Sdklow) {
        Write-Host "Attention Please: Use Windows 8.1 SDK"
        $ArgumentList += " 8.1"
    }
    if (!(Test-Path $vcvarsall)) {
        Write-Host "$vcvarsall not found"
        return 1;
    }
    Invoke-Vcvarsall -Path $vcvarsall -ArgumentList $ArgumentList
    return 
}


## Now 15.4.26823.1 support Visual C++ for ARM64
$FixedVer = [System.Version]::Parse("15.4.26823.0")
$ver = [System.Version]::Parse($vsinstance.installationVersion)
$vercmp = $ver.CompareTo($FixedVer)
if ($Arch -eq "ARM64" -and $vercmp -le 0) {
    Write-Host "Use Enterprise WDK support ARM64"
    Invoke-Expression "$PSScriptRoot\EnterpriseWDK.ps1"
    return ;
}
$vcvarsall = "$($vsinstance.installationPath)\VC\Auxiliary\Build\vcvarsall.bat"
if ($Sdklow) {
    Write-Host "Attention Please: Use Windows 8.1 SDK"
    $ArgumentList += " 8.1"
}

if (!(Test-Path $vcvarsall)) {
    Write-Host "$vcvarsall not found"
    return 1;
}


{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.046248715313463515, 'mean_word_length': 2.7262284620293555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2948439', 'n_tokens_mistral': 2316, 'n_tokens_neox': 2158, 'n_words': 428}