Skip to content

Commit 60bac7b

Browse files
committed
Flip the --disable-explicit-target-dependency-import-checking option to an opt-in enable option.
While we work on optimizing incremental build performance of this check, it would be nice to have it as an opt-in option.
1 parent 02c8558 commit 60bac7b

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

Sources/Build/BuildOperation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
133133
// Emit a warning if a target imports another target in this build
134134
// without specifying it as a dependency in the manifest
135135
private func verifyTargetImports(in description: BuildDescription) throws {
136-
guard !description.disableExplicitTargetDependencyImportChecking else {
136+
guard description.enableExplicitTargetDependencyImportChecking else {
137137
return
138138
}
139139
// Ensure the compiler supports the import-scan operation
@@ -193,7 +193,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
193193
try verifyTargetImports(in: buildDescription)
194194

195195
// Create the build system.
196-
let buildSystem = try createBuildSystem(with: buildDescription)
196+
let buildSystem = try createBuildSystem(buildDescription: buildDescription)
197197
self.buildSystem = buildSystem
198198

199199
// Perform the build.

Sources/Build/BuildOperationBuildSystemDelegateHandler.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ public struct BuildDescription: Codable {
205205
/// The map of copy commands.
206206
let copyCommands: [BuildManifest.CmdName: LLBuildManifest.CopyTool]
207207

208-
/// A flag that inidcates this build should skip checking whether targets only import
208+
/// A flag that inidcates this build should perform a check for whether targets only import
209209
/// their explicitly-declared dependencies
210-
let disableExplicitTargetDependencyImportChecking: Bool
210+
let enableExplicitTargetDependencyImportChecking: Bool
211211

212212
/// Every target's set of dependencies.
213213
let targetDependencyMap: [TargetName: [TargetName]]
@@ -232,7 +232,7 @@ public struct BuildDescription: Codable {
232232
self.swiftFrontendCommands = swiftFrontendCommands
233233
self.testDiscoveryCommands = testDiscoveryCommands
234234
self.copyCommands = copyCommands
235-
self.disableExplicitTargetDependencyImportChecking = plan.buildParameters.disableExplicitTargetDependencyImportChecking
235+
self.enableExplicitTargetDependencyImportChecking = plan.buildParameters.enableExplicitTargetDependencyImportChecking
236236
self.targetDependencyMap = try plan.targets.reduce(into: [TargetName: [TargetName]]()) {
237237
let deps = try $1.target.recursiveTargetDependencies().map { $0.c99name }
238238
$0[$1.target.c99name] = deps

Sources/Commands/Options.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ public struct SwiftToolOptions: ParsableArguments {
297297
@Flag()
298298
var useIntegratedSwiftDriver: Bool = false
299299

300-
/// A flag that inidcates this build should skip checking whether targets only import
300+
/// A flag that inidcates this build should check whether targets only import
301301
/// their explicitly-declared dependencies
302302
@Flag()
303-
var disableExplicitTargetDependencyImportChecking: Bool = false
303+
var enableExplicitTargetDependencyImportChecking: Bool = false
304304

305305
/// Whether to use the explicit module build flow (with the integrated driver)
306306
@Flag(name: .customLong("experimental-explicit-module-build"))

Sources/Commands/SwiftTool.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ public class SwiftTool {
914914
printManifestGraphviz: options.printManifestGraphviz,
915915
forceTestDiscovery: options.enableTestDiscovery, // backwards compatibility, remove with --enable-test-discovery
916916
isTTY: isTTY,
917-
disableExplicitTargetDependencyImportChecking: options.disableExplicitTargetDependencyImportChecking
917+
enableExplicitTargetDependencyImportChecking: options.enableExplicitTargetDependencyImportChecking
918918
)
919919
})
920920
}()

Sources/SPMBuildCore/BuildParameters.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ public struct BuildParameters: Encodable {
127127
/// Whether to use the explicit module build flow (with the integrated driver)
128128
public var useExplicitModuleBuild: Bool
129129

130-
/// A flag that inidcates this build should skip checking whether targets only import
130+
/// A flag that inidcates this build should check whether targets only import
131131
/// their explicitly-declared dependencies
132-
public var disableExplicitTargetDependencyImportChecking: Bool
132+
public var enableExplicitTargetDependencyImportChecking: Bool
133133

134134
/// Whether to output a graphviz file visualization of the combined job graph for all targets
135135
public var printManifestGraphviz: Bool
@@ -203,7 +203,7 @@ public struct BuildParameters: Encodable {
203203
enableTestability: Bool? = nil,
204204
forceTestDiscovery: Bool = false,
205205
isTTY: Bool = false,
206-
disableExplicitTargetDependencyImportChecking: Bool = false
206+
enableExplicitTargetDependencyImportChecking: Bool = false
207207
) {
208208
let triple = destinationTriple ?? .getHostTriple(usingSwiftCompiler: toolchain.swiftCompiler)
209209

@@ -235,7 +235,7 @@ public struct BuildParameters: Encodable {
235235
// decide if to enable the use of test manifests based on platform. this is likely to change in the future
236236
self.testDiscoveryStrategy = triple.isDarwin() ? .objectiveC : .manifest(generate: forceTestDiscovery)
237237
self.isTTY = isTTY
238-
self.disableExplicitTargetDependencyImportChecking = disableExplicitTargetDependencyImportChecking
238+
self.enableExplicitTargetDependencyImportChecking = enableExplicitTargetDependencyImportChecking
239239
}
240240

241241
/// The path to the build directory (inside the data directory).

Tests/CommandsTests/BuildToolTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ final class BuildToolTests: XCTestCase {
8080
#endif
8181
fixture(name: "Miscellaneous/ImportOfMissingDependency") { path in
8282
let fullPath = resolveSymlinks(path)
83-
XCTAssertThrowsError(try build([], packagePath: fullPath)) { error in
83+
XCTAssertThrowsError(try build(["--enable-explicit-target-dependency-import-checking"], packagePath: fullPath)) { error in
8484
guard case SwiftPMProductError.executionFailure(_, _, let stderr) = error else {
8585
XCTFail()
8686
return
@@ -92,7 +92,7 @@ final class BuildToolTests: XCTestCase {
9292
// Verify that the disable toggle works as expected
9393
fixture(name: "Miscellaneous/ImportOfMissingDependency") { path in
9494
let fullPath = resolveSymlinks(path)
95-
XCTAssertThrowsError(try build(["--disable-explicit-target-dependency-import-checking"], packagePath: fullPath)) { error in
95+
XCTAssertThrowsError(try build([], packagePath: fullPath)) { error in
9696
guard case SwiftPMProductError.executionFailure(_, _, let stderr) = error else {
9797
XCTFail()
9898
return

0 commit comments

Comments
 (0)