@@ -34,14 +34,15 @@ public struct Driver {
34
34
case missingProfilingData( String )
35
35
case conditionalCompilationFlagHasRedundantPrefix( String )
36
36
case conditionalCompilationFlagIsNotValidIdentifier( String )
37
+ case baselineGenerationRequiresTopLevelModule( String )
38
+ case optionRequiresAnother( String , String )
37
39
// Explicit Module Build Failures
38
40
case malformedModuleDependency( String , String )
39
41
case missingPCMArguments( String )
40
42
case missingModuleDependency( String )
41
43
case missingContextHashOnSwiftDependency( String )
42
44
case dependencyScanningFailure( Int , String )
43
45
case missingExternalDependency( String )
44
- case baselineGenerationRequiresTopLevelModule( String )
45
46
46
47
public var description : String {
47
48
switch self {
@@ -103,6 +104,8 @@ public struct Driver {
103
104
return " Missing External dependency info for module: \( moduleName) "
104
105
case . baselineGenerationRequiresTopLevelModule( let arg) :
105
106
return " generating a baseline with ' \( arg) ' is only supported with '-emit-module' or '-emit-module-path' "
107
+ case . optionRequiresAnother( let first, let second) :
108
+ return " ' \( first) ' cannot be specified if ' \( second) ' is not present "
106
109
}
107
110
}
108
111
}
@@ -291,11 +294,11 @@ public struct Driver {
291
294
/// Path to the Swift module source information file.
292
295
let moduleSourceInfoPath : VirtualPath . Handle ?
293
296
294
- /// Path to the module API baseline file.
295
- let apiBaselinePath : VirtualPath . Handle ?
297
+ /// Path to the module's digester baseline file.
298
+ let digesterBaselinePath : VirtualPath . Handle ?
296
299
297
- /// Path to the module ABI baseline file .
298
- let abiBaselinePath : VirtualPath . Handle ?
300
+ /// The mode the API digester should run in .
301
+ let digesterMode : DigesterMode
299
302
300
303
/// Force the driver to emit the module first and then run compile jobs. This could be used to unblock
301
304
/// dependencies in parallel builds.
@@ -544,6 +547,16 @@ public struct Driver {
544
547
self . numThreads = Self . determineNumThreads ( & parsedOptions, compilerMode: compilerMode, diagnosticsEngine: diagnosticEngine)
545
548
self . numParallelJobs = Self . determineNumParallelJobs ( & parsedOptions, diagnosticsEngine: diagnosticEngine, env: env)
546
549
550
+ var mode = DigesterMode . api
551
+ if let modeArg = parsedOptions. getLastArgument ( . digesterMode) ? . asSingle {
552
+ if let digesterMode = DigesterMode ( rawValue: modeArg) {
553
+ mode = digesterMode
554
+ } else {
555
+ diagnosticsEngine. emit ( Error . invalidArgumentValue ( Option . digesterMode. spelling, modeArg) )
556
+ }
557
+ }
558
+ self . digesterMode = mode
559
+
547
560
Self . validateWarningControlArgs ( & parsedOptions, diagnosticEngine: diagnosticEngine)
548
561
Self . validateProfilingArgs ( & parsedOptions,
549
562
fileSystem: fileSystem,
@@ -597,8 +610,6 @@ public struct Driver {
597
610
toolchain: toolchain,
598
611
targetInfo: frontendTargetInfo)
599
612
600
- Self . validateDigesterArgs ( & parsedOptions, moduleOutputInfo: moduleOutputInfo, diagnosticEngine: diagnosticsEngine)
601
-
602
613
Self . validateSanitizerAddressUseOdrIndicatorFlag ( & parsedOptions, diagnosticEngine: diagnosticsEngine, addressSanitizerEnabled: enabledSanitizers. contains ( . address) )
603
614
604
615
Self . validateSanitizerRecoverArgValues ( & parsedOptions, diagnosticEngine: diagnosticsEngine, enabledSanitizers: enabledSanitizers)
@@ -674,23 +685,10 @@ public struct Driver {
674
685
outputFileMap: self . outputFileMap,
675
686
moduleName: moduleOutputInfo. name,
676
687
projectDirectory: projectDirectory)
677
- self . apiBaselinePath = try Self . computeDigesterBaselineOutputPath (
678
- & parsedOptions,
679
- moduleOutputPath: self . moduleOutputInfo. output? . outputPath,
680
- type: . jsonAPIBaseline,
681
- isOutput: . emitAPIBaseline,
682
- outputPath: . emitAPIBaselinePath,
683
- compilerOutputType: compilerOutputType,
684
- compilerMode: compilerMode,
685
- outputFileMap: self . outputFileMap,
686
- moduleName: moduleOutputInfo. name,
687
- projectDirectory: projectDirectory)
688
- self . abiBaselinePath = try Self . computeDigesterBaselineOutputPath (
688
+ self . digesterBaselinePath = try Self . computeDigesterBaselineOutputPath (
689
689
& parsedOptions,
690
690
moduleOutputPath: self . moduleOutputInfo. output? . outputPath,
691
- type: . jsonABIBaseline,
692
- isOutput: . emitABIBaseline,
693
- outputPath: . emitABIBaselinePath,
691
+ mode: self . digesterMode,
694
692
compilerOutputType: compilerOutputType,
695
693
compilerMode: compilerMode,
696
694
outputFileMap: self . outputFileMap,
@@ -733,6 +731,12 @@ public struct Driver {
733
731
outputFileMap: self . outputFileMap,
734
732
moduleName: moduleOutputInfo. name)
735
733
734
+ Self . validateDigesterArgs ( & parsedOptions,
735
+ moduleOutputInfo: moduleOutputInfo,
736
+ digesterMode: self . digesterMode,
737
+ swiftInterfacePath: self . swiftInterfacePath,
738
+ diagnosticEngine: diagnosticsEngine)
739
+
736
740
try verifyOutputOptions ( )
737
741
}
738
742
@@ -2231,13 +2235,31 @@ extension Driver {
2231
2235
2232
2236
static func validateDigesterArgs( _ parsedOptions: inout ParsedOptions ,
2233
2237
moduleOutputInfo: ModuleOutputInfo ,
2238
+ digesterMode: DigesterMode ,
2239
+ swiftInterfacePath: VirtualPath . Handle ? ,
2234
2240
diagnosticEngine: DiagnosticsEngine ) {
2235
2241
if moduleOutputInfo. output? . isTopLevel != true {
2236
- for arg in parsedOptions. arguments ( for: . emitAPIBaseline, . emitAPIBaselinePath,
2237
- . emitABIBaseline, . emitABIBaselinePath) {
2242
+ for arg in parsedOptions. arguments ( for: . emitDigesterBaseline, . emitDigesterBaselinePath, . compareToBaselinePath) {
2238
2243
diagnosticEngine. emit ( Error . baselineGenerationRequiresTopLevelModule ( arg. option. spelling) )
2239
2244
}
2240
2245
}
2246
+
2247
+ if parsedOptions. hasArgument ( . serializeBreakingChangesPath) && !parsedOptions. hasArgument ( . compareToBaselinePath) {
2248
+ diagnosticEngine. emit ( Error . optionRequiresAnother ( Option . serializeBreakingChangesPath. spelling,
2249
+ Option . compareToBaselinePath. spelling) )
2250
+ }
2251
+ if parsedOptions. hasArgument ( . digesterBreakageAllowlistPath) && !parsedOptions. hasArgument ( . compareToBaselinePath) {
2252
+ diagnosticEngine. emit ( Error . optionRequiresAnother ( Option . digesterBreakageAllowlistPath. spelling,
2253
+ Option . compareToBaselinePath. spelling) )
2254
+ }
2255
+ if digesterMode == . abi && !parsedOptions. hasArgument ( . enableLibraryEvolution) {
2256
+ diagnosticEngine. emit ( Error . optionRequiresAnother ( " \( Option . digesterMode. spelling) abi " ,
2257
+ Option . enableLibraryEvolution. spelling) )
2258
+ }
2259
+ if digesterMode == . abi && swiftInterfacePath == nil {
2260
+ diagnosticEngine. emit ( Error . optionRequiresAnother ( " \( Option . digesterMode. spelling) abi " ,
2261
+ Option . emitModuleInterface. spelling) )
2262
+ }
2241
2263
}
2242
2264
2243
2265
@@ -2698,22 +2720,20 @@ extension Driver {
2698
2720
static func computeDigesterBaselineOutputPath(
2699
2721
_ parsedOptions: inout ParsedOptions ,
2700
2722
moduleOutputPath: VirtualPath . Handle ? ,
2701
- type: FileType ,
2702
- isOutput: Option ,
2703
- outputPath: Option ,
2723
+ mode: DigesterMode ,
2704
2724
compilerOutputType: FileType ? ,
2705
2725
compilerMode: CompilerMode ,
2706
2726
outputFileMap: OutputFileMap ? ,
2707
2727
moduleName: String ,
2708
2728
projectDirectory: VirtualPath . Handle ?
2709
2729
) throws -> VirtualPath . Handle ? {
2710
2730
// Only emit a baseline if at least of the arguments was provided.
2711
- guard parsedOptions. hasArgument ( isOutput , outputPath ) else { return nil }
2731
+ guard parsedOptions. hasArgument ( . emitDigesterBaseline , . emitDigesterBaselinePath ) else { return nil }
2712
2732
return try computeModuleAuxiliaryOutputPath ( & parsedOptions,
2713
2733
moduleOutputPath: moduleOutputPath,
2714
- type: type ,
2715
- isOutput: isOutput ,
2716
- outputPath: outputPath ,
2734
+ type: mode . baselineFileType ,
2735
+ isOutput: . emitDigesterBaseline ,
2736
+ outputPath: . emitDigesterBaselinePath ,
2717
2737
compilerOutputType: compilerOutputType,
2718
2738
compilerMode: compilerMode,
2719
2739
outputFileMap: outputFileMap,
0 commit comments