@@ -230,18 +230,14 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
230
230
commandLine: & commandLine)
231
231
232
232
let moduleMapPath = moduleDetails. moduleMapPath. path
233
- // Encode the target triple pcm args into the output `.pcm` filename
234
- let targetEncodedModulePath =
235
- try targetEncodedClangModuleFilePath ( for: moduleInfo,
236
- hashParts: getPCMHashParts ( pcmArgs: pcmArgs,
237
- contextHash: moduleDetails. contextHash) )
238
- outputs. append ( TypedVirtualPath ( file: targetEncodedModulePath, type: . pcm) )
233
+ let modulePCMPath = moduleInfo. modulePath
234
+ outputs. append ( TypedVirtualPath ( file: modulePCMPath. path, type: . pcm) )
239
235
commandLine. appendFlags ( " -emit-pcm " , " -module-name " , moduleId. moduleName,
240
- " -o " , targetEncodedModulePath . description)
236
+ " -o " , modulePCMPath . path . description)
241
237
242
238
// Fixup "-o -Xcc '<replace-me>'"
243
239
if let outputIndex = commandLine. firstIndex ( of: . flag( " <replace-me> " ) ) {
244
- commandLine [ outputIndex] = . path( VirtualPath . lookup ( targetEncodedModulePath ) )
240
+ commandLine [ outputIndex] = . path( VirtualPath . lookup ( modulePCMPath . path ) )
245
241
}
246
242
247
243
// The only required input is the .modulemap for this module.
@@ -300,21 +296,23 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
300
296
let clangModulePath =
301
297
TypedVirtualPath ( file: moduleArtifactInfo. modulePath. path,
302
298
type: . pcm)
299
+ let clangModuleMapPath =
300
+ TypedVirtualPath ( file: moduleArtifactInfo. moduleMapPath. path,
301
+ type: . clangModuleMap)
302
+ inputs. append ( clangModulePath)
303
+ inputs. append ( clangModuleMapPath)
304
+
303
305
// If an existing dependency module path stub exists, replace it.
304
306
if let existingIndex = commandLine. firstIndex ( of: . flag( " -fmodule-file= " + moduleArtifactInfo. moduleName + " =<replace-me> " ) ) {
305
307
commandLine [ existingIndex] = . flag( " -fmodule-file= \( moduleArtifactInfo. moduleName) = \( clangModulePath. file. description) " )
306
- } else {
308
+ } else if case . swift ( _ ) = moduleId {
307
309
commandLine. appendFlags ( " -Xcc " ,
308
310
" -fmodule-file= \( moduleArtifactInfo. moduleName) = \( clangModulePath. file. description) " )
309
311
}
310
-
311
- let clangModuleMapPath =
312
- TypedVirtualPath ( file: moduleArtifactInfo. moduleMapPath. path,
313
- type: . clangModuleMap)
314
- commandLine. appendFlags ( " -Xcc " ,
315
- " -fmodule-map-file= \( clangModuleMapPath. file. description) " )
316
- inputs. append ( clangModulePath)
317
- inputs. append ( clangModuleMapPath)
312
+ if case . swift( _) = moduleId {
313
+ commandLine. appendFlags ( " -Xcc " ,
314
+ " -fmodule-map-file= \( clangModuleMapPath. file. description) " )
315
+ }
318
316
}
319
317
}
320
318
@@ -346,14 +344,10 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
346
344
let dependencyInfo = try dependencyGraph. moduleInfo ( of: dependencyId)
347
345
let dependencyClangModuleDetails =
348
346
try dependencyGraph. clangModuleDetails ( of: dependencyId)
349
- let clangModulePath =
350
- try targetEncodedClangModuleFilePath ( for: dependencyInfo,
351
- hashParts: getPCMHashParts ( pcmArgs: pcmArgs,
352
- contextHash: dependencyClangModuleDetails. contextHash) )
353
347
// Accumulate the required information about this dependency
354
348
clangDependencyArtifacts. append (
355
349
ClangModuleArtifactInfo ( name: dependencyId. moduleName,
356
- modulePath: TextualVirtualPath ( path: clangModulePath ) ,
350
+ modulePath: TextualVirtualPath ( path: dependencyInfo . modulePath . path ) ,
357
351
moduleMapPath: dependencyClangModuleDetails. moduleMapPath) )
358
352
case . swiftPrebuiltExternal:
359
353
let prebuiltModuleDetails = try dependencyGraph. swiftPrebuiltDetails ( of: dependencyId)
@@ -435,41 +429,6 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
435
429
}
436
430
}
437
431
438
- /// Utility methods for encoding PCM's target triple into its name.
439
- extension ExplicitDependencyBuildPlanner {
440
- /// Compute a full path to the resulting .pcm file for a given Clang module, with the
441
- /// target triple encoded in the name.
442
- public mutating func targetEncodedClangModuleFilePath( for moduleInfo: ModuleInfo ,
443
- hashParts: [ String ] ) throws -> VirtualPath . Handle {
444
- let plainModulePath = VirtualPath . lookup ( moduleInfo. modulePath. path)
445
- let targetEncodedBaseName =
446
- try targetEncodedClangModuleName ( for: plainModulePath. basenameWithoutExt,
447
- hashParts: hashParts)
448
- let modifiedModulePath =
449
- moduleInfo. modulePath. path. description
450
- . replacingOccurrences ( of: plainModulePath. basenameWithoutExt,
451
- with: targetEncodedBaseName)
452
- return try VirtualPath . intern ( path: modifiedModulePath)
453
- }
454
-
455
- /// Compute the name of a given Clang module, along with a hash of extra PCM build arguments it
456
- /// is to be constructed with.
457
- @_spi ( Testing) public mutating func targetEncodedClangModuleName( for moduleName: String ,
458
- hashParts: [ String ] )
459
- throws -> String {
460
- let hashInput = hashParts. sorted ( ) . joined ( )
461
- // Hash based on "moduleName + hashInput"
462
- let cacheQuery = moduleName + hashInput
463
- if let previouslyHashsedName = hashedModuleNameCache [ cacheQuery] {
464
- return previouslyHashsedName
465
- }
466
- let hashedArguments = SHA256 ( ) . hash ( hashInput) . hexadecimalRepresentation
467
- let resultingName = moduleName + " - " + hashedArguments
468
- hashedModuleNameCache [ cacheQuery] = resultingName
469
- return resultingName
470
- }
471
- }
472
-
473
432
/// Encapsulates some of the common queries of the ExplicitDependencyBuildPlanner with error-checking
474
433
/// on the dependency graph's structure.
475
434
@_spi ( Testing) public extension InterModuleDependencyGraph {
0 commit comments