Skip to content

Commit 6808365

Browse files
authored
Merge pull request #47 from WebKitForWindows/ig/add-install-swift
Add Install-Swift helper
2 parents b2b95e3 + 9821b5f commit 6808365

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2026, the WebKit for Windows project authors. Please see the
2+
# AUTHORS file for details. All rights reserved. Use of this source code is
3+
# governed by a BSD-style license that can be found in the LICENSE file.
4+
5+
<#
6+
.Synopsis
7+
Installs the Swift toolchain for Windows.
8+
9+
.Description
10+
Downloads the specified release of the Swift toolchain for Windows and
11+
installs it silently on the host. The installer places the toolchain under
12+
the user profile and updates the user PATH rather than the machine PATH, so
13+
the environment is refreshed from both targets before verifying. Compiling
14+
with Swift additionally requires the MSVC toolchain and Windows SDK.
15+
16+
.Parameter Version
17+
The version of the Swift toolchain to install.
18+
19+
.Example
20+
# Install 6.3.3
21+
Install-Swift -Version 6.3.3
22+
#>
23+
function Install-Swift {
24+
param(
25+
[Parameter(Mandatory)]
26+
[string]$version
27+
)
28+
29+
$url = ('https://download.swift.org/swift-{0}-release/windows10/swift-{0}-RELEASE/swift-{0}-RELEASE-windows10.exe' -f $version);
30+
31+
$options = @(
32+
'-q'
33+
);
34+
35+
# Install-FromExe only refreshes the machine PATH before verifying, but the
36+
# Swift installer updates the user PATH, so skip the built-in verification.
37+
Install-FromExe -Name 'swift' -url $url -Options $options -NoVerify;
38+
39+
# Refresh the PATH from both the machine and user targets so the newly
40+
# installed toolchain is resolvable, then verify.
41+
$env:PATH = @(
42+
[Environment]::GetEnvironmentVariable('PATH',[EnvironmentVariableTarget]::Machine),
43+
[Environment]::GetEnvironmentVariable('PATH',[EnvironmentVariableTarget]::User)
44+
) -join ';';
45+
46+
Write-Information -MessageData 'Verifying swift install ...' -InformationAction Continue;
47+
swift --version;
48+
}

WebKitDev/WebKitDev.psd1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# RootModule = ''
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.6.4'
15+
ModuleVersion = '0.7.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -113,6 +113,7 @@
113113
'Functions/Install-Python.ps1',
114114
'Functions/Install-Ruby.ps1',
115115
'Functions/Install-SVN.ps1',
116+
'Functions/Install-Swift.ps1',
116117
'Functions/Install-VSBuildTools2015.ps1',
117118
'Functions/Install-VSBuildTools2017.ps1',
118119
'Functions/Install-VSBuildTools2019.ps1',
@@ -174,6 +175,7 @@
174175
'Install-Python',
175176
'Install-Ruby',
176177
'Install-SVN',
178+
'Install-Swift',
177179
'Install-VSBuildTools2015',
178180
'Install-VSBuildTools2017',
179181
'Install-VSBuildTools2019',

0 commit comments

Comments
 (0)