@@ -514,14 +514,15 @@ final class SwiftDriverTests: XCTestCase {
514
514
// Forwarding of arguments.
515
515
var driver2 = try Driver ( args: [ " swiftc " , " -color-diagnostics " , " foo.swift " , " bar.swift " , " -working-directory " , " /tmp " , " -api-diff-data-file " , " diff.txt " , " -Xfrontend " , " -HI " , " -no-color-diagnostics " , " -g " ] )
516
516
let plannedJobs2 = try driver2. planBuild ( )
517
- XCTAssert ( plannedJobs2 [ 0 ] . commandLine. contains ( Job . ArgTemplate. path ( . absolute( try AbsolutePath ( validating: " /tmp/diff.txt " ) ) ) ) )
518
- XCTAssert ( plannedJobs2 [ 0 ] . commandLine. contains ( . flag( " -HI " ) ) )
519
- XCTAssert ( !plannedJobs2[ 0 ] . commandLine. contains ( . flag( " -Xfrontend " ) ) )
520
- XCTAssert ( plannedJobs2 [ 0 ] . commandLine. contains ( . flag( " -no-color-diagnostics " ) ) )
521
- XCTAssert ( !plannedJobs2[ 0 ] . commandLine. contains ( . flag( " -color-diagnostics " ) ) )
522
- XCTAssert ( plannedJobs2 [ 0 ] . commandLine. contains ( . flag( " -target " ) ) )
523
- XCTAssert ( plannedJobs2 [ 0 ] . commandLine. contains ( . flag( driver2. targetTriple. triple) ) )
524
- XCTAssert ( plannedJobs2 [ 0 ] . commandLine. contains ( . flag( " -enable-anonymous-context-mangled-names " ) ) )
517
+ let compileJob = plannedJobs2. first ( where: { $0. kind == . compile} ) !
518
+ XCTAssert ( compileJob. commandLine. contains ( Job . ArgTemplate. path ( . absolute( try AbsolutePath ( validating: " /tmp/diff.txt " ) ) ) ) )
519
+ XCTAssert ( compileJob. commandLine. contains ( . flag( " -HI " ) ) )
520
+ XCTAssert ( !compileJob. commandLine. contains ( . flag( " -Xfrontend " ) ) )
521
+ XCTAssert ( compileJob. commandLine. contains ( . flag( " -no-color-diagnostics " ) ) )
522
+ XCTAssert ( !compileJob. commandLine. contains ( . flag( " -color-diagnostics " ) ) )
523
+ XCTAssert ( compileJob. commandLine. contains ( . flag( " -target " ) ) )
524
+ XCTAssert ( compileJob. commandLine. contains ( . flag( driver2. targetTriple. triple) ) )
525
+ XCTAssert ( compileJob. commandLine. contains ( . flag( " -enable-anonymous-context-mangled-names " ) ) )
525
526
526
527
var driver3 = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -emit-library " , " -module-name " , " Test " ] )
527
528
let plannedJobs3 = try driver3. planBuild ( )
@@ -757,7 +758,7 @@ final class SwiftDriverTests: XCTestCase {
757
758
}
758
759
759
760
func testMergeModuleEmittingDependencies( ) throws {
760
- var driver1 = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Foo " , " -emit-dependencies " , " -emit-module " , " -serialize-diagnostics " , " -driver-filelist-threshold=9999 " ] )
761
+ var driver1 = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Foo " , " -emit-dependencies " , " -emit-module " , " -serialize-diagnostics " , " -driver-filelist-threshold=9999 " , " -no-emit-module-separately " ] )
761
762
let plannedJobs = try driver1. planBuild ( ) . removingAutolinkExtractJobs ( )
762
763
XCTAssertTrue ( plannedJobs [ 0 ] . kind == . compile)
763
764
XCTAssertTrue ( plannedJobs [ 1 ] . kind == . compile)
@@ -770,6 +771,15 @@ final class SwiftDriverTests: XCTestCase {
770
771
XCTAssertFalse ( plannedJobs [ 2 ] . commandLine. contains ( . flag( " -serialize-diagnostics-path " ) ) )
771
772
}
772
773
774
+ func testEmitModuleEmittingDependencies( ) throws {
775
+ var driver1 = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Foo " , " -emit-dependencies " , " -emit-module " , " -serialize-diagnostics " , " -driver-filelist-threshold=9999 " , " -experimental-emit-module-separately " ] )
776
+ let plannedJobs = try driver1. planBuild ( ) . removingAutolinkExtractJobs ( )
777
+ XCTAssertEqual ( plannedJobs. count, 1 )
778
+ XCTAssertTrue ( plannedJobs [ 0 ] . kind == . emitModule)
779
+ XCTAssertTrue ( plannedJobs [ 0 ] . commandLine. contains ( . flag( " -emit-dependencies-path " ) ) )
780
+ XCTAssertTrue ( plannedJobs [ 0 ] . commandLine. contains ( . flag( " -serialize-diagnostics-path " ) ) )
781
+ }
782
+
773
783
func testReferenceDependencies( ) throws {
774
784
var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " -incremental " ] )
775
785
let plannedJobs = try driver. planBuild ( )
@@ -2112,7 +2122,7 @@ final class SwiftDriverTests: XCTestCase {
2112
2122
2113
2123
func testMergeModulesOnly( ) throws {
2114
2124
do {
2115
- var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Test " , " -emit-module " , " -disable-bridging-pch " , " -import-objc-header " , " TestInputHeader.h " , " -emit-dependencies " , " -emit-module-source-info-path " , " /foo/bar/Test.swiftsourceinfo " ] )
2125
+ var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Test " , " -emit-module " , " -disable-bridging-pch " , " -import-objc-header " , " TestInputHeader.h " , " -emit-dependencies " , " -emit-module-source-info-path " , " /foo/bar/Test.swiftsourceinfo " , " -no-emit-module-separately " ] )
2116
2126
let plannedJobs = try driver. planBuild ( )
2117
2127
XCTAssertEqual ( plannedJobs. count, 3 )
2118
2128
XCTAssertEqual ( Set ( plannedJobs. map { $0. kind } ) , Set ( [ . compile, . mergeModule] ) )
@@ -2140,7 +2150,7 @@ final class SwiftDriverTests: XCTestCase {
2140
2150
}
2141
2151
2142
2152
do {
2143
- var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Test " , " -emit-module-path " , " /foo/bar/Test.swiftmodule " ] )
2153
+ var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Test " , " -emit-module-path " , " /foo/bar/Test.swiftmodule " , " -no-emit-module-separately " ] )
2144
2154
let plannedJobs = try driver. planBuild ( )
2145
2155
XCTAssertEqual ( plannedJobs. count, 3 )
2146
2156
XCTAssertTrue ( plannedJobs [ 2 ] . tool. name. contains ( " swift " ) )
@@ -2152,7 +2162,7 @@ final class SwiftDriverTests: XCTestCase {
2152
2162
2153
2163
do {
2154
2164
// Make sure the swiftdoc path is correct for a relative module
2155
- var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Test " , " -emit-module-path " , " Test.swiftmodule " ] )
2165
+ var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Test " , " -emit-module-path " , " Test.swiftmodule " , " -no-emit-module-separately " ] )
2156
2166
let plannedJobs = try driver. planBuild ( )
2157
2167
XCTAssertEqual ( plannedJobs. count, 3 )
2158
2168
XCTAssertTrue ( plannedJobs [ 2 ] . tool. name. contains ( " swift " ) )
@@ -2164,7 +2174,7 @@ final class SwiftDriverTests: XCTestCase {
2164
2174
2165
2175
do {
2166
2176
// Make sure the swiftdoc path is correct for an inferred module
2167
- var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Test " , " -emit-module " ] )
2177
+ var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Test " , " -emit-module " , " -no-emit-module-separately " ] )
2168
2178
let plannedJobs = try driver. planBuild ( )
2169
2179
XCTAssertEqual ( plannedJobs. count, 3 )
2170
2180
XCTAssertTrue ( plannedJobs [ 2 ] . tool. name. contains ( " swift " ) )
@@ -2176,7 +2186,7 @@ final class SwiftDriverTests: XCTestCase {
2176
2186
2177
2187
do {
2178
2188
// -o specified
2179
- var driver = try Driver ( args: [ " swiftc " , " -emit-module " , " -o " , " /tmp/test.swiftmodule " , " input.swift " ] )
2189
+ var driver = try Driver ( args: [ " swiftc " , " -emit-module " , " -o " , " /tmp/test.swiftmodule " , " input.swift " , " -no-emit-module-separately " ] )
2180
2190
let plannedJobs = try driver. planBuild ( )
2181
2191
2182
2192
XCTAssertEqual ( plannedJobs. count, 2 )
@@ -3370,7 +3380,7 @@ final class SwiftDriverTests: XCTestCase {
3370
3380
// Reset the temporary store to ensure predictable results.
3371
3381
VirtualPath . resetTemporaryFileStore ( )
3372
3382
var driver = try Driver ( args: [
3373
- " swiftc " , " -emit-executable " , " test.swift " , " -emit-module " , " -avoid-emit-module-source-info "
3383
+ " swiftc " , " -emit-executable " , " test.swift " , " -emit-module " , " -avoid-emit-module-source-info " , " -experimental-emit-module-separately "
3374
3384
] )
3375
3385
let plannedJobs = try driver. planBuild ( )
3376
3386
@@ -3383,25 +3393,21 @@ final class SwiftDriverTests: XCTestCase {
3383
3393
XCTAssertEqual ( output,
3384
3394
"""
3385
3395
digraph Jobs {
3386
- " compile (swift-frontend)" [style=bold];
3396
+ " emitModule (swift-frontend)" [style=bold];
3387
3397
" test.swift " [fontsize=12];
3398
+ " test.swift " -> " emitModule (swift-frontend) " [color=blue];
3399
+ " test.swiftmodule " [fontsize=12];
3400
+ " emitModule (swift-frontend) " -> " test.swiftmodule " [color=green];
3401
+ " test.swiftdoc " [fontsize=12];
3402
+ " emitModule (swift-frontend) " -> " test.swiftdoc " [color=green];
3403
+ " compile (swift-frontend) " [style=bold];
3388
3404
" test.swift " -> " compile (swift-frontend) " [color=blue];
3389
3405
" test-1.o " [fontsize=12];
3390
3406
" compile (swift-frontend) " -> " test-1.o " [color=green];
3391
- " test-1.swiftmodule " [fontsize=12];
3392
- " compile (swift-frontend) " -> " test-1.swiftmodule " [color=green];
3393
- " test-1.swiftdoc " [fontsize=12];
3394
- " compile (swift-frontend) " -> " test-1.swiftdoc " [color=green];
3395
3407
" autolinkExtract (swift-autolink-extract) " [style=bold];
3396
3408
" test-1.o " -> " autolinkExtract (swift-autolink-extract) " [color=blue];
3397
3409
" test-2.autolink " [fontsize=12];
3398
3410
" autolinkExtract (swift-autolink-extract) " -> " test-2.autolink " [color=green];
3399
- " mergeModule (swift-frontend) " [style=bold];
3400
- " test-1.swiftmodule " -> " mergeModule (swift-frontend) " [color=blue];
3401
- " test.swiftmodule " [fontsize=12];
3402
- " mergeModule (swift-frontend) " -> " test.swiftmodule " [color=green];
3403
- " test.swiftdoc " [fontsize=12];
3404
- " mergeModule (swift-frontend) " -> " test.swiftdoc " [color=green];
3405
3411
" link (clang) " [style=bold];
3406
3412
" test-1.o " -> " link (clang) " [color=blue];
3407
3413
" test-2.autolink " -> " link (clang) " [color=blue];
@@ -3414,21 +3420,17 @@ final class SwiftDriverTests: XCTestCase {
3414
3420
XCTAssertEqual ( output,
3415
3421
"""
3416
3422
digraph Jobs {
3417
- " compile (swift-frontend)" [style=bold];
3423
+ " emitModule (swift-frontend)" [style=bold];
3418
3424
" test.swift " [fontsize=12];
3425
+ " test.swift " -> " emitModule (swift-frontend) " [color=blue];
3426
+ " test.swiftmodule " [fontsize=12];
3427
+ " emitModule (swift-frontend) " -> " test.swiftmodule " [color=green];
3428
+ " test.swiftdoc " [fontsize=12];
3429
+ " emitModule (swift-frontend) " -> " test.swiftdoc " [color=green];
3430
+ " compile (swift-frontend) " [style=bold];
3419
3431
" test.swift " -> " compile (swift-frontend) " [color=blue];
3420
3432
" test-1.o " [fontsize=12];
3421
3433
" compile (swift-frontend) " -> " test-1.o " [color=green];
3422
- " test-1.swiftmodule " [fontsize=12];
3423
- " compile (swift-frontend) " -> " test-1.swiftmodule " [color=green];
3424
- " test-1.swiftdoc " [fontsize=12];
3425
- " compile (swift-frontend) " -> " test-1.swiftdoc " [color=green];
3426
- " mergeModule (swift-frontend) " [style=bold];
3427
- " test-1.swiftmodule " -> " mergeModule (swift-frontend) " [color=blue];
3428
- " test.swiftmodule " [fontsize=12];
3429
- " mergeModule (swift-frontend) " -> " test.swiftmodule " [color=green];
3430
- " test.swiftdoc " [fontsize=12];
3431
- " mergeModule (swift-frontend) " -> " test.swiftdoc " [color=green];
3432
3434
" link ( \( dynamicLinker) ) " [style=bold];
3433
3435
" test-1.o " -> " link ( \( dynamicLinker) ) " [color=blue];
3434
3436
" test " [fontsize=12];
@@ -4269,7 +4271,7 @@ final class SwiftDriverTests: XCTestCase {
4269
4271
4270
4272
// Ensure the merge-module step is not passed the precompiled header
4271
4273
do {
4272
- var driver = try Driver ( args: [ " swiftc " , " -emit-module " , " -import-objc-header " , " header.h " , " foo.swift " ] )
4274
+ var driver = try Driver ( args: [ " swiftc " , " -emit-module " , " -import-objc-header " , " header.h " , " foo.swift " , " -no-emit-module-separately " ] )
4273
4275
let plannedJobs = try driver. planBuild ( )
4274
4276
XCTAssertEqual ( plannedJobs. count, 3 )
4275
4277
@@ -4409,20 +4411,20 @@ final class SwiftDriverTests: XCTestCase {
4409
4411
let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
4410
4412
XCTAssertEqual ( plannedJobs. count, 3 )
4411
4413
4412
- XCTAssertEqual ( plannedJobs [ 0 ] . kind, . compile)
4413
- XCTAssertEqual ( plannedJobs [ 0 ] . inputs. count, 1 )
4414
- XCTAssertEqual ( plannedJobs [ 0 ] . inputs [ 0 ] . file, . relative( RelativePath ( " embed-bitcode.swift " ) ) )
4415
- XCTAssertEqual ( plannedJobs [ 0 ] . outputs. count, 4 )
4416
- XCTAssertTrue ( matchTemporary ( plannedJobs [ 0 ] . outputs [ 0 ] . file, " embed-bitcode.bc " ) )
4417
- XCTAssertTrue ( matchTemporary ( plannedJobs [ 0 ] . outputs [ 1 ] . file, " embed-bitcode.swiftmodule " ) )
4418
- XCTAssertTrue ( matchTemporary ( plannedJobs [ 0 ] . outputs [ 2 ] . file, " embed-bitcode.swiftdoc " ) )
4419
- XCTAssertTrue ( matchTemporary ( plannedJobs [ 0 ] . outputs [ 3 ] . file, " embed-bitcode.swiftsourceinfo " ) )
4420
-
4421
- XCTAssertEqual ( plannedJobs [ 1 ] . kind, . backend)
4422
- XCTAssertEqual ( plannedJobs [ 1 ] . inputs. count, 1 )
4423
- XCTAssertTrue ( matchTemporary ( plannedJobs [ 1 ] . inputs [ 0 ] . file, " embed-bitcode.bc " ) )
4424
- XCTAssertEqual ( plannedJobs [ 1 ] . outputs. count, 1 )
4425
- XCTAssertEqual ( plannedJobs [ 1 ] . outputs [ 0 ] . file, . relative( RelativePath ( " embed-bitcode.o " ) ) )
4414
+ let compileJob = plannedJobs. first ( where : { $0 . kind == . compile} ) !
4415
+ XCTAssertEqual ( compileJob . inputs. count, 1 )
4416
+ XCTAssertEqual ( compileJob . inputs [ 0 ] . file, . relative( RelativePath ( " embed-bitcode.swift " ) ) )
4417
+ XCTAssertEqual ( compileJob . outputs. count, 4 )
4418
+ XCTAssertTrue ( matchTemporary ( compileJob . outputs [ 0 ] . file, " embed-bitcode.bc " ) )
4419
+ XCTAssertTrue ( matchTemporary ( compileJob . outputs [ 1 ] . file, " embed-bitcode.swiftmodule " ) )
4420
+ XCTAssertTrue ( matchTemporary ( compileJob . outputs [ 2 ] . file, " embed-bitcode.swiftdoc " ) )
4421
+ XCTAssertTrue ( matchTemporary ( compileJob . outputs [ 3 ] . file, " embed-bitcode.swiftsourceinfo " ) )
4422
+
4423
+ let backendJob = plannedJobs. first ( where : { $0 . kind == . backend} ) !
4424
+ XCTAssertEqual ( backendJob . inputs. count, 1 )
4425
+ XCTAssertTrue ( matchTemporary ( backendJob . inputs [ 0 ] . file, " embed-bitcode.bc " ) )
4426
+ XCTAssertEqual ( backendJob . outputs. count, 1 )
4427
+ XCTAssertEqual ( backendJob . outputs [ 0 ] . file, . relative( RelativePath ( " embed-bitcode.o " ) ) )
4426
4428
4427
4429
XCTAssertEqual ( plannedJobs [ 2 ] . kind, . mergeModule)
4428
4430
XCTAssertEqual ( plannedJobs [ 2 ] . inputs. count, 1 )
@@ -4871,7 +4873,7 @@ final class SwiftDriverTests: XCTestCase {
4871
4873
4872
4874
func testFilelist( ) throws {
4873
4875
do {
4874
- var driver = try Driver ( args: [ " swiftc " , " -emit-module " , " ./a.swift " , " ./b.swift " , " ./c.swift " , " -module-name " , " main " , " -target " , " x86_64-apple-macosx10.9 " , " -driver-filelist-threshold=0 " ] )
4876
+ var driver = try Driver ( args: [ " swiftc " , " -emit-module " , " ./a.swift " , " ./b.swift " , " ./c.swift " , " -module-name " , " main " , " -target " , " x86_64-apple-macosx10.9 " , " -driver-filelist-threshold=0 " , " -no-emit-module-separately " ] )
4875
4877
let plannedJobs = try driver. planBuild ( )
4876
4878
4877
4879
let jobA = plannedJobs [ 0 ]
0 commit comments