@@ -2591,6 +2591,142 @@ final class ExplicitModuleBuildTests: XCTestCase {
2591
2591
}
2592
2592
}
2593
2593
2594
+ func testClangTargetOptionsExplicit( ) throws {
2595
+ let ( stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning ( )
2596
+ let cHeadersPath : AbsolutePath =
2597
+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
2598
+ . appending ( component: " CHeaders " )
2599
+ let swiftModuleInterfacesPath : AbsolutePath =
2600
+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
2601
+ . appending ( component: " Swift " )
2602
+ let mockSDKPath : AbsolutePath =
2603
+ try testInputsPath. appending ( component: " mock-sdk.sdk " )
2604
+
2605
+ // Only '-target' is specified, the driver infers '-clang-target' from SDK deployment target
2606
+ do {
2607
+ try withTemporaryDirectory { path in
2608
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2609
+ try localFileSystem. writeFileContents ( main, bytes:
2610
+ """
2611
+ import A;
2612
+ """
2613
+ )
2614
+ var driver = try Driver ( args: [ " swiftc " ,
2615
+ " -target " , " x86_64-apple-macosx10.10 " ,
2616
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2617
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2618
+ " -emit-module " ,
2619
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2620
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2621
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2622
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2623
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2624
+ " -explicit-module-build " ,
2625
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2626
+ main. pathString] )
2627
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2628
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2629
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2630
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.15 " ) ] ) )
2631
+ }
2632
+ }
2633
+
2634
+ // User-specified '-clang-target'
2635
+ do {
2636
+ try withTemporaryDirectory { path in
2637
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2638
+ try localFileSystem. writeFileContents ( main, bytes:
2639
+ """
2640
+ import A;
2641
+ """
2642
+ )
2643
+ var driver = try Driver ( args: [ " swiftc " ,
2644
+ " -target " , " x86_64-apple-macosx10.10 " ,
2645
+ " -clang-target " , " x86_64-apple-macosx10.12 " ,
2646
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2647
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2648
+ " -emit-module " ,
2649
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2650
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2651
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2652
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2653
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2654
+ " -explicit-module-build " ,
2655
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2656
+ main. pathString] )
2657
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2658
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2659
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2660
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.12 " ) ] ) )
2661
+ }
2662
+ }
2663
+
2664
+ // Only '-target' and '-target-variant' is specified, the driver infers '-clang-target' from SDK deployment target
2665
+ // and '-clang-target-variant' form the
2666
+ do {
2667
+ try withTemporaryDirectory { path in
2668
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2669
+ try localFileSystem. writeFileContents ( main, bytes:
2670
+ """
2671
+ import A;
2672
+ """
2673
+ )
2674
+ var driver = try Driver ( args: [ " swiftc " ,
2675
+ " -target " , " x86_64-apple-macosx10.10 " ,
2676
+ " -target-variant " , " x86_64-apple-ios13.0-macabi " ,
2677
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2678
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2679
+ " -emit-module " ,
2680
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2681
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2682
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2683
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2684
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2685
+ " -explicit-module-build " ,
2686
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2687
+ main. pathString] )
2688
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2689
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2690
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2691
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.15 " ) ] ) )
2692
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target-variant " ) , . flag( " x86_64-apple-ios13.1-macabi " ) ] ) )
2693
+ }
2694
+ }
2695
+
2696
+ // User-specified '-clang-target' and '-clang-target-variant'
2697
+ do {
2698
+ try withTemporaryDirectory { path in
2699
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2700
+ try localFileSystem. writeFileContents ( main, bytes:
2701
+ """
2702
+ import A;
2703
+ """
2704
+ )
2705
+ var driver = try Driver ( args: [ " swiftc " ,
2706
+ " -target " , " x86_64-apple-macosx10.10 " ,
2707
+ " -target-variant " , " x86_64-apple-ios13.0-macabi " ,
2708
+ " -clang-target " , " x86_64-apple-macosx10.12 " ,
2709
+ " -clang-target-variant " , " x86_64-apple-ios14.0-macabi " ,
2710
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2711
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2712
+ " -emit-module " ,
2713
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2714
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2715
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2716
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2717
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2718
+ " -explicit-module-build " ,
2719
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2720
+ main. pathString] )
2721
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2722
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2723
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2724
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.12 " ) ] ) )
2725
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target-variant " ) , . flag( " x86_64-apple-ios14.0-macabi " ) ] ) )
2726
+ }
2727
+ }
2728
+ }
2729
+
2594
2730
func testTargetVariantEmitModuleExplicit( ) throws {
2595
2731
let ( stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning ( )
2596
2732
let cHeadersPath : AbsolutePath =
@@ -2623,8 +2759,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
2623
2759
" -emit-variant-module-path " , " foo.swiftmodule/variant.swiftmodule " ,
2624
2760
" -emit-module-interface-path " , " foo.swiftmodule/target.swiftinterface " ,
2625
2761
" -emit-variant-module-interface-path " , " foo.swiftmodule/variant.swiftinterface " ,
2626
- " -disable-implicit-concurrency-module-import " ,
2627
- " -disable-implicit-string-processing-module-import " ,
2762
+ " -Xfrontend " , " - disable-implicit-concurrency-module-import" ,
2763
+ " -Xfrontend " , " - disable-implicit-string-processing-module-import" ,
2628
2764
" -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2629
2765
" -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2630
2766
" -I " , stdlibPath. nativePathString ( escaped: true ) ,
@@ -2725,8 +2861,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
2725
2861
" -emit-module " ,
2726
2862
" -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2727
2863
" -emit-variant-module-path " , " foo.swiftmodule/variant.swiftmodule " ,
2728
- " -disable-implicit-concurrency-module-import " ,
2729
- " -disable-implicit-string-processing-module-import " ,
2864
+ " -Xfrontend " , " - disable-implicit-concurrency-module-import" ,
2865
+ " -Xfrontend " , " - disable-implicit-string-processing-module-import" ,
2730
2866
" -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2731
2867
" -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2732
2868
" -I " , stdlibPath. nativePathString ( escaped: true ) ,
0 commit comments