Skip to content

Commit 7f8e26b

Browse files
committed
Remove triple from SwiftBuild system output path
The triple name in the SwiftBuild build system is redundant. Remove the triple from the output path.
1 parent 7ad4f83 commit 7f8e26b

File tree

5 files changed

+99
-127
lines changed

5 files changed

+99
-127
lines changed

Sources/SPMBuildCore/Triple+Extensions.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ extension Triple {
3232
// can be used to build for any Apple platform and it has its own
3333
// conventions for build subpaths based on platforms.
3434
return "apple"
35-
case .swiftbuild, .native:
35+
case .swiftbuild:
36+
return "out"
37+
case .native:
3638
return self.platformBuildPathComponent
3739
}
3840
}

Sources/_InternalTestSupport/BuildSystemProvider+Configuration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extension BuildSystemProvider.Kind {
6666
case .native:
6767
return scratchPath + [tripleString, "\(config)".lowercased()]
6868
case .swiftbuild:
69-
return scratchPath + [tripleString, "Products", "\(config)".capitalized + suffix]
69+
return scratchPath + ["out", "Products", "\(config)".capitalized + suffix]
7070
case .xcode:
7171
return scratchPath + ["apple", "Products", "\(config)".capitalized + suffix]
7272
}

Tests/CommandsTests/BuildCommandTests.swift

Lines changed: 72 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -818,31 +818,27 @@ struct BuildCommandTestCases {
818818
data: BuildData,
819819
) async throws {
820820
let buildSystem = data.buildSystem
821-
try await withKnownIssue {
822-
try await fixture(name: "Miscellaneous/LibraryEvolution") { fixturePath in
823-
let result = try await build(
824-
[],
825-
packagePath: fixturePath,
826-
configuration: data.config,
827-
buildSystem: buildSystem,
828-
)
829-
switch buildSystem {
830-
case .native:
831-
#expect(result.moduleContents.contains("A.swiftinterface"))
832-
#expect(result.moduleContents.contains("B.swiftinterface"))
833-
case .swiftbuild, .xcode:
834-
let moduleARegex = try Regex(#"A[.]swiftmodule[/].*[.]swiftinterface"#)
835-
let moduleBRegex = try Regex(#"B[.]swiftmodule[/].*[.]swiftmodule"#)
836-
withKnownIssue("SWBINTTODO: Test failed because of missing 'A.swiftmodule/*.swiftinterface' files") {
837-
#expect(result.moduleContents.contains { $0.contains(moduleARegex) })
838-
} when: {
839-
buildSystem == .swiftbuild
840-
}
841-
#expect(result.moduleContents.contains { $0.contains(moduleBRegex) })
842-
}
821+
try await fixture(name: "Miscellaneous/LibraryEvolution") { fixturePath in
822+
let result = try await build(
823+
[],
824+
packagePath: fixturePath,
825+
configuration: data.config,
826+
buildSystem: buildSystem,
827+
)
828+
switch buildSystem {
829+
case .native:
830+
#expect(result.moduleContents.contains("A.swiftinterface"))
831+
#expect(result.moduleContents.contains("B.swiftinterface"))
832+
case .swiftbuild, .xcode:
833+
let moduleARegex = try Regex(#"A[.]swiftmodule[/].*[.]swiftinterface"#)
834+
let moduleBRegex = try Regex(#"B[.]swiftmodule[/].*[.]swiftmodule"#)
835+
withKnownIssue("SWBINTTODO: Test failed because of missing 'A.swiftmodule/*.swiftinterface' files") {
836+
#expect(result.moduleContents.contains { $0.contains(moduleARegex) })
837+
} when: {
838+
buildSystem == .swiftbuild
839+
}
840+
#expect(result.moduleContents.contains { $0.contains(moduleBRegex) })
843841
}
844-
} when: {
845-
buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .windows
846842
}
847843
}
848844

@@ -857,47 +853,43 @@ struct BuildCommandTestCases {
857853
data: BuildData,
858854
) async throws {
859855
let buildSystem = data.buildSystem
860-
try await withKnownIssue {
861-
try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in
862-
let buildCompleteRegex = try Regex(#"Build complete!\s?(\([0-9]*\.[0-9]*\s*s(econds)?\))?"#)
863-
do {
864-
let result = try await execute(
865-
packagePath: fixturePath,
866-
configuration: data.config,
867-
buildSystem: buildSystem,
868-
)
869-
// This test fails to match the 'Compiling' regex; rdar://101815761
870-
// XCTAssertMatch(result.stdout, .regex("\\[[1-9][0-9]*\\/[1-9][0-9]*\\] Compiling"))
871-
let lines = result.stdout.split(whereSeparator: { $0.isNewline })
872-
let lastLine = try #require(lines.last)
873-
#expect(lastLine.contains(buildCompleteRegex))
874-
}
856+
try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in
857+
let buildCompleteRegex = try Regex(#"Build complete!\s?(\([0-9]*\.[0-9]*\s*s(econds)?\))?"#)
858+
do {
859+
let result = try await execute(
860+
packagePath: fixturePath,
861+
configuration: data.config,
862+
buildSystem: buildSystem,
863+
)
864+
// This test fails to match the 'Compiling' regex; rdar://101815761
865+
// XCTAssertMatch(result.stdout, .regex("\\[[1-9][0-9]*\\/[1-9][0-9]*\\] Compiling"))
866+
let lines = result.stdout.split(whereSeparator: { $0.isNewline })
867+
let lastLine = try #require(lines.last)
868+
#expect(lastLine.contains(buildCompleteRegex))
869+
}
875870

876-
do {
877-
// test second time, to stabilize the cache
878-
try await execute(
879-
packagePath: fixturePath,
880-
configuration: data.config,
881-
buildSystem: buildSystem,
882-
)
883-
}
871+
do {
872+
// test second time, to stabilize the cache
873+
try await execute(
874+
packagePath: fixturePath,
875+
configuration: data.config,
876+
buildSystem: buildSystem,
877+
)
878+
}
884879

885-
do {
886-
// test third time, to make sure message is presented even when nothing to build (cached)
887-
let result = try await execute(
888-
packagePath: fixturePath,
889-
configuration: data.config,
890-
buildSystem: buildSystem,
891-
)
892-
// This test fails to match the 'Compiling' regex; rdar://101815761
893-
// XCTAssertNoMatch(result.stdout, .regex("\\[[1-9][0-9]*\\/[1-9][0-9]*\\] Compiling"))
894-
let lines = result.stdout.split(whereSeparator: { $0.isNewline })
895-
let lastLine = try #require(lines.last)
896-
#expect(lastLine.contains(buildCompleteRegex))
897-
}
880+
do {
881+
// test third time, to make sure message is presented even when nothing to build (cached)
882+
let result = try await execute(
883+
packagePath: fixturePath,
884+
configuration: data.config,
885+
buildSystem: buildSystem,
886+
)
887+
// This test fails to match the 'Compiling' regex; rdar://101815761
888+
// XCTAssertNoMatch(result.stdout, .regex("\\[[1-9][0-9]*\\/[1-9][0-9]*\\] Compiling"))
889+
let lines = result.stdout.split(whereSeparator: { $0.isNewline })
890+
let lastLine = try #require(lines.last)
891+
#expect(lastLine.contains(buildCompleteRegex))
898892
}
899-
} when: {
900-
buildSystem == .swiftbuild && (ProcessInfo.hostOperatingSystem == .windows)
901893
}
902894
}
903895

@@ -1135,31 +1127,24 @@ struct BuildCommandTestCases {
11351127
func swiftDriverRawOutputGetsNewlines(
11361128
buildSystem: BuildSystemProvider.Kind,
11371129
) async throws {
1138-
try await withKnownIssue(
1139-
"error produced for this fixture",
1140-
isIntermittent: ProcessInfo.hostOperatingSystem == .linux,
1141-
) {
1142-
try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in
1143-
// Building with `-wmo` should result in a `remark: Incremental compilation has been disabled: it is not
1144-
// compatible with whole module optimization` message, which should have a trailing newline. Since that
1145-
// message won't be there at all when the legacy compiler driver is used, we gate this check on whether the
1146-
// remark is there in the first place.
1147-
let result = try await execute(
1148-
["-Xswiftc", "-wmo"],
1149-
packagePath: fixturePath,
1150-
configuration: .release,
1151-
buildSystem: buildSystem,
1152-
)
1153-
if result.stdout.contains(
1154-
"remark: Incremental compilation has been disabled: it is not compatible with whole module optimization"
1155-
) {
1156-
#expect(result.stdout.contains("optimization\n"))
1157-
#expect(!result.stdout.contains("optimization["))
1158-
#expect(!result.stdout.contains("optimizationremark"))
1159-
}
1130+
try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in
1131+
// Building with `-wmo` should result in a `remark: Incremental compilation has been disabled: it is not
1132+
// compatible with whole module optimization` message, which should have a trailing newline. Since that
1133+
// message won't be there at all when the legacy compiler driver is used, we gate this check on whether the
1134+
// remark is there in the first place.
1135+
let result = try await execute(
1136+
["-Xswiftc", "-wmo"],
1137+
packagePath: fixturePath,
1138+
configuration: .release,
1139+
buildSystem: buildSystem,
1140+
)
1141+
if result.stdout.contains(
1142+
"remark: Incremental compilation has been disabled: it is not compatible with whole module optimization"
1143+
) {
1144+
#expect(result.stdout.contains("optimization\n"))
1145+
#expect(!result.stdout.contains("optimization["))
1146+
#expect(!result.stdout.contains("optimizationremark"))
11601147
}
1161-
} when: {
1162-
ProcessInfo.hostOperatingSystem == .windows && buildSystem == .swiftbuild
11631148
}
11641149
}
11651150

@@ -1469,7 +1454,7 @@ struct BuildCommandTestCases {
14691454
"""
14701455
Windows: Sometimes failed to build due to a possible path issue
14711456
All: --very-verbose causes rebuild on SwiftBuild (https://github.com/swiftlang/swift-package-manager/issues/9299)
1472-
""",
1457+
""",
14731458
isIntermittent: true) {
14741459
try await fixture(name: "ValidLayouts/SingleModule/ExecutableNew") { fixturePath in
14751460
_ = try await build(

Tests/CommandsTests/RunCommandTests.swift

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct RunCommandTests {
5353
buildSystem: BuildSystemProvider.Kind
5454
) async throws {
5555
let stdout = try await execute(["-help"], buildSystem: buildSystem).stdout
56-
56+
5757
#expect(stdout.contains("USAGE: swift run <options>") || stdout.contains("USAGE: swift run [<options>]"), "got stdout:\n \(stdout)")
5858
}
5959

@@ -106,7 +106,6 @@ struct RunCommandTests {
106106
func toolsetDebugger(
107107
buildSystem: BuildSystemProvider.Kind,
108108
) async throws {
109-
try await withKnownIssue {
110109
try await fixture(name: "Miscellaneous/EchoExecutable") { fixturePath in
111110
#if os(Windows)
112111
let win32 = ".win32"
@@ -135,10 +134,6 @@ struct RunCommandTests {
135134
buildSystem == .swiftbuild
136135
}
137136
}
138-
} when: {
139-
(.swiftbuild == buildSystem && ProcessInfo.hostOperatingSystem == .windows)
140-
|| (.native == buildSystem && ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSmokeTestPipeline)
141-
}
142137
}
143138

144139
@Test(
@@ -152,34 +147,29 @@ struct RunCommandTests {
152147
func productArgumentPassing(
153148
buildSystem: BuildSystemProvider.Kind,
154149
) async throws {
155-
try await withKnownIssue {
156-
try await fixture(name: "Miscellaneous/EchoExecutable") { fixturePath in
157-
let (stdout, stderr) = try await execute(
158-
["secho", "1", "--hello", "world"],
159-
packagePath: fixturePath,
160-
buildSystem: buildSystem,
161-
)
150+
try await fixture(name: "Miscellaneous/EchoExecutable") { fixturePath in
151+
let (stdout, stderr) = try await execute(
152+
["secho", "1", "--hello", "world"],
153+
packagePath: fixturePath,
154+
buildSystem: buildSystem,
155+
)
162156

163-
// We only expect tool's output on the stdout stream.
164-
#expect(stdout.contains("""
165-
"1" "--hello" "world"
166-
"""))
157+
// We only expect tool's output on the stdout stream.
158+
#expect(stdout.contains("""
159+
"1" "--hello" "world"
160+
"""))
167161

168-
// swift-build-tool output should go to stderr.
169-
withKnownIssue {
170-
#expect(stderr.contains("Compiling"))
171-
} when: {
172-
buildSystem == .swiftbuild
173-
}
174-
withKnownIssue {
175-
#expect(stderr.contains("Linking"))
176-
} when: {
177-
buildSystem == .swiftbuild
178-
}
162+
// swift-build-tool output should go to stderr.
163+
withKnownIssue {
164+
#expect(stderr.contains("Compiling"))
165+
} when: {
166+
buildSystem == .swiftbuild
167+
}
168+
withKnownIssue {
169+
#expect(stderr.contains("Linking"))
170+
} when: {
171+
buildSystem == .swiftbuild
179172
}
180-
} when: {
181-
(.windows == ProcessInfo.hostOperatingSystem && buildSystem == .swiftbuild)
182-
|| (.windows == ProcessInfo.hostOperatingSystem && buildSystem == .native && CiEnvironment.runningInSmokeTestPipeline)
183173
}
184174
}
185175

@@ -220,7 +210,6 @@ struct RunCommandTests {
220210
func multipleExecutableAndExplicitExecutable(
221211
buildSystem: BuildSystemProvider.Kind,
222212
) async throws {
223-
try await withKnownIssue {
224213
try await fixture(name: "Miscellaneous/MultipleExecutables") { fixturePath in
225214

226215
let error = await #expect(throws: SwiftPMError.self ) {
@@ -242,10 +231,6 @@ struct RunCommandTests {
242231
(runOutput, _) = try await execute(["exec2"], packagePath: fixturePath, buildSystem: buildSystem)
243232
#expect(runOutput.contains("2"))
244233
}
245-
} when: {
246-
([.windows].contains(ProcessInfo.hostOperatingSystem) && buildSystem == .swiftbuild && CiEnvironment.runningInSelfHostedPipeline)
247-
|| (.windows == ProcessInfo.hostOperatingSystem && [.native, .swiftbuild].contains(buildSystem) && CiEnvironment.runningInSmokeTestPipeline)
248-
}
249234
}
250235

251236

Tests/IntegrationTests/SwiftPMTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ private struct SwiftPMTests {
192192
)
193193
case .swiftbuild:
194194
fooPath = try AbsolutePath(
195-
validating: ".build/\(arch)-apple-macosx/Products/Debug/foo",
195+
validating: ".build/Products/Debug/foo",
196196
relativeTo: packagePath
197197
)
198198
default:
@@ -225,7 +225,7 @@ private struct SwiftPMTests {
225225
)
226226
case .swiftbuild:
227227
fooPath = try AbsolutePath(
228-
validating: ".build/\(hostArch)-apple-macosx/Products/Debug/foo",
228+
validating: ".build/Products/Debug/foo",
229229
relativeTo: packagePath
230230
)
231231
default:

0 commit comments

Comments
 (0)