@@ -31,6 +31,9 @@ public enum ModuleError: Swift.Error {
31
31
32
32
/// A module was marked as being dependent on an executable.
33
33
case executableAsDependency( module: String , dependency: String )
34
+
35
+ /// The manifest has invalid configuration wrt type of the module.
36
+ case invalidManifestConfig( String , String )
34
37
}
35
38
36
39
extension ModuleError : FixableError {
@@ -42,6 +45,8 @@ extension ModuleError: FixableError {
42
45
return " the package has an unsupported layout, \( type. error) "
43
46
case . executableAsDependency( let module, let dependency) :
44
47
return " the target \( module) cannot have the executable \( dependency) as a dependency "
48
+ case . invalidManifestConfig( let package , let message) :
49
+ return " invalid configuration in ' \( package ) ': \( message) "
45
50
}
46
51
}
47
52
@@ -53,6 +58,8 @@ extension ModuleError: FixableError {
53
58
return type. fix
54
59
case . executableAsDependency( _) :
55
60
return " move the shared logic inside a library, which can be referenced from both the target and the executable "
61
+ case . invalidManifestConfig( _) :
62
+ return nil
56
63
}
57
64
}
58
65
}
@@ -338,6 +345,15 @@ public struct PackageBuilder {
338
345
return [ try CModule ( name: manifest. name, sources: sources, path: packagePath, pkgConfig: pkgConfigPath, providers: manifest. package . providers) ]
339
346
}
340
347
348
+ // At this point the module can't be a system module, make sure manifest doesn't contain
349
+ // system module specific configuration.
350
+ guard manifest. package . pkgConfig == nil else {
351
+ throw ModuleError . invalidManifestConfig ( manifest. name, " pkgConfig should only be used with a System Module Package " )
352
+ }
353
+ guard manifest. package . providers == nil else {
354
+ throw ModuleError . invalidManifestConfig ( manifest. name, " providers should only be used with a System Module Package " )
355
+ }
356
+
341
357
// If everything is excluded, just return an empty array.
342
358
if manifest. package . exclude. contains ( " . " ) {
343
359
return [ ]
0 commit comments