@@ -199,8 +199,23 @@ public struct TargetSourcesBuilder {
199
199
additionalResources = [ ]
200
200
}
201
201
202
- let headers = pathToRule. lazy. filter { $0. value == . header } . map { $0. key } . sorted ( )
203
- let compilePaths = pathToRule. lazy. filter { $0. value == . compile } . map { $0. key }
202
+ var additionalSources : [ Basics . AbsolutePath ] = [ ]
203
+ var additionalHeaders : [ Basics . AbsolutePath ] = [ ]
204
+ if self . toolsVersion >= . vNext {
205
+ if let declaredSources = self . declaredSources {
206
+ let unhandledSources = self . computeContents ( for: declaredSources. filter { !$0. isDescendant ( of: self . targetPath) } )
207
+ for source in unhandledSources {
208
+ if let ext = source. extension, FileRuleDescription . header. fileTypes. contains ( ext) {
209
+ additionalHeaders. append ( source)
210
+ } else {
211
+ additionalSources. append ( source)
212
+ }
213
+ }
214
+ }
215
+ }
216
+ 1
217
+ let headers = ( pathToRule. lazy. filter { $0. value == . header } . map { $0. key } + additionalHeaders) . sorted ( )
218
+ let compilePaths = ( pathToRule. lazy. filter { $0. value == . compile } . map { $0. key } + additionalSources)
204
219
let sources = Sources ( paths: Array ( compilePaths) . sorted ( ) , root: targetPath)
205
220
let resources : [ Resource ] = ( pathToRule. compactMap { resource ( for: $0. key, with: $0. value) } + additionalResources) . sorted { a, b in
206
221
a. path. pathString < b. path. pathString
@@ -415,9 +430,9 @@ public struct TargetSourcesBuilder {
415
430
///
416
431
/// This avoids recursing into certain directories like exclude or the
417
432
/// ones that should be copied as-is.
418
- public func computeContents( ) -> [ Basics . AbsolutePath ] {
433
+ public func computeContents( for paths : [ Basics . AbsolutePath ] ) -> [ Basics . AbsolutePath ] {
419
434
var contents : [ Basics . AbsolutePath ] = [ ]
420
- var queue : [ Basics . AbsolutePath ] = [ targetPath ]
435
+ var queue : [ Basics . AbsolutePath ] = paths
421
436
422
437
// Ignore xcodeproj and playground directories.
423
438
var ignoredDirectoryExtensions = [ " xcodeproj " , " playground " , " xcworkspace " ]
@@ -519,6 +534,10 @@ public struct TargetSourcesBuilder {
519
534
return contents
520
535
}
521
536
537
+ public func computeContents( ) -> [ Basics . AbsolutePath ] {
538
+ self . computeContents ( for: [ self . targetPath] )
539
+ }
540
+
522
541
public static func computeContents( for generatedFiles: [ Basics . AbsolutePath ] , toolsVersion: ToolsVersion , additionalFileRules: [ FileRuleDescription ] , defaultLocalization: String ? , targetName: String , targetPath: Basics . AbsolutePath , observabilityScope: ObservabilityScope ) -> ( sources: [ Basics . AbsolutePath ] , resources: [ Resource ] ) {
523
542
var sources = [ Basics . AbsolutePath] ( )
524
543
var resources = [ Resource] ( )
0 commit comments