Skip to content

Commit a4114eb

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 01eb92d commit a4114eb

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

Sources/Build/BuildOperation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
161161
// Emit a warning if a target imports another target in this build
162162
// without specifying it as a dependency in the manifest
163163
private func verifyTargetImports(in description: BuildDescription) throws {
164-
guard !description.disableExplicitTargetDependencyImportChecking else {
164+
guard description.enableExplicitTargetDependencyImportChecking else {
165165
return
166166
}
167167
// Ensure the compiler supports the import-scan operation

Sources/Build/BuildOperationBuildSystemDelegateHandler.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ public struct BuildDescription: Codable {
226226
/// The map of copy commands.
227227
let copyCommands: [BuildManifest.CmdName: LLBuildManifest.CopyTool]
228228

229-
/// A flag that inidcates this build should skip checking whether targets only import
229+
/// A flag that inidcates this build should perform a check for whether targets only import
230230
/// their explicitly-declared dependencies
231-
let disableExplicitTargetDependencyImportChecking: Bool
231+
let enableExplicitTargetDependencyImportChecking: Bool
232232

233233
/// Every target's set of dependencies.
234234
let targetDependencyMap: [TargetName: [TargetName]]
@@ -257,7 +257,7 @@ public struct BuildDescription: Codable {
257257
self.swiftFrontendCommands = swiftFrontendCommands
258258
self.testDiscoveryCommands = testDiscoveryCommands
259259
self.copyCommands = copyCommands
260-
self.disableExplicitTargetDependencyImportChecking = plan.buildParameters.disableExplicitTargetDependencyImportChecking
260+
self.enableExplicitTargetDependencyImportChecking = plan.buildParameters.enableExplicitTargetDependencyImportChecking
261261
self.targetDependencyMap = try plan.targets.reduce(into: [TargetName: [TargetName]]()) {
262262
let deps = try $1.target.recursiveTargetDependencies().map { $0.c99name }
263263
$0[$1.target.c99name] = deps
@@ -270,8 +270,8 @@ public struct BuildDescription: Codable {
270270
}
271271
targetCommandLines[target.c99name] =
272272
try desc.emitCommandLine(scanInvocation: true) + ["-driver-use-frontend-path",
273-
plan.buildParameters.toolchain.swiftCompiler.pathString]
274-
if desc.testDiscoveryTarget {
273+
plan.buildParameters.toolchain.swiftCompilerPath.pathString]
274+
if desc.isTestDiscoveryTarget {
275275
generatedSourceTargets.append(target.c99name)
276276
}
277277
}

Sources/Commands/SwiftTool.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,10 @@ public class SwiftTool {
792792
enableParseableModuleInterfaces: options.build.shouldEnableParseableModuleInterfaces,
793793
emitSwiftModuleSeparately: options.build.emitSwiftModuleSeparately,
794794
useIntegratedSwiftDriver: options.build.useIntegratedSwiftDriver,
795-
disableExplicitTargetDependencyImportChecking: build.disableExplicitTargetDependencyImportChecking,
796795
useExplicitModuleBuild: options.build.useExplicitModuleBuild,
797796
isXcodeBuildSystemEnabled: options.build.buildSystem == .xcode,
798797
forceTestDiscovery: options.build.enableTestDiscovery, // backwards compatibility, remove with --enable-test-discovery
798+
enableExplicitTargetDependencyImportChecking: options.build.enableExplicitTargetDependencyImportChecking,
799799
linkerDeadStrip: options.linker.linkerDeadStrip,
800800
verboseOutput: self.logLevel <= .info
801801
)

Sources/SPMBuildCore/BuildParameters.swift

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

131-
/// A flag that inidcates this build should skip checking whether targets only import
131+
/// A flag that inidcates this build should check whether targets only import
132132
/// their explicitly-declared dependencies
133-
public var disableExplicitTargetDependencyImportChecking: Bool
133+
public var enableExplicitTargetDependencyImportChecking: Bool
134134

135135
/// Whether to create dylibs for dynamic library products.
136136
public var shouldCreateDylibForDynamicProducts: Bool
@@ -203,7 +203,7 @@ public struct BuildParameters: Encodable {
203203
isXcodeBuildSystemEnabled: Bool = false,
204204
enableTestability: Bool? = nil,
205205
forceTestDiscovery: Bool = false,
206-
disableExplicitTargetDependencyImportChecking: Bool = false
206+
enableExplicitTargetDependencyImportChecking: Bool = false,
207207
linkerDeadStrip: Bool = true,
208208
colorizedOutput: Bool = false,
209209
verboseOutput: Bool = false
@@ -241,7 +241,7 @@ public struct BuildParameters: Encodable {
241241
self.enableTestability = enableTestability ?? (.debug == configuration)
242242
// decide if to enable the use of test manifests based on platform. this is likely to change in the future
243243
self.testDiscoveryStrategy = triple.isDarwin() ? .objectiveC : .manifest(generate: forceTestDiscovery)
244-
self.disableExplicitTargetDependencyImportChecking = disableExplicitTargetDependencyImportChecking
244+
self.enableExplicitTargetDependencyImportChecking = enableExplicitTargetDependencyImportChecking
245245
self.linkerDeadStrip = linkerDeadStrip
246246
self.colorizedOutput = colorizedOutput
247247
self.verboseOutput = verboseOutput

Tests/CommandsTests/BuildToolTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ final class BuildToolTests: CommandsTestCase {
7979
#if swift(<5.5)
8080
try XCTSkipIf(true, "skipping because host compiler doesn't support '-import-prescan'")
8181
#endif
82-
fixture(name: "Miscellaneous/ImportOfMissingDependency") { path in
82+
try fixture(name: "Miscellaneous/ImportOfMissingDependency") { path in
8383
let fullPath = resolveSymlinks(path)
84-
XCTAssertThrowsError(try build([], packagePath: fullPath)) { error in
84+
XCTAssertThrowsError(try build(["--enable-explicit-target-dependency-import-checking"], packagePath: fullPath)) { error in
8585
guard case SwiftPMProductError.executionFailure(_, _, let stderr) = error else {
8686
XCTFail()
8787
return
@@ -91,9 +91,9 @@ final class BuildToolTests: CommandsTestCase {
9191
}
9292

9393
// Verify that the disable toggle works as expected
94-
fixture(name: "Miscellaneous/ImportOfMissingDependency") { path in
94+
try fixture(name: "Miscellaneous/ImportOfMissingDependency") { path in
9595
let fullPath = resolveSymlinks(path)
96-
XCTAssertThrowsError(try build(["--disable-explicit-target-dependency-import-checking"], packagePath: fullPath)) { error in
96+
XCTAssertThrowsError(try build([], packagePath: fullPath)) { error in
9797
guard case SwiftPMProductError.executionFailure(_, _, let stderr) = error else {
9898
XCTFail()
9999
return

0 commit comments

Comments
 (0)