Skip to content

Remove duplicate module names in diagnostic about missing dependencies #663

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/SWBCore/Dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ public struct ModuleDependenciesContext: Sendable, SerializableCodable {

let moduleDependencyNames = moduleDependencies.map { $0.name }
let fileNames = files.compactMap { findFrameworkName($0) }
let missingDeps = fileNames.filter {
let missingDeps = Set(fileNames.filter {
return !moduleDependencyNames.contains($0)
}.map {
ModuleDependency(name: $0, accessLevel: .Private)
}
})

guard !missingDeps.isEmpty else { return [] }

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

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

let message = "Missing entries in \(BuiltinMacros.MODULE_DEPENDENCIES.name): \(missingDeps.map { $0.asBuildSettingEntryQuotedIfNeeded }.sorted().joined(separator: " "))"
Expand Down
5 changes: 3 additions & 2 deletions Tests/SWBBuildSystemTests/DependencyValidationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
"CLANG_ENABLE_MODULES": "YES",
"CLANG_ENABLE_EXPLICIT_MODULES": "YES",
"GENERATE_INFOPLIST_FILE": "YES",
"MODULE_DEPENDENCIES": "Foundation",
"MODULE_DEPENDENCIES": "Accelerate",
"VALIDATE_MODULE_DEPENDENCIES": "YES_ERROR",
"SDKROOT": "$(HOST_PLATFORM)",
"SUPPORTED_PLATFORMS": "$(HOST_PLATFORM)",
Expand All @@ -507,6 +507,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
try await tester.fs.writeFileContents(SRCROOT.join("Sources/CoreFoo.m")) { contents in
contents <<< """
#include <Foundation/Foundation.h>
#include <Foundation/NSObject.h>
#include <Accelerate/Accelerate.h>

void f0(void) { };
Expand All @@ -515,7 +516,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {

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

// Declaring dependencies resolves the problem
Expand Down