Skip to content

Commit a497441

Browse files
committed
build: define build path structure in BuildSystemProvider.Kind
There are a few places that check the BuildSystemProvider.Kind is Xcode to determine the build directory structure. With the upcoming Swift Build integration, which uses the "Xcode path" structure, we would need to update all instances to check the two build system provider kinds. Add an extension on the BuildSystemProvider.Kind that create a boolean variable `useXcodeBuildEngine`, which determines whether the build system should use the xcode path structure or not. In addition, update the code that requires a "isXcodeBuildSystemEnabled" to return this build system provider variable. This will hopefully help address #8272 when #8271, where it adds `case .swiftbuild: return true` to the `useXcodeBuildEngine`
1 parent 71ab073 commit a497441

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

Sources/CoreCommands/SwiftCommandState.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ public final class SwiftCommandState {
441441
self.observabilityHandler.progress,
442442
self.observabilityHandler.prompt
443443
)
444-
let isXcodeBuildSystemEnabled = self.options.build.buildSystem == .xcode
444+
let isXcodeBuildSystemEnabled = self.options.build.buildSystem.usesXcodeBuildEngine
445445
let workspace = try Workspace(
446446
fileSystem: self.fileSystem,
447447
location: .init(
@@ -459,7 +459,7 @@ public final class SwiftCommandState {
459459
configuration: .init(
460460
skipDependenciesUpdates: options.resolver.skipDependencyUpdate,
461461
prefetchBasedOnResolvedFile: options.resolver.shouldEnableResolverPrefetching,
462-
shouldCreateMultipleTestProducts: toolWorkspaceConfiguration.wantsMultipleTestProducts || options.build.buildSystem == .xcode,
462+
shouldCreateMultipleTestProducts: toolWorkspaceConfiguration.wantsMultipleTestProducts || options.build.buildSystem.usesXcodeBuildEngine,
463463
createREPLProduct: toolWorkspaceConfiguration.wantsREPLProduct,
464464
additionalFileRules: isXcodeBuildSystemEnabled ? FileRuleDescription.xcbuildFileTypes : FileRuleDescription.swiftpmFileTypes,
465465
sharedDependenciesCacheEnabled: self.options.caching.useDependenciesCache,
@@ -795,7 +795,7 @@ public final class SwiftCommandState {
795795
workers: options.build.jobs ?? UInt32(ProcessInfo.processInfo.activeProcessorCount),
796796
sanitizers: options.build.enabledSanitizers,
797797
indexStoreMode: options.build.indexStoreMode.buildParameter,
798-
isXcodeBuildSystemEnabled: options.build.buildSystem == .xcode,
798+
isXcodeBuildSystemEnabled: options.build.buildSystem.usesXcodeBuildEngine,
799799
prepareForIndexing: prepareForIndexingMode,
800800
debuggingParameters: .init(
801801
debugInfoFormat: options.build.debugInfoFormat.buildParameter,

Sources/SPMBuildCore/BuildSystem/BuildSystem.swift

+8
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ public struct BuildSystemProvider {
168168
}
169169
}
170170

171+
extension BuildSystemProvider.Kind {
172+
public var usesXcodeBuildEngine: Bool {
173+
switch self {
174+
case .native: return false
175+
case .xcode: return true
176+
}
177+
}
178+
}
171179
private enum Errors: Swift.Error {
172180
case buildSystemProviderNotRegistered(kind: BuildSystemProvider.Kind)
173181
}

Sources/SPMBuildCore/Triple+Extensions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ extension Triple {
2727
// Use "apple" as the subdirectory because in theory Xcode build system
2828
// can be used to build for any Apple platform and it has its own
2929
// conventions for build subpaths based on platforms.
30-
buildSystem == .xcode ? "apple" : self.platformBuildPathComponent
30+
buildSystem.usesXcodeBuildEngine ? "apple" : self.platformBuildPathComponent
3131
}
3232
}

Sources/swift-bootstrap/main.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ struct SwiftBootstrapBuildTool: AsyncParsableCommand {
289289
triple: self.hostToolchain.targetTriple,
290290
flags: buildFlags,
291291
architectures: architectures,
292-
isXcodeBuildSystemEnabled: buildSystem == .xcode,
292+
isXcodeBuildSystemEnabled: buildSystem.usesXcodeBuildEngine,
293293
driverParameters: .init(
294294
explicitTargetDependencyImportCheckingMode: explicitTargetDependencyImportCheck == .error ? .error : .none,
295295
useIntegratedSwiftDriver: useIntegratedSwiftDriver,

0 commit comments

Comments
 (0)