Skip to content

Commit

Permalink
Another take at uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgodbolt committed Jun 24, 2024
1 parent ca54edf commit 00bbbc8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 62 deletions.
121 changes: 59 additions & 62 deletions msvc-install/gh-msvc-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions terraform/security.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}/*",
]
Expand Down

0 comments on commit 00bbbc8

Please sign in to comment.