Skip to content

Commit 14d50db

Browse files
author
Luke Daley
committed
Disable dependency verification if no dependencies are declared
1 parent 32fc9d1 commit 14d50db

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

Sources/SWBCore/Dependencies.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,8 @@ public struct DependencySettings : Serializable, Sendable, Encodable {
2323
public let dependencies: OrderedSet<String>
2424
public let verification: Bool
2525

26-
27-
public init(_ scope: MacroEvaluationScope) {
28-
self.init(
29-
dependencies: scope.evaluate(BuiltinMacros.DEPENDENCIES),
30-
verification: scope.evaluate(BuiltinMacros.DEPENDENCIES_VERIFICATION)
31-
)
32-
}
33-
3426
public init(
35-
dependencies: [String],
27+
dependencies: any Sequence<String>,
3628
verification: Bool
3729
) {
3830
self.dependencies = OrderedSet(dependencies)
@@ -51,7 +43,22 @@ public struct DependencySettings : Serializable, Sendable, Encodable {
5143
self.dependencies = try deserializer.deserialize()
5244
self.verification = try deserializer.deserialize()
5345
}
46+
}
5447

48+
extension DependencySettings {
49+
public init(_ scope: MacroEvaluationScope) {
50+
let dependencies = scope.evaluate(BuiltinMacros.DEPENDENCIES)
51+
52+
// We cannot distinguish between "DEPENDENCIES" not set and set to an empty list.
53+
// Turn verification off it we have an empty list, assuming that it is not set.
54+
// This means that there is no way at the moment to declare that a project with no dependencies should have verification enabled.
55+
let verification = !dependencies.isEmpty && scope.evaluate(BuiltinMacros.DEPENDENCIES_VERIFICATION)
56+
57+
self.init(
58+
dependencies: dependencies,
59+
verification: verification
60+
)
61+
}
5562
}
5663

5764
// Task-specific settings

0 commit comments

Comments
 (0)