Skip to content

Commit 8f3b288

Browse files
neonichujakepetroules
authored andcommitted
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 e988969 commit 8f3b288

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

Sources/CoreCommands/Options.swift

-5
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,8 @@ public struct BuildOptions: ParsableArguments {
472472
public var debugInfoFormat: DebugInfoFormat = .dwarf
473473

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

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

Sources/XCBuildSupport/XcodeBuildSystem.swift

+2-2
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

+1-4
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)