@@ -348,8 +348,9 @@ public struct SwiftDriverPayload: Serializable, TaskPayload, Encodable {
348
348
public let reportRequiredTargetDependencies : BooleanWarningLevel
349
349
public let linkerResponseFilePath : Path ?
350
350
public let dependencyFilteringRootPath : Path ?
351
+ public let verifyScannerDependencies : Bool
351
352
352
- internal init ( uniqueID: String , compilerLocation: LibSwiftDriver . CompilerLocation , moduleName: String , tempDirPath: Path , explicitModulesTempDirPath: Path , variant: String , architecture: String , eagerCompilationEnabled: Bool , explicitModulesEnabled: Bool , commandLine: [ String ] , ruleInfo: [ String ] , isUsingWholeModuleOptimization: Bool , casOptions: CASOptions ? , reportRequiredTargetDependencies: BooleanWarningLevel , linkerResponseFilePath: Path ? , dependencyFilteringRootPath: Path ? ) {
353
+ internal init ( uniqueID: String , compilerLocation: LibSwiftDriver . CompilerLocation , moduleName: String , tempDirPath: Path , explicitModulesTempDirPath: Path , variant: String , architecture: String , eagerCompilationEnabled: Bool , explicitModulesEnabled: Bool , commandLine: [ String ] , ruleInfo: [ String ] , isUsingWholeModuleOptimization: Bool , casOptions: CASOptions ? , reportRequiredTargetDependencies: BooleanWarningLevel , linkerResponseFilePath: Path ? , dependencyFilteringRootPath: Path ? , verifyScannerDependencies : Bool ) {
353
354
self . uniqueID = uniqueID
354
355
self . compilerLocation = compilerLocation
355
356
self . moduleName = moduleName
@@ -366,10 +367,11 @@ public struct SwiftDriverPayload: Serializable, TaskPayload, Encodable {
366
367
self . reportRequiredTargetDependencies = reportRequiredTargetDependencies
367
368
self . linkerResponseFilePath = linkerResponseFilePath
368
369
self . dependencyFilteringRootPath = dependencyFilteringRootPath
370
+ self . verifyScannerDependencies = verifyScannerDependencies
369
371
}
370
372
371
373
public init ( from deserializer: any Deserializer ) throws {
372
- try deserializer. beginAggregate ( 16 )
374
+ try deserializer. beginAggregate ( 17 )
373
375
self . uniqueID = try deserializer. deserialize ( )
374
376
self . compilerLocation = try deserializer. deserialize ( )
375
377
self . moduleName = try deserializer. deserialize ( )
@@ -386,10 +388,11 @@ public struct SwiftDriverPayload: Serializable, TaskPayload, Encodable {
386
388
self . reportRequiredTargetDependencies = try deserializer. deserialize ( )
387
389
self . linkerResponseFilePath = try deserializer. deserialize ( )
388
390
self . dependencyFilteringRootPath = try deserializer. deserialize ( )
391
+ self . verifyScannerDependencies = try deserializer. deserialize ( )
389
392
}
390
393
391
394
public func serialize< T> ( to serializer: T ) where T : Serializer {
392
- serializer. serializeAggregate ( 16 ) {
395
+ serializer. serializeAggregate ( 17 ) {
393
396
serializer. serialize ( self . uniqueID)
394
397
serializer. serialize ( self . compilerLocation)
395
398
serializer. serialize ( self . moduleName)
@@ -406,6 +409,7 @@ public struct SwiftDriverPayload: Serializable, TaskPayload, Encodable {
406
409
serializer. serialize ( self . reportRequiredTargetDependencies)
407
410
serializer. serialize ( self . linkerResponseFilePath)
408
411
serializer. serialize ( self . dependencyFilteringRootPath)
412
+ serializer. serialize ( self . verifyScannerDependencies)
409
413
}
410
414
}
411
415
}
@@ -1391,6 +1395,20 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
1391
1395
return buildSettingEnabled
1392
1396
}
1393
1397
1398
+ func shouldEmitMakeStyleDependencies( _ producer: any CommandProducer , _ scope: MacroEvaluationScope , delegate: any TaskGenerationDelegate ) async -> Bool {
1399
+ guard await swiftExplicitModuleBuildEnabled ( producer, scope, delegate) else {
1400
+ return true
1401
+ }
1402
+ switch scope. evaluate ( BuiltinMacros . SWIFT_DEPENDENCY_REGISTRATION_MODE) {
1403
+ case . makeStyleDependenciesSupplementedByScanner:
1404
+ return true
1405
+ case . swiftDependencyScannerOnly:
1406
+ return false
1407
+ case . verifySwiftDependencyScanner:
1408
+ return true
1409
+ }
1410
+ }
1411
+
1394
1412
private func swiftCachingEnabled( _ cbc: CommandBuildContext , _ delegate: any TaskGenerationDelegate , _ moduleName: String , _ useIntegratedDriver: Bool , _ explicitModuleBuildEnabled: Bool , _ disabledPCHCompile: Bool ) async -> Bool {
1395
1413
guard cbc. producer. supportsCompilationCaching else { return false }
1396
1414
@@ -1822,8 +1840,10 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
1822
1840
// Instruct the compiler to serialize diagnostics.
1823
1841
args. append ( " -serialize-diagnostics " )
1824
1842
1825
- // Instruct the compiler to emit dependencies information.
1826
- args. append ( " -emit-dependencies " )
1843
+ if await shouldEmitMakeStyleDependencies ( cbc. producer, cbc. scope, delegate: delegate) {
1844
+ // Instruct the compiler to emit dependencies information.
1845
+ args. append ( " -emit-dependencies " )
1846
+ }
1827
1847
1828
1848
// Generate the .swiftmodule from this compilation to a known location.
1829
1849
//
@@ -2200,7 +2220,10 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
2200
2220
}
2201
2221
} )
2202
2222
2203
- let dependencyInfoPath : Path ? = {
2223
+ let dependencyInfoPath : Path ? = await {
2224
+ guard await shouldEmitMakeStyleDependencies ( cbc. producer, cbc. scope, delegate: delegate) else {
2225
+ return nil
2226
+ }
2204
2227
// FIXME: Duplication with `SwiftCompilerSpec.computeOutputFileMapContents`
2205
2228
//
2206
2229
// FIXME: Can we simplify this to not require the full macro scope?
@@ -2307,9 +2330,6 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
2307
2330
2308
2331
// Rest compilation (defined before for transparent dependency handling
2309
2332
let eagerCompilationEnabled = eagerCompilationEnabled ( args: args, scope: cbc. scope, compilationMode: compilationMode, isUsingWholeModuleOptimization: isUsingWholeModuleOptimization)
2310
- // FIXME: Duplication with `SwiftCompilerSpec.computeOutputFileMapContents`
2311
- let masterSwiftBaseName = cbc. scope. evaluate ( BuiltinMacros . TARGET_NAME) + compilationMode. moduleBaseNameSuffix + " -master "
2312
- let emitModuleDependenciesFilePath = objectFileDir. join ( masterSwiftBaseName + " -emit-module.d " )
2313
2333
let compilationRequirementOutputs : [ any PlannedNode ]
2314
2334
let compilationOutputs : [ any PlannedNode ]
2315
2335
if eagerCompilationEnabled {
@@ -2321,8 +2341,17 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
2321
2341
compilationOutputs = [ compilationFinishedNode]
2322
2342
}
2323
2343
2344
+ let dependencyData : DependencyDataStyle ?
2345
+ if await shouldEmitMakeStyleDependencies ( cbc. producer, cbc. scope, delegate: delegate) {
2346
+ // FIXME: Duplication with `SwiftCompilerSpec.computeOutputFileMapContents`
2347
+ let masterSwiftBaseName = cbc. scope. evaluate ( BuiltinMacros . TARGET_NAME) + compilationMode. moduleBaseNameSuffix + " -master "
2348
+ let emitModuleDependenciesFilePath = objectFileDir. join ( masterSwiftBaseName + " -emit-module.d " )
2349
+ dependencyData = eagerCompilationEnabled ? . makefileIgnoringSubsequentOutputs( emitModuleDependenciesFilePath) : dependencyInfoPath. map ( DependencyDataStyle . makefileIgnoringSubsequentOutputs)
2350
+ } else {
2351
+ dependencyData = nil
2352
+ }
2353
+
2324
2354
// Compilation Requirements
2325
- let dependencyData : DependencyDataStyle ? = eagerCompilationEnabled ? . makefileIgnoringSubsequentOutputs( emitModuleDependenciesFilePath) : dependencyInfoPath. map ( DependencyDataStyle . makefileIgnoringSubsequentOutputs)
2326
2355
delegate. createTask ( type: self , dependencyData: dependencyData, payload: payload, ruleInfo: ruleInfo ( " SwiftDriver Compilation Requirements " , targetName) , additionalSignatureData: additionalSignatureData, commandLine: [ " builtin-Swift-Compilation-Requirements " , " -- " ] + args, environment: environmentBindings, workingDirectory: compilerWorkingDirectory ( cbc) , inputs: allInputsNodes, outputs: compilationRequirementOutputs, action: delegate. taskActionCreationDelegate. createSwiftCompilationRequirementTaskAction ( ) , execDescription: archSpecificExecutionDescription ( cbc. scope. namespace. parseString ( " Unblock downstream dependents of $PRODUCT_NAME " ) , cbc, delegate) , preparesForIndexing: true , enableSandboxing: enableSandboxing, additionalTaskOrderingOptions: [ . compilation, . compilationRequirement, . linkingRequirement, . blockedByTargetHeaders, . compilationForIndexableSourceFile] , usesExecutionInputs: true , showInLog: true )
2327
2356
2328
2357
if case . compile = compilationMode {
@@ -2461,8 +2490,9 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
2461
2490
compilerLocation = . library( libSwiftScanPath: libSwiftScanPath)
2462
2491
#endif
2463
2492
let explicitModuleBuildEnabled = await swiftExplicitModuleBuildEnabled ( cbc. producer, cbc. scope, delegate)
2493
+ let verifyScannerDependencies = explicitModuleBuildEnabled && cbc. scope. evaluate ( BuiltinMacros . SWIFT_DEPENDENCY_REGISTRATION_MODE) == . verifySwiftDependencyScanner
2464
2494
2465
- return SwiftDriverPayload ( uniqueID: uniqueID, compilerLocation: compilerLocation, moduleName: scope. evaluate ( BuiltinMacros . SWIFT_MODULE_NAME) , tempDirPath: tempDirPath, explicitModulesTempDirPath: explicitModulesTempDirPath, variant: variant, architecture: arch, eagerCompilationEnabled: eagerCompilationEnabled ( args: args, scope: scope, compilationMode: compilationMode, isUsingWholeModuleOptimization: isUsingWholeModuleOptimization) , explicitModulesEnabled: explicitModuleBuildEnabled, commandLine: commandLine, ruleInfo: ruleInfo, isUsingWholeModuleOptimization: isUsingWholeModuleOptimization, casOptions: casOptions, reportRequiredTargetDependencies: scope. evaluate ( BuiltinMacros . DIAGNOSE_MISSING_TARGET_DEPENDENCIES) , linkerResponseFilePath: linkerResponseFilePath, dependencyFilteringRootPath: cbc. producer. sdk? . path)
2495
+ return SwiftDriverPayload ( uniqueID: uniqueID, compilerLocation: compilerLocation, moduleName: scope. evaluate ( BuiltinMacros . SWIFT_MODULE_NAME) , tempDirPath: tempDirPath, explicitModulesTempDirPath: explicitModulesTempDirPath, variant: variant, architecture: arch, eagerCompilationEnabled: eagerCompilationEnabled ( args: args, scope: scope, compilationMode: compilationMode, isUsingWholeModuleOptimization: isUsingWholeModuleOptimization) , explicitModulesEnabled: explicitModuleBuildEnabled, commandLine: commandLine, ruleInfo: ruleInfo, isUsingWholeModuleOptimization: isUsingWholeModuleOptimization, casOptions: casOptions, reportRequiredTargetDependencies: scope. evaluate ( BuiltinMacros . DIAGNOSE_MISSING_TARGET_DEPENDENCIES) , linkerResponseFilePath: linkerResponseFilePath, dependencyFilteringRootPath: cbc. producer. sdk? . path, verifyScannerDependencies : verifyScannerDependencies )
2466
2496
}
2467
2497
2468
2498
func constructSwiftResponseFileTask( path: Path ) {
@@ -3048,9 +3078,11 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
3048
3078
let diagnosticsFilePath = objectFileDir. join ( objectFilePrefix + " .dia " )
3049
3079
fileMapEntry. diagnostics = diagnosticsFilePath. str
3050
3080
3051
- // The dependencies file, used to discover implicit dependencies. This file will be in Makefile format.
3052
- let dependenciesFilePath = objectFileDir. join ( objectFilePrefix + " .d " )
3053
- fileMapEntry. dependencies = dependenciesFilePath. str
3081
+ if await shouldEmitMakeStyleDependencies ( cbc. producer, cbc. scope, delegate: delegate) {
3082
+ // The dependencies file, used to discover implicit dependencies. This file will be in Makefile format.
3083
+ let dependenciesFilePath = objectFileDir. join ( objectFilePrefix + " .d " )
3084
+ fileMapEntry. dependencies = dependenciesFilePath. str
3085
+ }
3054
3086
3055
3087
// The file used by Swift to manage intermodule dependencies.
3056
3088
let swiftDependenciesFilePath = objectFileDir. join ( objectFilePrefix + " .swiftdeps " )
@@ -3085,9 +3117,11 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
3085
3117
let emitModuleDiagnosticsFilePath = objectFileDir. join ( masterSwiftBaseName + " -emit-module.dia " )
3086
3118
fileMapEntry. emitModuleDiagnostics = emitModuleDiagnosticsFilePath. str
3087
3119
3088
- // The dependency file for emit-module jobs.
3089
- let emitModuleDependenciesFilePath = objectFileDir. join ( masterSwiftBaseName + " -emit-module.d " )
3090
- fileMapEntry. emitModuleDependencies = emitModuleDependenciesFilePath. str
3120
+ if await shouldEmitMakeStyleDependencies ( cbc. producer, cbc. scope, delegate: delegate) {
3121
+ // The dependency file for emit-module jobs.
3122
+ let emitModuleDependenciesFilePath = objectFileDir. join ( masterSwiftBaseName + " -emit-module.d " )
3123
+ fileMapEntry. emitModuleDependencies = emitModuleDependenciesFilePath. str
3124
+ }
3091
3125
3092
3126
// The PCH file path for generatePCH job.
3093
3127
let bridgingHeaderPCHPath = objectFileDir. join ( masterSwiftBaseName + " -Bridging-header.pch " )
@@ -3115,13 +3149,16 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
3115
3149
let emitModuleDiagnosticsFilePath = objectFileDir. join ( masterSwiftBaseName + " -emit-module.dia " )
3116
3150
fileMapEntry. emitModuleDiagnostics = emitModuleDiagnosticsFilePath. str
3117
3151
3118
- // The dependency file for emit-module jobs.
3119
- let emitModuleDependenciesFilePath = objectFileDir. join ( masterSwiftBaseName + " -emit-module.d " )
3120
- fileMapEntry. emitModuleDependencies = emitModuleDependenciesFilePath. str
3152
+ if await shouldEmitMakeStyleDependencies ( cbc. producer, cbc. scope, delegate: delegate) {
3153
+ // The dependency file for emit-module jobs.
3154
+ let emitModuleDependenciesFilePath = objectFileDir. join ( masterSwiftBaseName + " -emit-module.d " )
3155
+ fileMapEntry. emitModuleDependencies = emitModuleDependenciesFilePath. str
3121
3156
3122
- // The dependencies file, used to discover implicit dependencies. This file will be in Makefile format.
3123
- let dependenciesFilePath = objectFileDir. join ( masterSwiftBaseName + " .d " )
3124
- fileMapEntry. dependencies = dependenciesFilePath. str
3157
+
3158
+ // The dependencies file, used to discover implicit dependencies. This file will be in Makefile format.
3159
+ let dependenciesFilePath = objectFileDir. join ( masterSwiftBaseName + " .d " )
3160
+ fileMapEntry. dependencies = dependenciesFilePath. str
3161
+ }
3125
3162
3126
3163
// The file used by Swift to manage intermodule dependencies.
3127
3164
let swiftDependenciesFilePath = objectFileDir. join ( masterSwiftBaseName + " .swiftdeps " )
0 commit comments