Skip to content

Commit ec5d66a

Browse files
authored
Remove triple from SwiftBuild system output path (#9370)
The triple name in the SwiftBuild build system is redundant. Remove the triple from the output path.
1 parent 4eb0097 commit ec5d66a

File tree

6 files changed

+101
-105
lines changed

6 files changed

+101
-105
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: 68 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,23 @@ struct BuildCommandTestCases {
846846
}
847847
}
848848

849+
@Test
850+
func pifManifestFileIsCreatedInTheRootScratchPathDirectory() async throws {
851+
try await fixture(name: "Miscellaneous/ParseableInterfaces") { fixturePath in
852+
try await withTemporaryDirectory { tmpDir in
853+
try await executeSwiftBuild(
854+
fixturePath,
855+
extraArgs: [
856+
"--scratch-path",
857+
tmpDir.pathString,
858+
],
859+
buildSystem: .swiftbuild
860+
)
861+
expectFileExists(at: tmpDir.appending("manifest.pif"))
862+
}
863+
}
864+
}
865+
849866
@Test(
850867
.tags(
851868
.Feature.BuildCache,
@@ -857,47 +874,43 @@ struct BuildCommandTestCases {
857874
data: BuildData,
858875
) async throws {
859876
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-
}
877+
try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in
878+
let buildCompleteRegex = try Regex(#"Build complete!\s?(\([0-9]*\.[0-9]*\s*s(econds)?\))?"#)
879+
do {
880+
let result = try await execute(
881+
packagePath: fixturePath,
882+
configuration: data.config,
883+
buildSystem: buildSystem,
884+
)
885+
// This test fails to match the 'Compiling' regex; rdar://101815761
886+
// XCTAssertMatch(result.stdout, .regex("\\[[1-9][0-9]*\\/[1-9][0-9]*\\] Compiling"))
887+
let lines = result.stdout.split(whereSeparator: { $0.isNewline })
888+
let lastLine = try #require(lines.last)
889+
#expect(lastLine.contains(buildCompleteRegex))
890+
}
875891

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-
}
892+
do {
893+
// test second time, to stabilize the cache
894+
try await execute(
895+
packagePath: fixturePath,
896+
configuration: data.config,
897+
buildSystem: buildSystem,
898+
)
899+
}
884900

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-
}
901+
do {
902+
// test third time, to make sure message is presented even when nothing to build (cached)
903+
let result = try await execute(
904+
packagePath: fixturePath,
905+
configuration: data.config,
906+
buildSystem: buildSystem,
907+
)
908+
// This test fails to match the 'Compiling' regex; rdar://101815761
909+
// XCTAssertNoMatch(result.stdout, .regex("\\[[1-9][0-9]*\\/[1-9][0-9]*\\] Compiling"))
910+
let lines = result.stdout.split(whereSeparator: { $0.isNewline })
911+
let lastLine = try #require(lines.last)
912+
#expect(lastLine.contains(buildCompleteRegex))
898913
}
899-
} when: {
900-
buildSystem == .swiftbuild && (ProcessInfo.hostOperatingSystem == .windows)
901914
}
902915
}
903916

@@ -1135,31 +1148,24 @@ struct BuildCommandTestCases {
11351148
func swiftDriverRawOutputGetsNewlines(
11361149
buildSystem: BuildSystemProvider.Kind,
11371150
) 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-
}
1151+
try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in
1152+
// Building with `-wmo` should result in a `remark: Incremental compilation has been disabled: it is not
1153+
// compatible with whole module optimization` message, which should have a trailing newline. Since that
1154+
// message won't be there at all when the legacy compiler driver is used, we gate this check on whether the
1155+
// remark is there in the first place.
1156+
let result = try await execute(
1157+
["-Xswiftc", "-wmo"],
1158+
packagePath: fixturePath,
1159+
configuration: .release,
1160+
buildSystem: buildSystem,
1161+
)
1162+
if result.stdout.contains(
1163+
"remark: Incremental compilation has been disabled: it is not compatible with whole module optimization"
1164+
) {
1165+
#expect(result.stdout.contains("optimization\n"))
1166+
#expect(!result.stdout.contains("optimization["))
1167+
#expect(!result.stdout.contains("optimizationremark"))
11601168
}
1161-
} when: {
1162-
ProcessInfo.hostOperatingSystem == .windows && buildSystem == .swiftbuild
11631169
}
11641170
}
11651171

Tests/CommandsTests/PackageCommandTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5646,7 +5646,7 @@ struct PackageCommandTests {
56465646
data: BuildData,
56475647
) async throws {
56485648
// Plugin arguments: check-testability <targetName> <config> <shouldTestable>
5649-
try await withKnownIssue {
5649+
try await withKnownIssue(isIntermittent: true) {
56505650
// Overall configuration: debug, plugin build request: debug -> without testability
56515651
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
56525652
let _ = await #expect(throws: Never.self) {
@@ -5674,7 +5674,7 @@ struct PackageCommandTests {
56745674
func commandPluginBuildTestabilityInternalModule_Release_False(
56755675
data: BuildData,
56765676
) async throws {
5677-
try await withKnownIssue {
5677+
try await withKnownIssue(isIntermittent: true) {
56785678
// Overall configuration: debug, plugin build request: release -> without testability
56795679
try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in
56805680
let _ = await #expect(throws: Never.self) {

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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ private struct SwiftPMTests {
154154
}
155155
}
156156

157-
@Test(.requireHostOS(.macOS), arguments: [BuildSystemProvider.Kind.native, .swiftbuild])
157+
@Test(
158+
.requireHostOS(.macOS),
159+
arguments: SupportedBuildSystemOnAllPlatforms,
160+
)
158161
func testArchCustomization(buildSystem: BuildSystemProvider.Kind) async throws {
159162
try await withTemporaryDirectory { tmpDir in
160163
let packagePath = tmpDir.appending(component: "foo")
@@ -194,7 +197,7 @@ private struct SwiftPMTests {
194197
)
195198
case .swiftbuild:
196199
fooPath = try AbsolutePath(
197-
validating: ".build/\(arch)-apple-macosx/Products/Debug/foo",
200+
validating: ".build/out/Products/Debug/foo",
198201
relativeTo: packagePath
199202
)
200203
default:
@@ -227,7 +230,7 @@ private struct SwiftPMTests {
227230
)
228231
case .swiftbuild:
229232
fooPath = try AbsolutePath(
230-
validating: ".build/\(hostArch)-apple-macosx/Products/Debug/foo",
233+
validating: ".build/out/Products/Debug/foo",
231234
relativeTo: packagePath
232235
)
233236
default:

0 commit comments

Comments
 (0)