Skip to content
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

Make it impossible to create an invalid BuildSettingCondition #4131

Merged
Merged
Changes from all commits
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
37 changes: 29 additions & 8 deletions Sources/PackageDescription/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,42 @@ public struct BuildSettingCondition: Encodable {
self.config = config
}

/// Creates a build setting condition.
///
/// At least one parameter is mandatory.
///
/// - Parameters:
/// - platforms: The applicable platforms for this build setting condition.
/// - configuration: The applicable build configuration for this build setting condition.
@available(_PackageDescription, deprecated: 999.0)
public static func when(
platforms: [Platform]? = nil,
configuration: BuildConfiguration? = nil
) -> BuildSettingCondition {
// FIXME: This should be an error, not a precondition.
precondition(!(platforms == nil && configuration == nil))
return BuildSettingCondition(platforms: platforms, config: configuration)
}

/// Creates a build setting condition.
///
/// - Parameters:
/// - platforms: The applicable platforms for this build setting condition.
/// - configuration: The applicable build configuration for this build setting condition.
@available(_PackageDescription, introduced: 999.0)
public static func when(platforms: [Platform], configuration: BuildConfiguration) -> BuildSettingCondition {
BuildSettingCondition(platforms: platforms, config: configuration)
}

/// Creates a build setting condition.
///
/// - Parameters:
/// - platforms: The applicable platforms for this build setting condition.
@available(_PackageDescription, introduced: 999.0)
public static func when(platforms: [Platform]) -> BuildSettingCondition {
BuildSettingCondition(platforms: platforms, config: .none)
}

/// Creates a build setting condition.
///
/// - Parameters:
/// - configuration: The applicable build configuration for this build setting condition.
@available(_PackageDescription, introduced: 999.0)
public static func when(configuration: BuildConfiguration) -> BuildSettingCondition {
BuildSettingCondition(platforms: .none, config: configuration)
}
}

/// The underlying build setting data.
Expand Down