Skip to content

Commit 5390638

Browse files
committed
Run the CMake smoke test on Windows
This would have caught a recent regression.
1 parent 8d3d1d0 commit 5390638

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
##===----------------------------------------------------------------------===##
2+
##
3+
## This source file is part of the Swift open source project
4+
##
5+
## Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
## Licensed under Apache License v2.0 with Runtime Library Exception
7+
##
8+
## See http://swift.org/LICENSE.txt for license information
9+
## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
##
11+
##===----------------------------------------------------------------------===##
12+
13+
param (
14+
[switch]$SkipAndroid,
15+
[switch]$InstallCMake
16+
)
17+
18+
# winget isn't easily made available in containers, so use chocolatey
19+
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
20+
21+
if ($InstallCMake) {
22+
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' --apply-install-arguments-to-dependencies
23+
choco install -y ninja
24+
25+
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
26+
refreshenv
27+
}
28+
29+
if (-not $SkipAndroid) {
30+
choco install android-ndk
31+
32+
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
33+
refreshenv
34+
35+
# Work around a bug in the package causing the env var to be set incorrectly
36+
$env:ANDROID_NDK_ROOT = $env:ANDROID_NDK_ROOT.replace('-windows.zip','')
37+
}

.github/workflows/pull_request.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ jobs:
2929
linux_pre_build_command: SKIP_ANDROID=1 INSTALL_CMAKE=1 ./.github/scripts/linux_pre_build.sh
3030
linux_build_command: 'swift package -Xbuild-tools-swiftc -DUSE_PROCESS_SPAWNING_WORKAROUND cmake-smoke-test --disable-sandbox --cmake-path `which cmake` --ninja-path `which ninja` --extra-cmake-arg -DCMAKE_C_COMPILER=`which clang` --extra-cmake-arg -DCMAKE_CXX_COMPILER=`which clang++` --extra-cmake-arg -DCMAKE_Swift_COMPILER=`which swiftc`'
3131
linux_swift_versions: '["nightly-main"]'
32-
windows_swift_versions: '[]'
32+
windows_pre_build_command: 'Invoke-Program .\.github\scripts\windows_pre_build.ps1 -SkipAndroid -InstallCMake'
33+
windows_swift_versions: '["nightly-main"]'
34+
windows_build_command: 'Invoke-Program swift package -Xbuild-tools-swiftc cmake-smoke-test --disable-sandbox --cmake-path (Get-Command cmake).Path --ninja-path (Get-Command ninja).Path --extra-cmake-arg -DCMAKE_C_COMPILER=(Get-Command clang).Path --extra-cmake-arg -DCMAKE_CXX_COMPILER=(Get-Command clang++).Path --extra-cmake-arg -DCMAKE_Swift_COMPILER=(Get-Command swiftc).Path'
35+
3336
soundness:
3437
name: Soundness
3538
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main

Plugins/cmake-smoke-test/cmake-smoke-test.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ extension Process {
187187

188188
static func checkNonZeroExit(url: URL, arguments: [String], workingDirectory: URL, environment: [String: String]? = nil) async throws {
189189
Diagnostics.progress("\(url.path()) \(arguments.joined(separator: " "))")
190-
#if USE_PROCESS_SPAWNING_WORKAROUND
190+
#if USE_PROCESS_SPAWNING_WORKAROUND && !os(Windows)
191191
Diagnostics.progress("Using process spawning workaround")
192192
// Linux workaround for https://github.com/swiftlang/swift-corelibs-foundation/issues/4772
193193
// Foundation.Process on Linux seems to inherit the Process.run()-calling thread's signal mask, creating processes that even have SIGTERM blocked
@@ -246,6 +246,7 @@ extension Process {
246246
}
247247
}
248248

249+
#if USE_PROCESS_SPAWNING_WORKAROUND && !os(Windows)
249250
func scan<S: Sequence, U>(_ seq: S, _ initial: U, _ combine: (U, S.Element) -> U) -> [U] {
250251
var result: [U] = []
251252
result.reserveCapacity(seq.underestimatedCount)
@@ -283,3 +284,4 @@ func withArrayOfCStrings<T>(
283284
}
284285
}
285286
}
287+
#endif

0 commit comments

Comments
 (0)