-
Notifications
You must be signed in to change notification settings - Fork 91
Assert that only declared dependencies are used when compiling/linking #466
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
Open
ldaley
wants to merge
18
commits into
swiftlang:main
Choose a base branch
from
ldaley:ldaley/dependency-verification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
32fc9d1
Allow logical dependencies to be forward-declared and verified at use…
14d50db
Disable dependency verification if no dependencies are declared
bd4390d
Remove redundant import
38cb663
Add missing method impl in test source
47c7f37
Add initial unit and task construction tests for task wiring
1d1f7bb
Fix serialization asymmetry
e9ebeb9
Formatting: Remove unnecessary parens
00dd79e
Formatting
b6f8c48
Further encapsulate “logical dependency inference”
4f78193
Declare outer trace env vars as final
32494d0
Simplify implementation of dependency verification dynamic default
fa6ac03
Add initial build operation test
4e61f77
Expand build operation test
1542447
Test fix
4a4258a
Restrict tests to macOS
d593291
Use next index for task action, instead of jumping over test registra…
2338967
Disambiguate task action tool identifier
e5bb1a5
Don't attempt verification if linker does not support trace
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift open source project | ||
// | ||
// Copyright (c) 2025 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See http://swift.org/LICENSE.txt for license information | ||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
public import SWBUtil | ||
public import SWBMacro | ||
|
||
import Foundation | ||
|
||
// Global/target dependency settings | ||
public struct DependencySettings: Serializable, Sendable, Encodable { | ||
public let dependencies: [String] // lexicographically ordered and uniqued | ||
public let verification: Bool | ||
|
||
public init( | ||
dependencies: any Sequence<String>, | ||
verification: Bool | ||
) { | ||
self.dependencies = Array(OrderedSet(dependencies).sorted()) | ||
self.verification = verification | ||
} | ||
|
||
public func serialize<T: Serializer>(to serializer: T) { | ||
serializer.serializeAggregate(2) { | ||
serializer.serialize(dependencies) | ||
serializer.serialize(verification) | ||
} | ||
} | ||
|
||
public init(from deserializer: any Deserializer) throws { | ||
try deserializer.beginAggregate(2) | ||
self.dependencies = try deserializer.deserialize() | ||
self.verification = try deserializer.deserialize() | ||
} | ||
} | ||
|
||
extension DependencySettings { | ||
public init(_ scope: MacroEvaluationScope) { | ||
let dependencies = scope.evaluate(BuiltinMacros.DEPENDENCIES) | ||
self.init( | ||
dependencies: dependencies, | ||
verification: scope.evaluate(BuiltinMacros.DEPENDENCIES_VERIFICATION) | ||
.isEnabled(onNotSet: !dependencies.isEmpty), | ||
) | ||
} | ||
} | ||
|
||
// Task-specific settings | ||
public struct TaskDependencySettings: Serializable, Sendable, Encodable { | ||
|
||
public let traceFile: Path | ||
public let dependencySettings: DependencySettings | ||
|
||
init(traceFile: Path, dependencySettings: DependencySettings) { | ||
assert(!traceFile.isEmpty, "traceFile should never be empty") | ||
self.traceFile = traceFile | ||
self.dependencySettings = dependencySettings | ||
} | ||
|
||
public func serialize<T: Serializer>(to serializer: T) { | ||
serializer.serializeAggregate(2) { | ||
serializer.serialize(traceFile) | ||
serializer.serialize(dependencySettings) | ||
} | ||
} | ||
|
||
public init(from deserializer: any Deserializer) throws { | ||
try deserializer.beginAggregate(2) | ||
self.traceFile = try deserializer.deserialize() | ||
self.dependencySettings = try deserializer.deserialize() | ||
} | ||
|
||
func signatureData() -> String { | ||
return "verify:\(dependencySettings.verification),deps:\(dependencySettings.dependencies.joined(separator: ":"))" | ||
} | ||
|
||
} | ||
|
||
// Protocol for task payloads | ||
public protocol TaskDependencySettingsPayload { | ||
var taskDependencySettings: TaskDependencySettings? { get } | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.