Skip to content

Add executorFactory option to package manifest. #8443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Sources/PackageDescription/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,23 @@ public struct SwiftSetting: Sendable {
return SwiftSetting(
name: "defaultIsolation", value: [isolationString], condition: condition)
}

/// Defines an `-executor-factory` to pass to the
/// corresponding build tool.
///
/// - Since: First available in PackageDescription 6.2
///
/// - Parameters:
/// - factory: The type name of the executor factory that should be used.
/// - condition: A condition that restricts the application of the build setting.
@available(_PackageDescription, introduced: 6.2)
public static func executorFactory(
_ factory: String,
_ condition: BuildSettingCondition? = nil
) -> SwiftSetting {
return SwiftSetting(
name: "swiftExecutorFactory", value: [name], condition: condition)
}
}

/// A linker build setting.
Expand Down
5 changes: 5 additions & 0 deletions Sources/PackageLoading/ManifestJSONParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,11 @@ extension TargetBuildSettingDescription.Kind {
}

return .defaultIsolation(isolation)
case "swiftExecutorFactory":
guard let value = values.first else {
throw InternalError("invalid (empty) build settings value")
}
return .swiftExecutorFactory(value)
default:
throw InternalError("invalid build setting \(name)")
}
Expand Down
11 changes: 11 additions & 0 deletions Sources/PackageLoading/PackageBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,17 @@ public final class PackageBuilder {
}

values = ["-default-isolation", isolation.rawValue]

case .swiftExecutorFactory(let factory):
switch setting.tool {
case .c, .cxx, .linker:
throw InternalError("only Swift supports executor factory")

case .swift:
decl = .OTHER_SWIFT_FLAGS
}

values = ["-executor-factory ", factory]
}

// Create an assignment for this setting.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ public enum TargetBuildSettingDescription {

case defaultIsolation(DefaultIsolation)

case executorFactory(String)

public var isUnsafeFlags: Bool {
switch self {
case .unsafeFlags(let flags):
// If `.unsafeFlags` is used, but doesn't specify any flags, we treat it the same way as not specifying it.
return !flags.isEmpty
case .headerSearchPath, .define, .linkedLibrary, .linkedFramework, .interoperabilityMode,
.enableUpcomingFeature, .enableExperimentalFeature, .strictMemorySafety, .swiftLanguageMode,
.defaultIsolation:
.defaultIsolation, executorFactory:
return false
}
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/PackageModel/ManifestSourceGeneration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,9 @@ fileprivate extension SourceCodeFragment {
params.append(SourceCodeFragment(from: condition))
}
self.init(enum: setting.kind.name, subnodes: params)
case .swiftExecutorFactory(let factory):
params.append(SourceCodeFragment(string: factory))
self.init(enum: setting.kind.name, subnodes: params)
}
}

Expand Down