Skip to content

Commit 338edfd

Browse files
authored
Improve cross-compilation when using experimental XCBuild support (#7719)
This allows e.g. `swift build --build-system xcode --triple arm64-apple-iphoneos` to work, slightly improving the ergonomics here and reducing hard-coded values.
1 parent 33662ed commit 338edfd

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

Sources/CoreCommands/Options.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,8 @@ public struct BuildOptions: ParsableArguments {
473473
public var debugInfoFormat: DebugInfoFormat = .dwarf
474474

475475
public var buildSystem: BuildSystemProvider.Kind {
476-
#if os(macOS)
477476
// Force the Xcode build system if we want to build more than one arch.
478477
return self.architectures.count > 1 ? .xcode : self._buildSystem
479-
#else
480-
// Force building with the native build system on other platforms than macOS.
481-
return .native
482-
#endif
483478
}
484479

485480
/// Whether to enable test discovery on platforms without Objective-C runtime.

Sources/XCBuildSupport/XcodeBuildSystem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem {
233233
func createBuildParametersFile() throws -> AbsolutePath {
234234
// Generate the run destination parameters.
235235
let runDestination = XCBBuildParameters.RunDestination(
236-
platform: "macosx",
237-
sdk: "macosx",
236+
platform: self.buildParameters.triple.osNameUnversioned,
237+
sdk: self.buildParameters.triple.osNameUnversioned,
238238
sdkVariant: nil,
239239
targetArchitecture: buildParameters.triple.archName,
240240
supportedArchitectures: [],

Tests/CommandsTests/BuildCommandTests.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ final class BuildCommandTests: CommandsTestCase {
182182
)
183183

184184
// Print correct path when building with XCBuild.
185+
#if os(macOS)
185186
let xcodeDebugOutput = try await execute(["--build-system", "xcode", "--show-bin-path"], packagePath: fullPath)
186187
.stdout
187188
let xcodeReleaseOutput = try await execute(
188189
["--build-system", "xcode", "-c", "release", "--show-bin-path"],
189190
packagePath: fullPath
190191
).stdout
191-
#if os(macOS)
192192
XCTAssertEqual(
193193
xcodeDebugOutput,
194194
"\(xcbuildTargetPath.appending(components: "Products", "Debug").pathString)\n"
@@ -197,9 +197,6 @@ final class BuildCommandTests: CommandsTestCase {
197197
xcodeReleaseOutput,
198198
"\(xcbuildTargetPath.appending(components: "Products", "Release").pathString)\n"
199199
)
200-
#else
201-
XCTAssertEqual(xcodeDebugOutput, "\(targetPath.appending("debug").pathString)\n")
202-
XCTAssertEqual(xcodeReleaseOutput, "\(targetPath.appending("release").pathString)\n")
203200
#endif
204201

205202
// Test symlink.

0 commit comments

Comments
 (0)