Skip to content

Commit 5722c8e

Browse files
committed
Throw an error for a library clang target if include dir is not found
1 parent c1afc88 commit 5722c8e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/PackageLoading/PackageBuilder.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,10 @@ public final class PackageBuilder {
916916
// First determine the type of module map that will be appropriate for the target based on its header layout.
917917
// FIXME: We should really be checking the target type to see whether it is one that can vend headers, not just check for the existence of the public headers path. But right now we have now way of distinguishing between, for example, a library and an executable. The semantics here should be to only try to detect the header layout of targets that can vend public headers.
918918
let moduleMapType: ModuleMapType
919+
920+
if targetType == .library, !fileSystem.exists(publicHeadersPath) {
921+
throw ModuleError.invalidPublicHeadersDirectory(potentialModule.name)
922+
}
919923
if fileSystem.exists(publicHeadersPath) {
920924
let moduleMapGenerator = ModuleMapGenerator(targetName: potentialModule.name, moduleName: potentialModule.name.spm_mangledToC99ExtendedIdentifier(), publicHeadersDir: publicHeadersPath, fileSystem: fileSystem)
921925
moduleMapType = moduleMapGenerator.determineModuleMapType(diagnostics: diagnostics)

0 commit comments

Comments
 (0)