Skip to content

Commit 0ba3dac

Browse files
committed
Enable SwiftBuild in pipeline
Ensure we run the pipeliines against SwiftBuild to give us extra confidence with the tooling Skip running SwiftBuild on Windows as it's currently failing.
1 parent 2096cff commit 0ba3dac

File tree

5 files changed

+225
-66
lines changed

5 files changed

+225
-66
lines changed

.github/workflows/pull_request.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,52 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
tests:
16-
name: Test
15+
tests-using-native:
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
buildSystem: ["native", "swiftbuild"]
20+
linuxSwiftVersion: ['["nightly-main", "nightly-6.2"]', '["nightly-main"]']
21+
enable_windows_checks: [true]
22+
exclude:
23+
- buildSystem: "swiftbuild"
24+
linuxSwiftVersion: '["nightly-main", "nightly-6.2"]'
25+
- buildSystem: "swiftbuild"
26+
enable_windows_checks: true
27+
- buildSystem: "native"
28+
linuxSwiftVersion: '["nightly-main"]'
29+
name: Test (${{ matrix.buildSystem }})
30+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
31+
with:
32+
linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]'
33+
linux_swift_versions: ${{ matrix.linuxSwiftVersion }}
34+
linux_pre_build_command: ./.github/scripts/prebuild.sh
35+
linux_build_command: 'swift run swift-build --build-tests --build-system ${{ matrix.buildSystem}}'
36+
windows_swift_versions: '["nightly-main"]'
37+
windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1'
38+
windows_build_command: 'Invoke-Program swift run swift-build --build-tests --build-system ${{ matrix.buildSystem}}'
39+
enable_windows_checks: ${{ matrix.enable_windows_checks }}
40+
enable_ios_checks: true
41+
enable_macos_checks: true
42+
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]"
43+
macos_build_command: 'swift run swift-build --build-tests --build-system ${{ matrix.buildSystem}}'
44+
45+
tests-using-swiftbuild:
46+
name: Test (all SwiftBuild)
1747
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
1848
with:
1949
linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]'
2050
linux_swift_versions: '["nightly-main"]'
2151
linux_pre_build_command: ./.github/scripts/prebuild.sh
22-
linux_build_command: 'swift build'
52+
linux_build_command: 'swift run --build-system swiftbuild swift-build --build-tests --build-system swiftbuild'
53+
enable_windows_checks: false
2354
windows_swift_versions: '["nightly-main"]'
2455
windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1'
25-
windows_build_command: 'Invoke-Program swift build'
56+
windows_build_command: 'Invoke-Program swift run --build-system swiftbuild swift-build --build-tests --build-system swiftbuild'
2657
enable_ios_checks: true
2758
enable_macos_checks: true
2859
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]"
29-
macos_build_command: 'swift build'
60+
macos_build_command: 'swift run --build-system swiftbuild swift-build --build-tests --build-system swiftbuild'
3061

3162
soundness:
3263
name: Soundness

Sources/SwiftBuildSupport/PackagePIFBuilder+Helpers.swift

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import enum SwiftBuild.ProjectModel
6363

6464
enum TargetSuffix: String {
6565
case testable, dynamic
66-
66+
6767
func hasSuffix(id: GUID) -> Bool {
6868
id.value.hasSuffix("-\(self.rawValue)")
6969
}
@@ -524,18 +524,18 @@ extension PackageGraph.ResolvedModule {
524524

525525
/// Target-specific single-value build settings declared in the manifest and that apply to the target itself.
526526
var targetSingleValueSettings: [BuildConfiguration: SingleValueSettingsByPlatform] = [:]
527-
527+
528528
/// Target-specific multiple-value build settings declared in the manifest and that apply to the target itself.
529529
var targetMultipleValueSettings: [BuildConfiguration: MultipleValueSettingsByPlatform] = [:]
530530

531531
/// Target-specific single-value build settings that should be imparted to client targets (packages and projects).
532532
var impartedSingleValueSettings: SingleValueSettingsByPlatform = [:]
533-
533+
534534
/// Target-specific multiple-value build settings that should be imparted to client targets (packages and projects).
535535
var impartedMultipleValueSettings: MultipleValueSettingsByPlatform = [:]
536-
536+
537537
// MARK: - Convenience Methods
538-
538+
539539
/// Apply all settings to a ProjectModel.BuildSettings instance
540540
func apply(to buildSettings: inout ProjectModel.BuildSettings, for configuration: BuildConfiguration) {
541541
// Apply single value settings for all platforms
@@ -550,7 +550,7 @@ extension PackageGraph.ResolvedModule {
550550
}
551551
}
552552
}
553-
553+
554554
// Apply multiple value settings for all platforms
555555
if let multipleValuesByPlatform = targetMultipleValueSettings[configuration] {
556556
// First, collect all multiple-value settings that are being used
@@ -560,7 +560,7 @@ extension PackageGraph.ResolvedModule {
560560
usedMultipleValueSettings.insert(setting)
561561
}
562562
}
563-
563+
564564
// Now apply the platform-specific values
565565
for (platform, multipleValues) in multipleValuesByPlatform {
566566
for (setting, values) in multipleValues {
@@ -577,7 +577,7 @@ extension PackageGraph.ResolvedModule {
577577
}
578578
}
579579
}
580-
580+
581581
/// Apply imparted settings to a ProjectModel.BuildSettings instance
582582
func applyImparted(to buildSettings: inout ProjectModel.BuildSettings) {
583583
// Apply imparted single value settings for all platforms
@@ -590,7 +590,7 @@ extension PackageGraph.ResolvedModule {
590590
}
591591
}
592592
}
593-
593+
594594
// Apply imparted multiple value settings for all platforms
595595
for (platform, multipleValues) in impartedMultipleValueSettings {
596596
for (setting, values) in multipleValues {
@@ -621,7 +621,7 @@ extension PackageGraph.ResolvedModule {
621621
let values: [String]
622622
let singleValueSetting: ProjectModel.BuildSettings.SingleValueSetting?
623623
let multipleValueSetting: ProjectModel.BuildSettings.MultipleValueSetting?
624-
624+
625625
switch declaration {
626626
case .LINK_FRAMEWORKS:
627627
singleValueSetting = nil
@@ -1032,6 +1032,11 @@ extension ProjectModel.BuildSettings {
10321032
self[.PRODUCT_BUNDLE_IDENTIFIER] = "\(packageIdentity).\(productName)".spm_mangledToBundleIdentifier()
10331033
self[.SWIFT_PACKAGE_NAME] = packageName ?? nil
10341034

1035+
//This should really be swift-build defaults set in the .xcspec files, but changing that requires some extensive testing to ensure xcode projects are not effected.
1036+
// So for now lets just force it here.
1037+
self[.EXECUTABLE_PREFIX] = "lib"
1038+
self[.EXECUTABLE_PREFIX, Platform.windows] = ""
1039+
10351040
if !createDylibForDynamicProducts {
10361041
self[.GENERATE_INFOPLIST_FILE] = "YES"
10371042
// If the built framework is named same as one of the target in the package,
@@ -1106,7 +1111,7 @@ extension ObservabilityScope {
11061111

11071112
let indentation = String(repeating: " ", count: Int(indent))
11081113
let message = "PIF: \(indentation)\(message)"
1109-
1114+
11101115
let diagnostic = Diagnostic(severity: severity, message: message, metadata: metadata)
11111116
self.emit(diagnostic)
11121117
}
@@ -1133,7 +1138,7 @@ public struct SourceLocation: Sendable {
11331138

11341139
public init(_ file: StaticString, _ line: UInt) {
11351140
precondition(file.description.hasContent)
1136-
1141+
11371142
self.file = file
11381143
self.line = line
11391144
}

Tests/PackageLoadingTests/PackageBuilderTests.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ struct PackageBuilderTests {
10771077
try TargetDescription(name: "Random"),
10781078
]
10791079
)
1080-
1080+
10811081
try PackageBuilderTester(manifest, in: fs) { package, diagnostics in
10821082
try package.checkModule("Random") { result in
10831083
#expect("/\(predefinedSourceDir)" == result.target.path)
@@ -1177,7 +1177,7 @@ struct PackageBuilderTests {
11771177
try TargetDescription(name: "MyTests", type: .test),
11781178
]
11791179
)
1180-
1180+
11811181
try PackageBuilderTester(manifest, in: fs) { package, diagnostics in
11821182
try package.checkModule("MyTests") { result in
11831183
#expect("/\(predefinedSourceDir)" == result.target.path)
@@ -1280,7 +1280,7 @@ struct PackageBuilderTests {
12801280
try TargetDescription(name: "MyPlugin", type: .plugin, pluginCapability: .buildTool),
12811281
]
12821282
)
1283-
1283+
12841284
try PackageBuilderTester(manifest, in: fs) { package, diagnostics in
12851285
try package.checkModule("MyPlugin") { result in
12861286
result.checkSources(root: result.target.path.appending(component: predefinedSourceDir).pathString, paths: "Foo.swift")
@@ -2838,19 +2838,19 @@ struct PackageBuilderTests {
28382838
// invalid - same target in package "Bar"
28392839
"Bar",
28402840
"Bar",
2841-
2841+
28422842
// invalid - same target in package "Bar"
28432843
"Bar2",
28442844
.product(name: "Bar2", package: "Bar"),
2845-
2845+
28462846
// invalid - same target in this package
28472847
"Foo2",
28482848
"Foo2",
2849-
2849+
28502850
// invalid - same target in this package
28512851
"Foo3",
28522852
.target(name: "Foo3"),
2853-
2853+
28542854
// valid - different packages
28552855
"Qux",
28562856
.product(name: "Qux", package: "Bar")
@@ -2979,7 +2979,7 @@ struct PackageBuilderTests {
29792979
func testXcodeResources5_4AndEarlier() throws {
29802980
// In SwiftTools 5.4 and earlier, supported xcbuild file types are supported by default.
29812981
// Of course, modern file types such as xcstrings won't be supported here because those require a newer Swift tools version in general.
2982-
2982+
29832983
let root: AbsolutePath = "/Foo"
29842984
let foo = root.appending(components: "Sources", "Foo")
29852985

@@ -3011,11 +3011,11 @@ struct PackageBuilderTests {
30113011
}
30123012
}
30133013
}
3014-
3014+
30153015
@Test
30163016
func testXcodeResources5_5AndLater() throws {
30173017
// In SwiftTools 5.5 and later, xcbuild file types are only supported when explicitly passed via additionalFileRules.
3018-
3018+
30193019
let root: AbsolutePath = "/Foo"
30203020
let foo = root.appending(components: "Sources", "Foo")
30213021

@@ -3140,7 +3140,7 @@ struct PackageBuilderTests {
31403140
internalSourcesDir.appending("Internal.swift").pathString,
31413141
productSourcesDir.appending("Product.swift").pathString,
31423142
snippetsDir.appending("ASnippet.swift").pathString)
3143-
3143+
31443144
let manifest = Manifest.createRootManifest(
31453145
displayName: "Foo", toolsVersion: .v5_7,
31463146
products: [
@@ -3150,7 +3150,7 @@ struct PackageBuilderTests {
31503150
try TargetDescription(name: "Internal"),
31513151
try TargetDescription(name: "Product"),
31523152
])
3153-
3153+
31543154
try PackageBuilderTester(manifest, path: root, in: fs) { result, diagnostics in
31553155
result.checkProduct("Product") { product in
31563156
product.check(type: .library(.automatic), targets: ["Product"])
@@ -3315,7 +3315,7 @@ struct PackageBuilderTests {
33153315
}
33163316
}
33173317
}
3318-
3318+
33193319
@Test
33203320
func testCWarningControlFlags() throws {
33213321
let fs = InMemoryFileSystem(emptyFiles:

0 commit comments

Comments
 (0)