Skip to content

Commit 581f628

Browse files
committed
Remove duplicate module names in diagnostic about missing dependencies
The Clang tracing information currently shows each header file separately, so if there are multiple headers included from the same module, we get duplicates. We are investigating having Clang trace the modules directly and also investigating de-duplicating these diagnostics across targets, but this is easy to fix in the meantime. rdar://156160529
1 parent f49864e commit 581f628

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Sources/SWBCore/Dependencies.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ public struct ModuleDependenciesContext: Sendable, SerializableCodable {
105105

106106
let moduleDependencyNames = moduleDependencies.map { $0.name }
107107
let fileNames = files.compactMap { findFrameworkName($0) }
108-
let missingDeps = fileNames.filter {
108+
let missingDeps = Set(fileNames.filter {
109109
return !moduleDependencyNames.contains($0)
110110
}.map {
111111
ModuleDependency(name: $0, accessLevel: .Private)
112-
}
112+
})
113113

114114
guard !missingDeps.isEmpty else { return [] }
115115

116116
let behavior: Diagnostic.Behavior = validate == .yesError ? .error : .warning
117117

118-
let fixIt = fixItContext?.makeFixIt(newModules: missingDeps)
118+
let fixIt = fixItContext?.makeFixIt(newModules: Array(missingDeps))
119119
let fixIts = fixIt.map { [$0] } ?? []
120120

121121
let message = "Missing entries in \(BuiltinMacros.MODULE_DEPENDENCIES.name): \(missingDeps.map { $0.asBuildSettingEntryQuotedIfNeeded }.sorted().joined(separator: " "))"

Tests/SWBBuildSystemTests/DependencyValidationTests.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
481481
"CLANG_ENABLE_MODULES": "YES",
482482
"CLANG_ENABLE_EXPLICIT_MODULES": "YES",
483483
"GENERATE_INFOPLIST_FILE": "YES",
484-
"MODULE_DEPENDENCIES": "Foundation",
484+
"MODULE_DEPENDENCIES": "Accelerate",
485485
"VALIDATE_MODULE_DEPENDENCIES": "YES_ERROR",
486486
"SDKROOT": "$(HOST_PLATFORM)",
487487
"SUPPORTED_PLATFORMS": "$(HOST_PLATFORM)",
@@ -507,6 +507,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
507507
try await tester.fs.writeFileContents(SRCROOT.join("Sources/CoreFoo.m")) { contents in
508508
contents <<< """
509509
#include <Foundation/Foundation.h>
510+
#include <Foundation/NSObject.h>
510511
#include <Accelerate/Accelerate.h>
511512
512513
void f0(void) { };
@@ -515,7 +516,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
515516

516517
// Expect complaint about undeclared dependency
517518
try await tester.checkBuild(parameters: BuildParameters(configuration: "Debug"), runDestination: .host, persistent: true) { results in
518-
results.checkError(.contains("Missing entries in MODULE_DEPENDENCIES: Accelerate"))
519+
results.checkError(.contains("Missing entries in MODULE_DEPENDENCIES: Foundation (for task"))
519520
}
520521

521522
// Declaring dependencies resolves the problem

0 commit comments

Comments
 (0)