Skip to content

Commit 1b292e3

Browse files
Georgeaciidgh
authored andcommitted
[PkgConfig] Do not emit 'pkg-config not installed' diagnostic unless we failed to find a pc file
1 parent 99a7d06 commit 1b292e3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/SPMUtility/PkgConfig.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct PCFileFinder {
4545

4646
/// Cached results of locations `pkg-config` will search for `.pc` files
4747
private(set) static var pkgConfigPaths: [AbsolutePath]? // FIXME: @testable(internal)
48+
private static var shouldEmitPkgConfigPathsDiagnostic = false
4849

4950
/// The built-in search path list.
5051
///
@@ -75,7 +76,7 @@ struct PCFileFinder {
7576
args: pkgConfigPath, "--variable", "pc_path", "pkg-config").spm_chomp()
7677
PCFileFinder.pkgConfigPaths = searchPaths.split(separator: ":").map({ AbsolutePath(String($0)) })
7778
} catch {
78-
diagnostics.emit(data: PkgConfigExecutionDiagnostic())
79+
PCFileFinder.shouldEmitPkgConfigPathsDiagnostic = true
7980
PCFileFinder.pkgConfigPaths = []
8081
}
8182
}
@@ -95,6 +96,10 @@ struct PCFileFinder {
9596
return pcFile
9697
}
9798
}
99+
if PCFileFinder.shouldEmitPkgConfigPathsDiagnostic {
100+
PCFileFinder.shouldEmitPkgConfigPathsDiagnostic = false
101+
diagnostics.emit(data: PkgConfigExecutionDiagnostic())
102+
}
98103
throw PkgConfigError.couldNotFindConfigFile
99104
}
100105
}

0 commit comments

Comments
 (0)