@@ -2524,6 +2524,142 @@ final class ExplicitModuleBuildTests: XCTestCase {
2524
2524
}
2525
2525
}
2526
2526
2527
+ func testClangTargetOptionsExplicit( ) throws {
2528
+ let ( stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning ( )
2529
+ let cHeadersPath : AbsolutePath =
2530
+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
2531
+ . appending ( component: " CHeaders " )
2532
+ let swiftModuleInterfacesPath : AbsolutePath =
2533
+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
2534
+ . appending ( component: " Swift " )
2535
+ let mockSDKPath : AbsolutePath =
2536
+ try testInputsPath. appending ( component: " mock-sdk.sdk " )
2537
+
2538
+ // Only '-target' is specified, the driver infers '-clang-target' from SDK deployment target
2539
+ do {
2540
+ try withTemporaryDirectory { path in
2541
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2542
+ try localFileSystem. writeFileContents ( main, bytes:
2543
+ """
2544
+ import A;
2545
+ """
2546
+ )
2547
+ var driver = try Driver ( args: [ " swiftc " ,
2548
+ " -target " , " x86_64-apple-macosx10.10 " ,
2549
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2550
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2551
+ " -emit-module " ,
2552
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2553
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2554
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2555
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2556
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2557
+ " -explicit-module-build " ,
2558
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2559
+ main. pathString] )
2560
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2561
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2562
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2563
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.15 " ) ] ) )
2564
+ }
2565
+ }
2566
+
2567
+ // User-specified '-clang-target'
2568
+ do {
2569
+ try withTemporaryDirectory { path in
2570
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2571
+ try localFileSystem. writeFileContents ( main, bytes:
2572
+ """
2573
+ import A;
2574
+ """
2575
+ )
2576
+ var driver = try Driver ( args: [ " swiftc " ,
2577
+ " -target " , " x86_64-apple-macosx10.10 " ,
2578
+ " -clang-target " , " x86_64-apple-macosx10.12 " ,
2579
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2580
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2581
+ " -emit-module " ,
2582
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2583
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2584
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2585
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2586
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2587
+ " -explicit-module-build " ,
2588
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2589
+ main. pathString] )
2590
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2591
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2592
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2593
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.12 " ) ] ) )
2594
+ }
2595
+ }
2596
+
2597
+ // Only '-target' and '-target-variant' is specified, the driver infers '-clang-target' from SDK deployment target
2598
+ // and '-clang-target-variant' form the
2599
+ do {
2600
+ try withTemporaryDirectory { path in
2601
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2602
+ try localFileSystem. writeFileContents ( main, bytes:
2603
+ """
2604
+ import A;
2605
+ """
2606
+ )
2607
+ var driver = try Driver ( args: [ " swiftc " ,
2608
+ " -target " , " x86_64-apple-macosx10.10 " ,
2609
+ " -target-variant " , " x86_64-apple-ios13.0-macabi " ,
2610
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2611
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2612
+ " -emit-module " ,
2613
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2614
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2615
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2616
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2617
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2618
+ " -explicit-module-build " ,
2619
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2620
+ main. pathString] )
2621
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2622
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2623
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2624
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.15 " ) ] ) )
2625
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target-variant " ) , . flag( " x86_64-apple-ios13.1-macabi " ) ] ) )
2626
+ }
2627
+ }
2628
+
2629
+ // User-specified '-clang-target' and '-clang-target-variant'
2630
+ do {
2631
+ try withTemporaryDirectory { path in
2632
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2633
+ try localFileSystem. writeFileContents ( main, bytes:
2634
+ """
2635
+ import A;
2636
+ """
2637
+ )
2638
+ var driver = try Driver ( args: [ " swiftc " ,
2639
+ " -target " , " x86_64-apple-macosx10.10 " ,
2640
+ " -target-variant " , " x86_64-apple-ios13.0-macabi " ,
2641
+ " -clang-target " , " x86_64-apple-macosx10.12 " ,
2642
+ " -clang-target-variant " , " x86_64-apple-ios14.0-macabi " ,
2643
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2644
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2645
+ " -emit-module " ,
2646
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2647
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2648
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2649
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2650
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2651
+ " -explicit-module-build " ,
2652
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2653
+ main. pathString] )
2654
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2655
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2656
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2657
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.12 " ) ] ) )
2658
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target-variant " ) , . flag( " x86_64-apple-ios14.0-macabi " ) ] ) )
2659
+ }
2660
+ }
2661
+ }
2662
+
2527
2663
func testTargetVariantEmitModuleExplicit( ) throws {
2528
2664
let ( stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning ( )
2529
2665
let cHeadersPath : AbsolutePath =
@@ -2556,8 +2692,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
2556
2692
" -emit-variant-module-path " , " foo.swiftmodule/variant.swiftmodule " ,
2557
2693
" -emit-module-interface-path " , " foo.swiftmodule/target.swiftinterface " ,
2558
2694
" -emit-variant-module-interface-path " , " foo.swiftmodule/variant.swiftinterface " ,
2559
- " -disable-implicit-concurrency-module-import " ,
2560
- " -disable-implicit-string-processing-module-import " ,
2695
+ " -Xfrontend " , " - disable-implicit-concurrency-module-import" ,
2696
+ " -Xfrontend " , " - disable-implicit-string-processing-module-import" ,
2561
2697
" -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2562
2698
" -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2563
2699
" -I " , stdlibPath. nativePathString ( escaped: true ) ,
@@ -2658,8 +2794,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
2658
2794
" -emit-module " ,
2659
2795
" -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2660
2796
" -emit-variant-module-path " , " foo.swiftmodule/variant.swiftmodule " ,
2661
- " -disable-implicit-concurrency-module-import " ,
2662
- " -disable-implicit-string-processing-module-import " ,
2797
+ " -Xfrontend " , " - disable-implicit-concurrency-module-import" ,
2798
+ " -Xfrontend " , " - disable-implicit-string-processing-module-import" ,
2663
2799
" -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2664
2800
" -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2665
2801
" -I " , stdlibPath. nativePathString ( escaped: true ) ,
0 commit comments