diff --git a/Sources/PackageLoading/PkgConfig.swift b/Sources/PackageLoading/PkgConfig.swift index 68c4086ec98..eef5f11bf35 100644 --- a/Sources/PackageLoading/PkgConfig.swift +++ b/Sources/PackageLoading/PkgConfig.swift @@ -271,7 +271,7 @@ internal struct PkgConfigParser { \(pcFile) """) } - } else { + } else if !arg.isEmpty { // Otherwise it is a dependency. deps.append(arg) } diff --git a/Tests/PackageLoadingTests/PkgConfigParserTests.swift b/Tests/PackageLoadingTests/PkgConfigParserTests.swift index ddb9df983f3..2e6f22780b2 100644 --- a/Tests/PackageLoadingTests/PkgConfigParserTests.swift +++ b/Tests/PackageLoadingTests/PkgConfigParserTests.swift @@ -105,6 +105,20 @@ final class PkgConfigParserTests: XCTestCase { } } + func testDummyDependency() throws { + try loadPCFile("dummy_dependency.pc") { parser in + XCTAssertEqual(parser.variables, [ + "prefix": "/usr/local/bin", + "exec_prefix": "/usr/local/bin", + "pcfiledir": parser.pcFile.parentDirectory.pathString, + "pc_sysrootdir": AbsolutePath.root.pathString + ]) + XCTAssertEqual(parser.dependencies, ["pango", "fontconfig"]) + XCTAssertEqual(parser.cFlags, []) + XCTAssertEqual(parser.libs, ["-L/usr/local/bin", "-lpangoft2-1.0"]) + } + } + /// Test custom search path get higher priority for locating pc files. func testCustomPcFileSearchPath() throws { let observability = ObservabilitySystem.makeForTesting() diff --git a/Tests/PackageLoadingTests/pkgconfigInputs/dummy_dependency.pc b/Tests/PackageLoadingTests/pkgconfigInputs/dummy_dependency.pc new file mode 100644 index 00000000000..c4ae253c81a --- /dev/null +++ b/Tests/PackageLoadingTests/pkgconfigInputs/dummy_dependency.pc @@ -0,0 +1,7 @@ +prefix=/usr/local/bin +exec_prefix=${prefix} + +#some comment + +Requires: pango, , fontconfig >= 2.13.0 +Libs:-L${prefix} -lpangoft2-1.0