@@ -45,7 +45,7 @@ extension LLBuildManifestBuilder {
45
45
let moduleNode = Node . file ( target. moduleOutputPath)
46
46
let cmdOutputs = objectNodes + [ moduleNode]
47
47
48
- if target. defaultBuildParameters . driverParameters. useIntegratedSwiftDriver {
48
+ if target. buildParameters . driverParameters. useIntegratedSwiftDriver {
49
49
try self . addSwiftCmdsViaIntegratedDriver (
50
50
target,
51
51
inputs: inputs,
@@ -68,7 +68,7 @@ extension LLBuildManifestBuilder {
68
68
// jobs needed to build this Swift target.
69
69
var commandLine = try target. emitCommandLine ( )
70
70
commandLine. append ( " -driver-use-frontend-path " )
71
- commandLine. append ( target. defaultBuildParameters . toolchain. swiftCompilerPath. pathString)
71
+ commandLine. append ( target. buildParameters . toolchain. swiftCompilerPath. pathString)
72
72
// FIXME: At some point SwiftPM should provide its own executor for
73
73
// running jobs/launching processes during planning
74
74
let resolver = try ArgsResolver ( fileSystem: target. fileSystem)
@@ -132,7 +132,7 @@ extension LLBuildManifestBuilder {
132
132
// common intermediate dependency modules, such dependencies can lead
133
133
// to cycles in the resulting manifest.
134
134
var manifestNodeInputs : [ Node ] = [ ]
135
- if targetDescription. defaultBuildParameters . driverParameters. useExplicitModuleBuild && !isMainModule( job) {
135
+ if targetDescription. buildParameters . driverParameters. useExplicitModuleBuild && !isMainModule( job) {
136
136
manifestNodeInputs = jobInputs
137
137
} else {
138
138
manifestNodeInputs = ( inputs + jobInputs) . uniqued ( )
@@ -191,11 +191,8 @@ extension LLBuildManifestBuilder {
191
191
public func addTargetsToExplicitBuildManifest( ) throws {
192
192
// Sort the product targets in topological order in order to collect and "bubble up"
193
193
// their respective dependency graphs to the depending targets.
194
- let nodes : [ ResolvedModule . Dependency ] = try self . plan. targetMap. keys. compactMap {
195
- guard let target = self . plan. graph. allTargets [ $0] else {
196
- throw InternalError ( " unknown target \( $0) " )
197
- }
198
- return ResolvedModule . Dependency. target ( target, conditions: [ ] )
194
+ let nodes = self . plan. targets. compactMap {
195
+ ResolvedModule . Dependency. target ( $0. target, conditions: [ ] )
199
196
}
200
197
let allPackageDependencies = try topologicalSort ( nodes, successors: { $0. dependencies } )
201
198
// Instantiate the inter-module dependency oracle which will cache commonly-scanned
@@ -287,7 +284,7 @@ extension LLBuildManifestBuilder {
287
284
// jobs needed to build this Swift target.
288
285
var commandLine = try targetDescription. emitCommandLine ( )
289
286
commandLine. append ( " -driver-use-frontend-path " )
290
- commandLine. append ( targetDescription. defaultBuildParameters . toolchain. swiftCompilerPath. pathString)
287
+ commandLine. append ( targetDescription. buildParameters . toolchain. swiftCompilerPath. pathString)
291
288
commandLine. append ( " -experimental-explicit-module-build " )
292
289
let resolver = try ArgsResolver ( fileSystem: self . fileSystem)
293
290
let executor = SPMSwiftDriverExecutor (
@@ -378,14 +375,14 @@ extension LLBuildManifestBuilder {
378
375
cmdOutputs: [ Node ]
379
376
) throws {
380
377
let isLibrary = target. target. type == . library || target. target. type == . test
381
- let cmdName = target. target . getCommandName ( buildParameters : target . defaultBuildParameters )
378
+ let cmdName = target. getCommandName ( )
382
379
383
380
self . manifest. addWriteSourcesFileListCommand ( sources: target. sources, sourcesFileListPath: target. sourcesFileListPath)
384
381
self . manifest. addSwiftCmd (
385
382
name: cmdName,
386
383
inputs: inputs + [ Node . file ( target. sourcesFileListPath) ] ,
387
384
outputs: cmdOutputs,
388
- executable: target. defaultBuildParameters . toolchain. swiftCompilerPath,
385
+ executable: target. buildParameters . toolchain. swiftCompilerPath,
389
386
moduleName: target. target. c99name,
390
387
moduleAliases: target. target. moduleAliases,
391
388
moduleOutputPath: target. moduleOutputPath,
@@ -396,7 +393,7 @@ extension LLBuildManifestBuilder {
396
393
sources: target. sources,
397
394
fileList: target. sourcesFileListPath,
398
395
isLibrary: isLibrary,
399
- wholeModuleOptimization: target. defaultBuildParameters . configuration == . release,
396
+ wholeModuleOptimization: target. buildParameters . configuration == . release,
400
397
outputFileMapPath: try target. writeOutputFileMap ( ) // FIXME: Eliminate side effect.
401
398
)
402
399
}
@@ -406,7 +403,7 @@ extension LLBuildManifestBuilder {
406
403
) throws -> [ Node ] {
407
404
var inputs = target. sources. map ( Node . file)
408
405
409
- let swiftVersionFilePath = addSwiftGetVersionCommand ( buildParameters: target. defaultBuildParameters )
406
+ let swiftVersionFilePath = addSwiftGetVersionCommand ( buildParameters: target. buildParameters )
410
407
inputs. append ( . file( swiftVersionFilePath) )
411
408
412
409
// Add resources node as the input to the target. This isn't great because we
@@ -433,14 +430,10 @@ extension LLBuildManifestBuilder {
433
430
// Depend on the binary for executable targets.
434
431
if target. type == . executable {
435
432
// FIXME: Optimize.
436
- let product = try plan. graph. allProducts. first {
437
- try $0. type == . executable && $0. executableTarget. id == target. id
438
- }
439
- if let product {
440
- guard let planProduct = plan. productMap [ product. id] else {
441
- throw InternalError ( " unknown product \( product) " )
442
- }
443
- try inputs. append ( file: planProduct. binaryPath)
433
+ if let productDescription = try plan. productMap. values. first ( where: {
434
+ try $0. product. type == . executable && $0. product. executableTarget. id == target. id
435
+ } ) {
436
+ try inputs. append ( file: productDescription. binaryPath)
444
437
}
445
438
return
446
439
}
@@ -457,7 +450,7 @@ extension LLBuildManifestBuilder {
457
450
}
458
451
}
459
452
460
- for dependency in target. target. dependencies ( satisfying: target. defaultBuildParameters . buildEnvironment) {
453
+ for dependency in target. target. dependencies ( satisfying: target. buildParameters . buildEnvironment) {
461
454
switch dependency {
462
455
case . target( let target, _) :
463
456
try addStaticTargetInputs ( target)
@@ -484,7 +477,7 @@ extension LLBuildManifestBuilder {
484
477
}
485
478
486
479
for binaryPath in target. libraryBinaryPaths {
487
- let path = target. defaultBuildParameters . destinationPath ( forBinaryAt: binaryPath)
480
+ let path = target. buildParameters . destinationPath ( forBinaryAt: binaryPath)
488
481
if self . fileSystem. isDirectory ( binaryPath) {
489
482
inputs. append ( directory: path)
490
483
} else {
@@ -496,7 +489,7 @@ extension LLBuildManifestBuilder {
496
489
497
490
// Depend on any required macro product's output.
498
491
try target. requiredMacroProducts. forEach { macro in
499
- try inputs. append ( . virtual( macro. getLLBuildTargetName ( buildParameters : target . defaultBuildParameters ) ) )
492
+ try inputs. append ( . virtual( macro. llbuildTargetName ) )
500
493
}
501
494
502
495
return inputs + additionalInputs
@@ -505,7 +498,7 @@ extension LLBuildManifestBuilder {
505
498
/// Adds a top-level phony command that builds the entire target.
506
499
private func addTargetCmd( _ target: SwiftTargetBuildDescription , cmdOutputs: [ Node ] ) {
507
500
// Create a phony node to represent the entire target.
508
- let targetName = target. target . getLLBuildTargetName ( buildParameters : target . defaultBuildParameters )
501
+ let targetName = target. getLLBuildTargetName ( )
509
502
let targetOutput : Node = . virtual( targetName)
510
503
511
504
self . manifest. addNode ( targetOutput, toTarget: targetName)
@@ -514,7 +507,7 @@ extension LLBuildManifestBuilder {
514
507
inputs: cmdOutputs,
515
508
outputs: [ targetOutput]
516
509
)
517
- if self . plan. graph. isInRootPackages ( target. target, satisfying: target. defaultBuildParameters . buildEnvironment) {
510
+ if self . plan. graph. isInRootPackages ( target. target, satisfying: target. buildParameters . buildEnvironment) {
518
511
if !target. isTestTarget {
519
512
self . addNode ( targetOutput, toTarget: . main)
520
513
}
@@ -524,13 +517,13 @@ extension LLBuildManifestBuilder {
524
517
525
518
private func addModuleWrapCmd( _ target: SwiftTargetBuildDescription ) throws {
526
519
// Add commands to perform the module wrapping Swift modules when debugging strategy is `modulewrap`.
527
- guard target. defaultBuildParameters . debuggingStrategy == . modulewrap else { return }
520
+ guard target. buildParameters . debuggingStrategy == . modulewrap else { return }
528
521
var moduleWrapArgs = [
529
- target. defaultBuildParameters . toolchain. swiftCompilerPath. pathString,
522
+ target. buildParameters . toolchain. swiftCompilerPath. pathString,
530
523
" -modulewrap " , target. moduleOutputPath. pathString,
531
524
" -o " , target. wrappedModuleOutputPath. pathString,
532
525
]
533
- moduleWrapArgs += try target. defaultBuildParameters . tripleArgs ( for: target. target)
526
+ moduleWrapArgs += try target. buildParameters . tripleArgs ( for: target. target)
534
527
self . manifest. addShellCmd (
535
528
name: target. wrappedModuleOutputPath. pathString,
536
529
description: " Wrapping AST for \( target. target. name) for debugging " ,
@@ -611,3 +604,13 @@ extension Driver {
611
604
}
612
605
}
613
606
}
607
+
608
+ extension SwiftTargetBuildDescription {
609
+ public func getCommandName( ) -> String {
610
+ " C. " + self . getLLBuildTargetName ( )
611
+ }
612
+
613
+ public func getLLBuildTargetName( ) -> String {
614
+ self . target. getLLBuildTargetName ( buildParameters: self . buildParameters)
615
+ }
616
+ }
0 commit comments