@@ -23,10 +23,27 @@ import struct TSCBasic.RelativePath
2323import var TSCBasic. localFileSystem
2424import var TSCBasic. stderrStream
2525
26- func getModuleFlags( _ path: VirtualPath , _ ignorable: Bool ) throws -> [ String ] {
26+ enum InterfaceFlagKind {
27+ case regular, ignorable, ignorablePrivate
28+
29+ var string : String {
30+ switch self {
31+ case . regular:
32+ return " swift-module-flags "
33+ case . ignorable:
34+ return " swift-module-flags-ignorable "
35+ case . ignorablePrivate:
36+ return " swift-module-flags-ignorable-private "
37+ }
38+ }
39+ }
40+
41+ func getModuleFlags( _ path: VirtualPath ,
42+ _ flagKind: InterfaceFlagKind ) throws -> [ String ] {
2743 let data = try localFileSystem. readFileContents ( path) . cString
2844 let myStrings = data. components ( separatedBy: . newlines)
29- let prefix = ignorable ? " // swift-module-flags-ignorable: " : " // swift-module-flags: "
45+
46+ let prefix = " // " + flagKind. string + " : "
3047 if let argLine = myStrings. first ( where: { $0. hasPrefix ( prefix) } ) {
3148 return argLine. dropFirst ( prefix. count) . components ( separatedBy: " " )
3249 }
@@ -35,8 +52,9 @@ func getModuleFlags(_ path: VirtualPath, _ ignorable: Bool) throws -> [String] {
3552
3653@_spi ( Testing) public func getAllModuleFlags( _ path: VirtualPath ) throws -> [ String ] {
3754 var allFlags : [ String ] = [ ]
38- allFlags. append ( contentsOf: try getModuleFlags ( path, true ) )
39- allFlags. append ( contentsOf: try getModuleFlags ( path, false ) )
55+ allFlags. append ( contentsOf: try getModuleFlags ( path, . regular) )
56+ allFlags. append ( contentsOf: try getModuleFlags ( path, . ignorable) )
57+ allFlags. append ( contentsOf: try getModuleFlags ( path, . ignorablePrivate) )
4058 return allFlags;
4159}
4260
0 commit comments