diff --git a/msvc-install/gh-msvc-install.ps1 b/msvc-install/gh-msvc-install.ps1 index 18a2b665..e04fe4f1 100644 --- a/msvc-install/gh-msvc-install.ps1 +++ b/msvc-install/gh-msvc-install.ps1 @@ -3,65 +3,62 @@ param ( ) $ErrorActionPreference = "Stop" -Get-S3Object -BucketName compiler-explorer -Prefix "opt-nonfree/msvc" -# -# -## This script is very destructive and is designed to only be run on a GH action runner. -#$download_path = "$Env:TEMP\download" -#$full_install_root = "$Env:TEMP\full" -#$archives = "$Env:TEMP\archives" -# -#function Download -#{ -# Param ( -# [string] $url -# ) -# -# $filepath = "$download_path/installer.exe" -# -# if (!(Test-Path -Path $filepath)) -# { -# New-Item -ItemType Directory $download_path -# Invoke-WebRequest -Uri $url -OutFile $filepath -# } -#} -# -#function Install -#{ -# $installer = "$download_path/installer.exe" -# -# New-Item -ItemType Directory -Force "$full_install_root" -# Write-Host "Installating in : $full_install_root" -# Start-Process -Wait -FilePath "$installer" -ArgumentList @("--quiet", "--installPath", "$full_install_root", "--add", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", "--add", "Microsoft.VisualStudio.Component.VC.Tools.ARM64", "--add", "Microsoft.VisualStudio.Component.VC.Tools.ARM") -#} -# -#function ZipAndUpload -#{ -# Param ( -# [string] $compilerVersion, -# [string] $productVersion -# ) -# -# New-Item -ItemType Directory -Force "$archives" -# Rename-Item -Path "$full_install_root/VC/Tools/MSVC/$compilerVersion" -NewName "$compilerVersion-$productVersion" -# & "7z.exe" a "$archives/$compilerVersion-$productVersion.zip" "$full_install_root/VC/Tools/MSVC/$compilerVersion-$productVersion" -# Write-Host "Uploading..." -# Write-S3Object -BucketName compiler-explorer -Key "opt-nonfree/msvc/$compilerVersion-$productVersion.zip" -File "$archives/$compilerVersion-$productVersion.zip" -# Write-Host "Uploaded!" -#} -# -#New-Item -ItemType Directory -Force "$full_install_root" -# -#Download -url $url -#Install -# -#$dir = "$full_install_root/VC/Tools/MSVC" -#Get-ChildItem $dir | Foreach-Object { -# $compilerVersion = $_.Name -# Write-Host "Compiler directory version: $compilerVersion" -# -# $compilerExeProductVersion = (Get-Item "$dir/$compilerVersion/bin/Hostx64/x64/cl.exe").VersionInfo.ProductVersionRaw -# Write-Host "Compiler exe version: $compilerExeProductVersion" -# -# ZipAndUpload -compilerVersion $compilerVersion -productVersion $compilerExeProductVersion -#} +# This script is very destructive and is designed to only be run on a GH action runner. +$download_path = "$Env:TEMP\download" +$full_install_root = "$Env:TEMP\full" +$archives = "$Env:TEMP\archives" + +function Download +{ + Param ( + [string] $url + ) + + $filepath = "$download_path/installer.exe" + + if (!(Test-Path -Path $filepath)) + { + New-Item -ItemType Directory $download_path + Invoke-WebRequest -Uri $url -OutFile $filepath + } +} + +function Install +{ + $installer = "$download_path/installer.exe" + + New-Item -ItemType Directory -Force "$full_install_root" + Write-Host "Installating in : $full_install_root" + Start-Process -Wait -FilePath "$installer" -ArgumentList @("--quiet", "--installPath", "$full_install_root", "--add", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", "--add", "Microsoft.VisualStudio.Component.VC.Tools.ARM64", "--add", "Microsoft.VisualStudio.Component.VC.Tools.ARM") +} + +function ZipAndUpload +{ + Param ( + [string] $compilerVersion, + [string] $productVersion + ) + + New-Item -ItemType Directory -Force "$archives" + Rename-Item -Path "$full_install_root/VC/Tools/MSVC/$compilerVersion" -NewName "$compilerVersion-$productVersion" + & "7z.exe" a "$archives/$compilerVersion-$productVersion.zip" "$full_install_root/VC/Tools/MSVC/$compilerVersion-$productVersion" + Write-Host "Uploading..." + Write-S3Object -BucketName compiler-explorer -Key "opt-nonfree/msvc/$compilerVersion-$productVersion.zip" -File "$archives/$compilerVersion-$productVersion.zip" + Write-Host "Uploaded!" +} + +New-Item -ItemType Directory -Force "$full_install_root" + +Download -url $url +Install + +$dir = "$full_install_root/VC/Tools/MSVC" +Get-ChildItem $dir | Foreach-Object { + $compilerVersion = $_.Name + Write-Host "Compiler directory version: $compilerVersion" + + $compilerExeProductVersion = (Get-Item "$dir/$compilerVersion/bin/Hostx64/x64/cl.exe").VersionInfo.ProductVersionRaw + Write-Host "Compiler exe version: $compilerExeProductVersion" + + ZipAndUpload -compilerVersion $compilerVersion -productVersion $compilerExeProductVersion +} diff --git a/terraform/security.tf b/terraform/security.tf index a0452cce..beed1431 100644 --- a/terraform/security.tf +++ b/terraform/security.tf @@ -436,6 +436,7 @@ data "aws_iam_policy_document" "CeBuilderStorageAccess" { actions = ["s3:*"] resources = [ "${aws_s3_bucket.compiler-explorer.arn}/opt/*", + "${aws_s3_bucket.compiler-explorer.arn}/opt-nonfree/*", "${aws_s3_bucket.compiler-explorer.arn}/dist/*", "${aws_s3_bucket.ce-cdn-net.arn}/*", ]