diff --git a/windows/README.md b/windows/README.md deleted file mode 100644 index d9e8047..0000000 --- a/windows/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Meson installer for windows and Powershell scripts - -The version of meson is 1.10.0 - -Don't blindly update. diff --git a/windows/add_to_path.ps1 b/windows/add_to_path.ps1 deleted file mode 100644 index 4abbacb..0000000 --- a/windows/add_to_path.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -param( - [Parameter()] - [String]$absolute_path -) -$absolute_path - -# Check if it already is on path -$oldpath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User) -$listy = $oldpath -split ";" -$is_on_path_already = $listy.Contains($absolute_path) - -# Add to path -if (! $is_on_path_already) { - [Environment]::SetEnvironmentVariable( - "Path", - [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User) + ";"+ $absolute_path+ ";", - [EnvironmentVariableTarget]::User) - Write-Host "Added" $absolute_path "to PATH" -} else { - Write-Host $absolute_path "is already on PATH" -} \ No newline at end of file diff --git a/windows/meson.msi b/windows/meson.msi deleted file mode 100644 index f7eea2e..0000000 Binary files a/windows/meson.msi and /dev/null differ diff --git a/windows/set_env_vars.ps1 b/windows/set_env_vars.ps1 deleted file mode 100644 index 63d34b8..0000000 --- a/windows/set_env_vars.ps1 +++ /dev/null @@ -1,10 +0,0 @@ -[Environment]::SetEnvironmentVariable( - "CC", - "C:\TDT4102-mingw64\bin\gcc", - [EnvironmentVariableTarget]::User) - - -[Environment]::SetEnvironmentVariable( - "CXX", - "C:\TDT4102-mingw64\bin\g++", - [EnvironmentVariableTarget]::User) diff --git a/windows/windows_installer.ps1 b/windows/windows_installer.ps1 new file mode 100644 index 0000000..22f1b96 --- /dev/null +++ b/windows/windows_installer.ps1 @@ -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" diff --git a/windows/windows_installer_scoop.ps1 b/windows/windows_installer_scoop.ps1 new file mode 100644 index 0000000..9568990 --- /dev/null +++ b/windows/windows_installer_scoop.ps1 @@ -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"