@@ -395,6 +395,9 @@ public struct Driver {
395395
396396 /// Path to the Swift module source information file.
397397 let moduleSourceInfoPath : VirtualPath . Handle ?
398+
399+ /// Path to the emitted API descriptor file.
400+ let apiDescriptorFilePath : VirtualPath . Handle ?
398401 }
399402
400403 private static func computeModuleOutputPaths(
@@ -424,6 +427,24 @@ public struct Driver {
424427 moduleName: moduleOutputInfo. name,
425428 projectDirectory: projectDirectory)
426429
430+ // ---------------------
431+ // API Descriptor Path
432+ let apiDescriptorFilePath : VirtualPath . Handle ?
433+ if let apiDescriptorDirectory = apiDescriptorDirectory {
434+ apiDescriptorFilePath = apiDescriptorDirectory
435+ . appending ( component: " \( moduleOutputInfo. name) . \( target. moduleTriple. triple) .swift.sdkdb " )
436+ . intern ( )
437+ } else {
438+ apiDescriptorFilePath = try Self . computeSupplementaryOutputPath (
439+ & parsedOptions, type: . jsonAPIDescriptor, isOutputOptions: [ ] ,
440+ outputPath: . emitApiDescriptorPath,
441+ compilerOutputType: compilerOutputType,
442+ compilerMode: compilerMode,
443+ emitModuleSeparately: emitModuleSeparately,
444+ outputFileMap: outputFileMap,
445+ moduleName: moduleOutputInfo. name)
446+ }
447+
427448 // ---------------------
428449 // Swift interface paths
429450 let swiftInterfacePath = try Self . computeSupplementaryOutputPath (
@@ -492,6 +513,7 @@ public struct Driver {
492513 swiftPrivateInterfacePath: swiftPrivateInterfacePath,
493514 swiftPackageInterfacePath: swiftPackageInterfacePath,
494515 moduleSourceInfoPath: moduleSourceInfoPath)
516+ apiDescriptorFilePath: apiDescriptorFilePath)
495517 }
496518
497519 /// Structure storing paths to supplemental outputs for the target module
@@ -509,8 +531,6 @@ public struct Driver {
509531 /// Path to the module's digester baseline file.
510532 let digesterBaselinePath : VirtualPath . Handle ?
511533
512- /// Path to the emitted API descriptor file.
513- let apiDescriptorFilePath : VirtualPath . Handle ?
514534
515535 /// The mode the API digester should run in.
516536 let digesterMode : DigesterMode
@@ -1151,6 +1171,13 @@ public struct Driver {
11511171 moduleOutputPath: moduleOutputInfo. output? . outputPath,
11521172 fileSystem: self . fileSystem)
11531173
1174+ var apiDescriptorDirectory : VirtualPath ? = nil
1175+ if let apiDescriptorDirectoryEnvVar = env [ " TAPI_SDKDB_OUTPUT_PATH " ] {
1176+ apiDescriptorDirectory = try VirtualPath ( path: apiDescriptorDirectoryEnvVar)
1177+ } else if let ldTraceFileEnvVar = env [ " LD_TRACE_FILE " ] {
1178+ apiDescriptorDirectory = try VirtualPath ( path: ldTraceFileEnvVar) . parentDirectory. appending ( component: " SDKDB " )
1179+ }
1180+
11541181 self . moduleOutputPaths = try Self . computeModuleOutputPaths (
11551182 & parsedOptions,
11561183 moduleName: moduleOutputInfo. name,
@@ -1161,8 +1188,11 @@ public struct Driver {
11611188 emitModuleSeparately: emitModuleSeparately,
11621189 outputFileMap: self . outputFileMap,
11631190 projectDirectory: projectDirectory)
1191+ apiDescriptorDirectory: apiDescriptorDirectory,
1192+ target: frontendTargetInfo. target)
11641193
11651194 if let variantModuleOutputInfo = self . variantModuleOutputInfo {
1195+ let targetVariant = self . frontendTargetInfo. targetVariant {
11661196 self . variantModuleOutputPaths = try Self . computeModuleOutputPaths (
11671197 & parsedOptions,
11681198 moduleName: variantModuleOutputInfo. name,
@@ -1172,7 +1202,9 @@ public struct Driver {
11721202 compilerMode: compilerMode,
11731203 emitModuleSeparately: true , // variant module is always independent
11741204 outputFileMap: self . outputFileMap,
1175- projectDirectory: projectDirectory)
1205+ projectDirectory: projectDirectory,
1206+ apiDescriptorDirectory: apiDescriptorDirectory,
1207+ target: targetVariant)
11761208 } else {
11771209 self . variantModuleOutputPaths = nil
11781210 }
@@ -1210,27 +1242,6 @@ public struct Driver {
12101242 outputFileMap: self . outputFileMap,
12111243 moduleName: moduleOutputInfo. name)
12121244
1213- var apiDescriptorDirectory : VirtualPath ? = nil
1214- if let apiDescriptorDirectoryEnvVar = env [ " TAPI_SDKDB_OUTPUT_PATH " ] {
1215- apiDescriptorDirectory = try VirtualPath ( path: apiDescriptorDirectoryEnvVar)
1216- } else if let ldTraceFileEnvVar = env [ " LD_TRACE_FILE " ] {
1217- apiDescriptorDirectory = try VirtualPath ( path: ldTraceFileEnvVar) . parentDirectory. appending ( component: " SDKDB " )
1218- }
1219- if let apiDescriptorDirectory = apiDescriptorDirectory {
1220- self . apiDescriptorFilePath = apiDescriptorDirectory
1221- . appending ( component: " \( moduleOutputInfo. name) . \( frontendTargetInfo. target. moduleTriple. triple) .swift.sdkdb " )
1222- . intern ( )
1223- } else {
1224- self . apiDescriptorFilePath = try Self . computeSupplementaryOutputPath (
1225- & parsedOptions, type: . jsonAPIDescriptor, isOutputOptions: [ ] ,
1226- outputPath: . emitApiDescriptorPath,
1227- compilerOutputType: compilerOutputType,
1228- compilerMode: compilerMode,
1229- emitModuleSeparately: emitModuleSeparately,
1230- outputFileMap: self . outputFileMap,
1231- moduleName: moduleOutputInfo. name)
1232- }
1233-
12341245 Self . validateDigesterArgs ( & parsedOptions,
12351246 moduleOutputInfo: moduleOutputInfo,
12361247 digesterMode: self . digesterMode,
0 commit comments