Skip to content

Commit 91a5b94

Browse files
authored
Fix failing windows builds (#1432)
1 parent 4d2fb35 commit 91a5b94

22 files changed

+306
-123
lines changed

.github/workflows/nightly.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ jobs:
4747
# Windows
4848
windows_env_vars: |
4949
CI=1
50-
VSCODE_TEST=1
5150
windows_pre_build_command: .github\workflows\scripts\windows\install-nodejs.ps1
5251
windows_build_command: scripts\test_windows.ps1
5352
enable_windows_docker: false
@@ -63,15 +62,13 @@ jobs:
6362
NODE_PATH=/usr/local/nvm/versions/node/v20.18.2/bin
6463
NVM_DIR=/usr/local/nvm
6564
CI=1
66-
VSCODE_TEST=1
6765
VSCODE_VERSION=insiders
6866
linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh
6967
linux_build_command: ./scripts/test.sh
7068
# Windows
7169
windows_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "nightly-6.1"}, {"swift_version": "nightly"}]'
7270
windows_env_vars: |
7371
CI=1
74-
VSCODE_TEST=1
7572
VSCODE_VERSION=insiders
7673
windows_pre_build_command: .github\workflows\scripts\windows\install-nodejs.ps1
7774
windows_build_command: scripts\test_windows.ps1

.github/workflows/pull_request.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ jobs:
1616
NODE_PATH=/usr/local/nvm/versions/node/v20.18.2/bin
1717
NVM_DIR=/usr/local/nvm
1818
CI=1
19-
VSCODE_TEST=1
2019
FAST_TEST_RUN=${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && '0' || '1'}}
2120
linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh
2221
linux_build_command: ./scripts/test.sh
2322
# Windows
2423
windows_exclude_swift_versions: '[{"swift_version": "nightly-6.1"},{"swift_version": "nightly"}]'
2524
windows_env_vars: |
2625
CI=1
27-
VSCODE_TEST=1
2826
FAST_TEST_RUN=${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && '0' || '1'}}
2927
windows_pre_build_command: .github\workflows\scripts\windows\install-nodejs.ps1
3028
windows_build_command: scripts\test_windows.ps1

.vscode/launch.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"args": ["--profile=testing-debug"],
2626
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
2727
"env": {
28-
"VSCODE_DEBUG": "1",
29-
"VSCODE_TEST": "1"
28+
"VSCODE_DEBUG": "1"
3029
},
3130
"preLaunchTask": "compile-tests"
3231
},

scripts/test_windows.ps1

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,54 @@
1212
##
1313
##===----------------------------------------------------------------------===##
1414

15-
$env:CI = "1"
16-
$env:FAST_TEST_RUN = "1"
15+
# In newer Visual C++ Tools they've added compiler intrinsics headers in wchar.h
16+
# that end up creating a cyclic dependency between the `ucrt` and compiler intrinsics modules.
17+
# Newer versions of swift (6.2) have a fixed modulemap that resolves the issue: https://github.com/swiftlang/swift/pull/79751
18+
$windowsSdkVersion = "10.0.22000.0"
19+
$vcToolsVersion = "14.43.34808"
20+
21+
# As a workaround we can pin the tools/SDK versions to older versions that are present in the GH Actions Windows image.
22+
# In the future we may only want to apply this workaround to older versions of Swift that don't have the fixed module map.
23+
$jsonFilePath = "./assets/test/.vscode/settings.json"
24+
try {
25+
$jsonContent = Get-Content -Raw -Path $jsonFilePath | ConvertFrom-Json
26+
} catch {
27+
Write-Host "Invalid JSON content in $jsonFilePath"
28+
exit 1
29+
}
30+
if ($jsonContent.PSObject.Properties['swift.buildArguments']) {
31+
$jsonContent.PSObject.Properties.Remove('swift.buildArguments')
32+
}
33+
34+
$windowsSdkRoot = "C:\Program Files (x86)\Windows Kits\10\"
35+
36+
$jsonContent | Add-Member -MemberType NoteProperty -Name "swift.buildArguments" -Value @(
37+
"-Xbuild-tools-swiftc", "-windows-sdk-root", "-Xbuild-tools-swiftc", $windowsSdkRoot,
38+
"-Xbuild-tools-swiftc", "-windows-sdk-version", "-Xbuild-tools-swiftc", $windowsSdkVersion,
39+
"-Xbuild-tools-swiftc", "-visualc-tools-version", "-Xbuild-tools-swiftc", $vcToolsVersion,
40+
"-Xswiftc", "-windows-sdk-root", "-Xswiftc", $windowsSdkRoot,
41+
"-Xswiftc", "-windows-sdk-version", "-Xswiftc", $windowsSdkVersion,
42+
"-Xswiftc", "-visualc-tools-version", "-Xswiftc", $vcToolsVersion
43+
)
44+
45+
if ($jsonContent.PSObject.Properties['swift.packageArguments']) {
46+
$jsonContent.PSObject.Properties.Remove('swift.packageArguments')
47+
}
48+
49+
$jsonContent | Add-Member -MemberType NoteProperty -Name "swift.packageArguments" -Value @(
50+
"-Xbuild-tools-swiftc", "-windows-sdk-root", "-Xbuild-tools-swiftc", $windowsSdkRoot,
51+
"-Xbuild-tools-swiftc", "-windows-sdk-version", "-Xbuild-tools-swiftc", $windowsSdkVersion,
52+
"-Xbuild-tools-swiftc", "-visualc-tools-version", "-Xbuild-tools-swiftc", $vcToolsVersion,
53+
"-Xswiftc", "-windows-sdk-root", "-Xswiftc", $windowsSdkRoot,
54+
"-Xswiftc", "-windows-sdk-version", "-Xswiftc", $windowsSdkVersion,
55+
"-Xswiftc", "-visualc-tools-version", "-Xswiftc", $vcToolsVersion
56+
)
57+
58+
$jsonContent | ConvertTo-Json -Depth 32 | Set-Content -Path $jsonFilePath
59+
60+
Write-Host "Contents of ${jsonFilePath}:"
61+
Get-Content -Path $jsonFilePath
62+
1763
npm ci -ignore-script node-pty
1864
npm run lint
1965
npm run format

src/FolderContext.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { WorkspaceContext, FolderOperation } from "./WorkspaceContext";
2222
import { BackgroundCompilation } from "./BackgroundCompilation";
2323
import { TaskQueue } from "./tasks/TaskQueue";
2424
import { isPathInsidePath } from "./utilities/filesystem";
25+
import { SwiftOutputChannel } from "./ui/SwiftOutputChannel";
2526

2627
export class FolderContext implements vscode.Disposable {
2728
private packageWatcher: PackageWatcher;
@@ -135,8 +136,8 @@ export class FolderContext implements vscode.Disposable {
135136
}
136137

137138
/** Load Swift Plugins and store in Package */
138-
async loadSwiftPlugins() {
139-
await this.swiftPackage.loadSwiftPlugins(this.workspaceContext.toolchain);
139+
async loadSwiftPlugins(outputChannel: SwiftOutputChannel) {
140+
await this.swiftPackage.loadSwiftPlugins(this.workspaceContext.toolchain, outputChannel);
140141
}
141142

142143
/**

src/SwiftPackage.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { execSwift, getErrorDescription, hashString } from "./utilities/utilitie
1919
import { isPathInsidePath } from "./utilities/filesystem";
2020
import { SwiftToolchain } from "./toolchain/toolchain";
2121
import { BuildFlags } from "./toolchain/BuildFlags";
22+
import { SwiftOutputChannel } from "./ui/SwiftOutputChannel";
2223

2324
/** Swift Package Manager contents */
2425
export interface PackageContents {
@@ -278,7 +279,8 @@ export class SwiftPackage implements PackageContents {
278279

279280
private static async loadPlugins(
280281
folder: vscode.Uri,
281-
toolchain: SwiftToolchain
282+
toolchain: SwiftToolchain,
283+
outputChannel: SwiftOutputChannel
282284
): Promise<PackagePlugin[]> {
283285
try {
284286
const { stdout } = await execSwift(["package", "plugin", "--list"], toolchain, {
@@ -298,7 +300,8 @@ export class SwiftPackage implements PackageContents {
298300
}
299301
}
300302
return plugins;
301-
} catch {
303+
} catch (error) {
304+
outputChannel.appendLine(`Failed to laod plugins: ${error}`);
302305
// failed to load resolved file return undefined
303306
return [];
304307
}
@@ -338,8 +341,8 @@ export class SwiftPackage implements PackageContents {
338341
this.workspaceState = await SwiftPackage.loadWorkspaceState(this.folder);
339342
}
340343

341-
public async loadSwiftPlugins(toolchain: SwiftToolchain) {
342-
this.plugins = await SwiftPackage.loadPlugins(this.folder, toolchain);
344+
public async loadSwiftPlugins(toolchain: SwiftToolchain, outputChannel: SwiftOutputChannel) {
345+
this.plugins = await SwiftPackage.loadPlugins(this.folder, toolchain, outputChannel);
343346
}
344347

345348
/** Return if has valid contents */

src/TestExplorer/TestExplorer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ export class TestExplorer {
412412
* @param errorDescription Error description to display
413413
*/
414414
private setErrorTestItem(errorDescription: string | undefined, title = "Test Discovery Error") {
415+
this.folderContext.workspaceContext.outputChannel.log(
416+
`Test Discovery Error: ${errorDescription}`
417+
);
415418
this.controller.items.forEach(item => {
416419
this.controller.items.delete(item.id);
417420
});

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<Api> {
203203
folder.workspaceFolder.uri
204204
)})`,
205205
async () => {
206-
await folder.loadSwiftPlugins();
206+
await folder.loadSwiftPlugins(outputChannel);
207207
workspace.updatePluginContextKey();
208208
folder.fireEvent(FolderOperation.pluginsUpdated);
209209
}

src/process-list/BaseProcessList.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export abstract class BaseProcessList implements ProcessList {
4242
protected abstract createParser(): ProcessListParser;
4343

4444
async listAllProcesses(): Promise<Process[]> {
45-
const execCommand = exec(this.getCommand(), this.getCommandArguments());
45+
const execCommand = exec(this.getCommand(), this.getCommandArguments(), {
46+
maxBuffer: 10 * 1024 * 1024, // Increase the max buffer size to 10Mb
47+
});
4648
const parser = this.createParser();
4749
return (await execCommand).stdout.split("\n").flatMap(line => {
4850
const process = parser(line.toString());

src/toolchain/BuildFlags.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ export class BuildFlags {
7171

7272
withSwiftPackageFlags(args: string[]): string[] {
7373
switch (args[0]) {
74-
case "package":
75-
if (args[1] === "resolve" || args[1] === "update") {
76-
return [...args, ...configuration.packageArguments];
74+
case "package": {
75+
if (args[1] === "init") {
76+
return args;
7777
}
78-
return args;
78+
const newArgs = [...args];
79+
newArgs.splice(1, 0, ...configuration.packageArguments);
80+
return newArgs;
81+
}
7982
case "build":
8083
case "run":
8184
case "test":

0 commit comments

Comments
 (0)