3
3
import PackageDescription
4
4
import Foundation
5
5
6
+ var unsupportedTests : Set < String > = [ " ObjectiveCNoBridgingStubs " ]
7
+ #if !os(macOS) && !os(iOS) && !os(watchOS) && !os(tvOS)
8
+ unsupportedTests. insert ( " ObjectiveCBridging " )
9
+ unsupportedTests. insert ( " ObjectiveCBridgingStubs " )
10
+ #endif
11
+
6
12
// This is a stop gap hack so we can edit benchmarks in Xcode.
7
13
let singleSourceLibraries : [ String ] = {
8
14
let f = FileManager . `default`
9
15
let dirURL = URL ( fileURLWithPath: " single-source " ) . absoluteURL
10
16
let fileURLs = try ! f. contentsOfDirectory ( at: dirURL,
11
17
includingPropertiesForKeys: nil )
12
- return fileURLs. flatMap { ( path: URL ) -> String ? in
18
+ return fileURLs. compactMap { ( path: URL ) -> String ? in
13
19
let c = path. lastPathComponent. split ( separator: " . " )
14
20
// Too many components. Must be a gyb file.
15
21
if c. count > 2 {
@@ -19,13 +25,15 @@ let singleSourceLibraries: [String] = {
19
25
return nil
20
26
}
21
27
28
+ let s = String ( c [ 0 ] )
29
+
22
30
// We do not support this test.
23
- if c [ 0 ] == " ObjectiveCNoBridgingStubs " {
31
+ if unsupportedTests . contains ( s ) {
24
32
return nil
25
33
}
26
34
27
- assert ( c [ 0 ] != " PrimsSplit " )
28
- return String ( c [ 0 ] )
35
+ assert ( s != " PrimsSplit " )
36
+ return s
29
37
}
30
38
} ( )
31
39
@@ -42,7 +50,9 @@ let multiSourceLibraries: [String] = {
42
50
var products : [ Product ] = [ ]
43
51
products. append ( . library( name: " TestsUtils " , type: . static, targets: [ " TestsUtils " ] ) )
44
52
products. append ( . library( name: " DriverUtils " , type: . static, targets: [ " DriverUtils " ] ) )
53
+ #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
45
54
products. append ( . library( name: " ObjectiveCTests " , type: . static, targets: [ " ObjectiveCTests " ] ) )
55
+ #endif
46
56
products. append ( . executable( name: " SwiftBench " , targets: [ " SwiftBench " ] ) )
47
57
products. append ( . library( name: " PrimsSplit " , type: . static, targets: [ " PrimsSplit " ] ) )
48
58
products += singleSourceLibraries. map { . library( name: $0, type: . static, targets: [ $0] ) }
@@ -56,26 +66,35 @@ targets.append(
56
66
dependencies: [ . target( name: " TestsUtils " ) , " LibProc " ] ,
57
67
path: " utils " ,
58
68
sources: [ " DriverUtils.swift " , " ArgParse.swift " ] ) )
69
+
70
+ var swiftBenchDeps : [ Target . Dependency ] = [ . target( name: " TestsUtils " ) ]
71
+ #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
72
+ swiftBenchDeps. append ( . target( name: " ObjectiveCTests " ) )
73
+ #endif
74
+ swiftBenchDeps. append ( . target( name: " DriverUtils " ) )
75
+ swiftBenchDeps += singleSourceLibraries. map { . target( name: $0) }
76
+ swiftBenchDeps += multiSourceLibraries. map { . target( name: $0) }
77
+
59
78
targets. append (
60
79
. target( name: " SwiftBench " ,
61
- dependencies: [
62
- . target( name: " TestsUtils " ) ,
63
- . target( name: " ObjectiveCTests " ) ,
64
- . target( name: " DriverUtils " ) ,
65
- ] + singleSourceLibraries. map { . target( name: $0) }
66
- + multiSourceLibraries. map { . target( name: $0) } ,
80
+ dependencies: swiftBenchDeps,
67
81
path: " utils " ,
68
82
sources: [ " main.swift " ] ) )
83
+
84
+ #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
69
85
targets. append (
70
86
. target( name: " ObjectiveCTests " ,
71
87
path: " utils/ObjectiveCTests " ,
72
88
publicHeadersPath: " . " ) )
89
+ #endif
90
+
91
+ var singleSourceDeps : [ Target . Dependency ] = [ . target( name: " TestsUtils " ) ]
92
+ #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
93
+ singleSourceDeps. append ( . target( name: " ObjectiveCTests " ) )
94
+ #endif
73
95
targets += singleSourceLibraries. map { x in
74
96
return . target( name: x,
75
- dependencies: [
76
- . target( name: " TestsUtils " ) ,
77
- . target( name: " ObjectiveCTests " ) ,
78
- ] ,
97
+ dependencies: singleSourceDeps,
79
98
path: " single-source " ,
80
99
sources: [ " \( x) .swift " ] )
81
100
}
0 commit comments