Skip to content

Add powershell install script #19

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions windows/README.md

This file was deleted.

21 changes: 0 additions & 21 deletions windows/add_to_path.ps1

This file was deleted.

Binary file removed windows/meson.msi
Binary file not shown.
10 changes: 0 additions & 10 deletions windows/set_env_vars.ps1

This file was deleted.

73 changes: 73 additions & 0 deletions windows/windows_installer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Powershell install script for tools required on Windows used in the C++ course TDT4102 given at NTNU

param(
[Parameter()]
[string]$MinGWUrl = "https://studntnu.sharepoint.com/:u:/s/TDT4102/IQDj8vdM8om1RqALb3itQwyiAcTXcg7lYaIoW_CTs_p3KxA?e=T7JmRl&download=1",
[string]$MesonUrl = "https://github.com/mesonbuild/meson/releases/download/1.10.0/meson-1.10.0-64.msi",
[string]$MesonMsiPath = "meson-1.10.0-64.msi",
[switch]$SkipMinGW,
[switch]$SkipMeson,
[switch]$SkipEnv
)

$MinGWZipPath = ".\MinGW.zip"

Write-Host "PLEASE KEEP THIS WINDOW OPEN UNTIL PROMPTED"

if (! $SkipMinGW ) {

Write-Host "Downloading MinGW, this may take some time"
Invoke-WebRequest -Uri $MinGWUrl -OutFile $MinGWZipPath
Write-Host "Extracting MinGW to C:\"
# Force will overwrite the previous
Expand-Archive -Path $MinGWZipPath -DestinationPath "C:\" -Force
if (Test-Path -LiteralPath $MinGWZipPath) {
Remove-Item $MinGWZipPath
}
}

if (! $SkipEnv) {
Write-Host "Setting environment variables and adding to PATH"
[Environment]::SetEnvironmentVariable("CC", "C:\TDT4102-mingw64\bin\gcc", [EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable("CXX", "C:\TDT4102-mingw64\bin\g++", [EnvironmentVariableTarget]::User)
Write-Host "Environment variables CC and CXX set"

$binFolder = "C:\TDT4102-mingw64\bin"
$userPath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User)
$listy = $userPath -split ";"
$is_on_path_already = $listy.Contains($binFolder)
if (! $is_on_path_already) {
[Environment]::SetEnvironmentVariable(
"Path",
[Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User) + ";"+ $binFolder+ ";",
[EnvironmentVariableTarget]::User)
Write-Host "Added " $binFolder " to PATH"
} else {
Write-Host $binFolder " is already on PATH"
}
}

if (! $SkipMeson) {
Write-Host "Installing Meson"
if ((Test-Path -LiteralPath "C:\Program Files\Meson")) {
Write-Host "Looks like Meson is already installed, skipping..."
} else {
if (-not (Test-Path -Path $MesonMsiPath)) {
Write-Host "Downloading Meson"
Invoke-WebRequest -Uri $MesonUrl -OutFile $MesonMsiPath
} else {
$msiArgs = @("/i", "`"$MesonMsiPath`"", "/norestart")
$p = Start-Process -FilePath "msiexec.exe" -ArgumentList $msiArgs -Wait -PassThru
if ($p.ExitCode -ne 0) {
throw "Failed to install Meson! This exit code might help explaining what went wrong. Exit code: $($p.ExitCode)"
}
Write-Host "Meson installed successfully."
if (Test-Path -LiteralPath $MesonMsiPath) {
Remove-Item $MesonMsiPath
}
}
}
}

Write-Host "`nInstallation completed! Please restart VS Code before continuing"
Read-Host -Prompt "`nPress enter to exit"
57 changes: 57 additions & 0 deletions windows/windows_installer_scoop.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Powershell install script using scoop for tools required on Windows used in the C++ course TDT4102 given at NTNU

Write-Host "PLEASE KEEP THIS WINDOW OPEN UNTIL PROMPTED"

if (-not (Get-Command scoop -ErrorAction SilentlyContinue)) {
Write-Host "Installing Scoop..."

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

Write-Host "Scoop installed successfully!"
} else {
Write-Host "Scoop already installed."
}

Write-Host "`nUpdating scoop..."
scoop update

# Git is needed to get buckets and packages
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Host "Installing Git..."
scoop install git
}

Write-Host "`nAdding buckets..."

$buckets = @("main", "extras", "versions")

foreach ($bucket in $buckets) {
if (-not (scoop bucket list | Select-String -SimpleMatch $bucket)) {
scoop bucket add $bucket
} else {
Write-Host "$bucket already added"
}
}

Write-Host "`nInstalling required packages..."

$packages = @(
"mingw-winlibs-ucrt",
"meson",
"sdl2",
"sdl2_image",
"sdl2_mixer"
)

foreach ($pkg in $packages) {
if (scoop list | Select-String -SimpleMatch $pkg) {
Write-Host "$pkg already installed!"
} else {
Write-Host "Installing $pkg..."
scoop install $pkg
}
}

Write-Host "`nInstallation completed! Please restart VS Code before continuing"
Read-Host -Prompt "`nPress enter to exit"