Skip to content
Merged
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
48 changes: 48 additions & 0 deletions WebKitDev/Functions/Install-Swift.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (c) 2026, the WebKit for Windows project authors. Please see the
# AUTHORS file for details. All rights reserved. Use of this source code is
# governed by a BSD-style license that can be found in the LICENSE file.

<#
.Synopsis
Installs the Swift toolchain for Windows.

.Description
Downloads the specified release of the Swift toolchain for Windows and
installs it silently on the host. The installer places the toolchain under
the user profile and updates the user PATH rather than the machine PATH, so
the environment is refreshed from both targets before verifying. Compiling
with Swift additionally requires the MSVC toolchain and Windows SDK.

.Parameter Version
The version of the Swift toolchain to install.

.Example
# Install 6.3.3
Install-Swift -Version 6.3.3
#>
function Install-Swift {
param(
[Parameter(Mandatory)]
[string]$version
)

$url = ('https://download.swift.org/swift-{0}-release/windows10/swift-{0}-RELEASE/swift-{0}-RELEASE-windows10.exe' -f $version);

$options = @(
'-q'
);

# Install-FromExe only refreshes the machine PATH before verifying, but the
# Swift installer updates the user PATH, so skip the built-in verification.
Install-FromExe -Name 'swift' -url $url -Options $options -NoVerify;

# Refresh the PATH from both the machine and user targets so the newly
# installed toolchain is resolvable, then verify.
$env:PATH = @(
[Environment]::GetEnvironmentVariable('PATH',[EnvironmentVariableTarget]::Machine),
[Environment]::GetEnvironmentVariable('PATH',[EnvironmentVariableTarget]::User)
) -join ';';

Write-Information -MessageData 'Verifying swift install ...' -InformationAction Continue;
swift --version;
}
4 changes: 3 additions & 1 deletion WebKitDev/WebKitDev.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# RootModule = ''

# Version number of this module.
ModuleVersion = '0.6.4'
ModuleVersion = '0.7.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -113,6 +113,7 @@
'Functions/Install-Python.ps1',
'Functions/Install-Ruby.ps1',
'Functions/Install-SVN.ps1',
'Functions/Install-Swift.ps1',
'Functions/Install-VSBuildTools2015.ps1',
'Functions/Install-VSBuildTools2017.ps1',
'Functions/Install-VSBuildTools2019.ps1',
Expand Down Expand Up @@ -174,6 +175,7 @@
'Install-Python',
'Install-Ruby',
'Install-SVN',
'Install-Swift',
'Install-VSBuildTools2015',
'Install-VSBuildTools2017',
'Install-VSBuildTools2019',
Expand Down