@@ -2457,6 +2457,142 @@ final class ExplicitModuleBuildTests: XCTestCase {
2457
2457
}
2458
2458
}
2459
2459
2460
+ func testClangTargetOptionsExplicit( ) throws {
2461
+ let ( stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning ( )
2462
+ let cHeadersPath : AbsolutePath =
2463
+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
2464
+ . appending ( component: " CHeaders " )
2465
+ let swiftModuleInterfacesPath : AbsolutePath =
2466
+ try testInputsPath. appending ( component: " ExplicitModuleBuilds " )
2467
+ . appending ( component: " Swift " )
2468
+ let mockSDKPath : AbsolutePath =
2469
+ try testInputsPath. appending ( component: " mock-sdk.sdk " )
2470
+
2471
+ // Only '-target' is specified, the driver infers '-clang-target' from SDK deployment target
2472
+ do {
2473
+ try withTemporaryDirectory { path in
2474
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2475
+ try localFileSystem. writeFileContents ( main, bytes:
2476
+ """
2477
+ import A;
2478
+ """
2479
+ )
2480
+ var driver = try Driver ( args: [ " swiftc " ,
2481
+ " -target " , " x86_64-apple-macosx10.10 " ,
2482
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2483
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2484
+ " -emit-module " ,
2485
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2486
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2487
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2488
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2489
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2490
+ " -explicit-module-build " ,
2491
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2492
+ main. pathString] )
2493
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2494
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2495
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2496
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.15 " ) ] ) )
2497
+ }
2498
+ }
2499
+
2500
+ // User-specified '-clang-target'
2501
+ do {
2502
+ try withTemporaryDirectory { path in
2503
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2504
+ try localFileSystem. writeFileContents ( main, bytes:
2505
+ """
2506
+ import A;
2507
+ """
2508
+ )
2509
+ var driver = try Driver ( args: [ " swiftc " ,
2510
+ " -target " , " x86_64-apple-macosx10.10 " ,
2511
+ " -clang-target " , " x86_64-apple-macosx10.12 " ,
2512
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2513
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2514
+ " -emit-module " ,
2515
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2516
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2517
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2518
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2519
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2520
+ " -explicit-module-build " ,
2521
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2522
+ main. pathString] )
2523
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2524
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2525
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2526
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.12 " ) ] ) )
2527
+ }
2528
+ }
2529
+
2530
+ // Only '-target' and '-target-variant' is specified, the driver infers '-clang-target' from SDK deployment target
2531
+ // and '-clang-target-variant' form the
2532
+ do {
2533
+ try withTemporaryDirectory { path in
2534
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2535
+ try localFileSystem. writeFileContents ( main, bytes:
2536
+ """
2537
+ import A;
2538
+ """
2539
+ )
2540
+ var driver = try Driver ( args: [ " swiftc " ,
2541
+ " -target " , " x86_64-apple-macosx10.10 " ,
2542
+ " -target-variant " , " x86_64-apple-ios13.0-macabi " ,
2543
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2544
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2545
+ " -emit-module " ,
2546
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2547
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2548
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2549
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2550
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2551
+ " -explicit-module-build " ,
2552
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2553
+ main. pathString] )
2554
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2555
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2556
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2557
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.15 " ) ] ) )
2558
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target-variant " ) , . flag( " x86_64-apple-ios13.1-macabi " ) ] ) )
2559
+ }
2560
+ }
2561
+
2562
+ // User-specified '-clang-target' and '-clang-target-variant'
2563
+ do {
2564
+ try withTemporaryDirectory { path in
2565
+ let main = path. appending ( component: " testDependencyScanning.swift " )
2566
+ try localFileSystem. writeFileContents ( main, bytes:
2567
+ """
2568
+ import A;
2569
+ """
2570
+ )
2571
+ var driver = try Driver ( args: [ " swiftc " ,
2572
+ " -target " , " x86_64-apple-macosx10.10 " ,
2573
+ " -target-variant " , " x86_64-apple-ios13.0-macabi " ,
2574
+ " -clang-target " , " x86_64-apple-macosx10.12 " ,
2575
+ " -clang-target-variant " , " x86_64-apple-ios14.0-macabi " ,
2576
+ " -Xfrontend " , " -disable-implicit-concurrency-module-import " ,
2577
+ " -Xfrontend " , " -disable-implicit-string-processing-module-import " ,
2578
+ " -emit-module " ,
2579
+ " -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2580
+ " -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2581
+ " -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2582
+ " -I " , stdlibPath. nativePathString ( escaped: true ) ,
2583
+ " -I " , shimsPath. nativePathString ( escaped: true ) ,
2584
+ " -explicit-module-build " ,
2585
+ " -sdk " , mockSDKPath. nativePathString ( escaped: true ) ,
2586
+ main. pathString] )
2587
+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
2588
+ let emitModuleJob = try XCTUnwrap ( plannedJobs. findJobs ( . emitModule) . spm_only)
2589
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -sdk " ) , . path( . absolute( mockSDKPath) ) ] ) )
2590
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target " ) , . flag( " x86_64-apple-macosx10.12 " ) ] ) )
2591
+ XCTAssertTrue ( emitModuleJob. commandLine. contains ( subsequence: [ . flag( " -clang-target-variant " ) , . flag( " x86_64-apple-ios14.0-macabi " ) ] ) )
2592
+ }
2593
+ }
2594
+ }
2595
+
2460
2596
func testTargetVariantEmitModuleExplicit( ) throws {
2461
2597
let ( stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning ( )
2462
2598
let cHeadersPath : AbsolutePath =
@@ -2489,8 +2625,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
2489
2625
" -emit-variant-module-path " , " foo.swiftmodule/variant.swiftmodule " ,
2490
2626
" -emit-module-interface-path " , " foo.swiftmodule/target.swiftinterface " ,
2491
2627
" -emit-variant-module-interface-path " , " foo.swiftmodule/variant.swiftinterface " ,
2492
- " -disable-implicit-concurrency-module-import " ,
2493
- " -disable-implicit-string-processing-module-import " ,
2628
+ " -Xfrontend " , " - disable-implicit-concurrency-module-import" ,
2629
+ " -Xfrontend " , " - disable-implicit-string-processing-module-import" ,
2494
2630
" -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2495
2631
" -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2496
2632
" -I " , stdlibPath. nativePathString ( escaped: true ) ,
@@ -2591,8 +2727,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
2591
2727
" -emit-module " ,
2592
2728
" -emit-module-path " , " foo.swiftmodule/target.swiftmodule " ,
2593
2729
" -emit-variant-module-path " , " foo.swiftmodule/variant.swiftmodule " ,
2594
- " -disable-implicit-concurrency-module-import " ,
2595
- " -disable-implicit-string-processing-module-import " ,
2730
+ " -Xfrontend " , " - disable-implicit-concurrency-module-import" ,
2731
+ " -Xfrontend " , " - disable-implicit-string-processing-module-import" ,
2596
2732
" -I " , cHeadersPath. nativePathString ( escaped: true ) ,
2597
2733
" -I " , swiftModuleInterfacesPath. nativePathString ( escaped: true ) ,
2598
2734
" -I " , stdlibPath. nativePathString ( escaped: true ) ,
0 commit comments