@@ -32,10 +32,6 @@ public enum SwiftBuildServicePIFObjectType: Sendable {
32
32
}
33
33
}
34
34
35
- private protocol InvalidateDeprecated {
36
- func invalidateDeprecated( isolated: ( any Actor ) ? ) async throws
37
- }
38
-
39
35
/// This class encapsulates a unique session connection to the inferior build service process.
40
36
///
41
37
/// The state for each individual session is separated, and generally a unique session is used for each separate workspace, project, etc. that a client may want to build
@@ -57,9 +53,7 @@ public final class SWBBuildServiceSession: Sendable {
57
53
/// For macro evaluation scopes, the session will register each newly created scope with the tracker. If the client manually discards the scope, it will be removed from the tracker by the session. If the client does not manually discard their scopes, they will be cleaned up by the tracker when the session is closed.
58
54
///
59
55
/// For build operations, the tracker implements a generic background operation queue. Closures are enqueued to a stream, and consumed and awaited on a background task. Closing the session awaits that background taskto ensure all closures are awaited before continuing with teardown.
60
- private actor SessionResourceTracker : InvalidateDeprecated {
61
- @available ( * , deprecated, message: " SWBMacroEvaluationScope is deprecated and should not be used " )
62
- private var macroEvaluationScopes : [ String : SWBMacroEvaluationScope ] = [ : ]
56
+ private actor SessionResourceTracker {
63
57
private var awaitableBuildOperations : AsyncStreamController < SWBBuildOperation , Never >
64
58
private let cancellableBuildOperationsHolder = CancellableBuildOperationsHolder ( )
65
59
@@ -94,16 +88,6 @@ public final class SWBBuildServiceSession: Sendable {
94
88
}
95
89
}
96
90
97
- @available ( * , deprecated, message: " SWBMacroEvaluationScope is deprecated and should not be used " )
98
- func append( _ scope: SWBMacroEvaluationScope ) {
99
- macroEvaluationScopes [ scope. settingsHandle] = scope
100
- }
101
-
102
- @available ( * , deprecated, message: " SWBMacroEvaluationScope is deprecated and should not be used " )
103
- func remove( _ scope: SWBMacroEvaluationScope ) {
104
- macroEvaluationScopes. removeValue ( forKey: scope. settingsHandle)
105
- }
106
-
107
91
func enqueue( _ operation: SWBBuildOperation ) async {
108
92
let queuedResult = awaitableBuildOperations. yield ( operation)
109
93
switch queuedResult {
@@ -128,22 +112,6 @@ public final class SWBBuildServiceSession: Sendable {
128
112
awaitableBuildOperations. finish ( )
129
113
await cancellableBuildOperationsHolder. cancelAll ( )
130
114
await awaitableBuildOperations. wait ( )
131
-
132
- try await ( self as ( any InvalidateDeprecated ) ) . invalidateDeprecated ( isolated: #isolation)
133
- }
134
-
135
- @available ( * , deprecated, message: " SWBMacroEvaluationScope is deprecated and should not be used " )
136
- func invalidateDeprecated( isolated: ( any Actor ) ? ) async throws {
137
- let scopes = macroEvaluationScopes. values
138
- macroEvaluationScopes = [ : ]
139
- try await withThrowingTaskGroup ( of: Void . self) { group in
140
- for scope in scopes {
141
- group. addTask {
142
- try await scope. invalidate ( )
143
- }
144
- }
145
- try await group. waitForAll ( )
146
- }
147
115
}
148
116
}
149
117
@@ -441,70 +409,42 @@ public final class SWBBuildServiceSession: Sendable {
441
409
}
442
410
443
411
444
- // Helper methods to package up a request and send it to the service.
445
- // These methods are used both by the public methods below, and by those in SWBMacroEvaluationScope.
446
-
447
- func evaluateMacroAsString( _ macro: String , context: MacroEvaluationRequestContext , overrides: [ String : String ] ? ) async throws -> String {
448
- let request = MacroEvaluationRequest ( sessionHandle: uid, context: context, request: . macro( macro) , overrides: overrides, resultType: . string)
449
- return try await sendMacroEvaluationStringRequest ( self , request)
450
- }
451
-
452
- func evaluateMacroAsStringList( _ macro: String , context: MacroEvaluationRequestContext , overrides: [ String : String ] ? ) async throws -> [ String ] {
453
- let request = MacroEvaluationRequest ( sessionHandle: uid, context: context, request: . macro( macro) , overrides: overrides, resultType: . stringList)
454
- return try await sendMacroEvaluationStringListRequest ( self , request)
455
- }
456
-
457
- func evaluateMacroAsBoolean( _ macro: String , context: MacroEvaluationRequestContext , overrides: [ String : String ] ? ) async throws -> Bool {
458
- let request = MacroEvaluationRequest ( sessionHandle: uid, context: context, request: . macro( macro) , overrides: overrides, resultType: . string)
459
- return try await sendMacroEvaluationStringRequest ( self , request) == " YES "
460
- }
461
-
462
- func evaluateMacroExpressionAsString( _ expr: String , context: MacroEvaluationRequestContext , overrides: [ String : String ] ? ) async throws -> String {
463
- let request = MacroEvaluationRequest ( sessionHandle: uid, context: context, request: . stringExpression( expr) , overrides: overrides, resultType: . string)
464
- return try await sendMacroEvaluationStringRequest ( self , request)
465
- }
466
-
467
- func evaluateMacroExpressionAsStringList( _ expr: String , context: MacroEvaluationRequestContext , overrides: [ String : String ] ? ) async throws -> [ String ] {
468
- let request = MacroEvaluationRequest ( sessionHandle: uid, context: context, request: . stringExpression( expr) , overrides: overrides, resultType: . stringList)
469
- return try await sendMacroEvaluationStringListRequest ( self , request)
470
- }
471
-
472
- func evaluateMacroExpressionArrayAsStringList( _ expr: [ String ] , context: MacroEvaluationRequestContext , overrides: [ String : String ] ? ) async throws -> [ String ] {
473
- let request = MacroEvaluationRequest ( sessionHandle: uid, context: context, request: . stringExpressionArray( expr) , overrides: overrides, resultType: . stringList)
474
- return try await sendMacroEvaluationStringListRequest ( self , request)
475
- }
476
-
477
-
478
412
// Public methods to perform macro evaluations for a level and build parameters.
479
413
480
414
public func evaluateMacroAsString( _ macro: String, level: SWBMacroEvaluationLevel, buildParameters: SWBBuildParameters, overrides: [ String : String] ? ) async throws -> String {
481
415
let parameters = buildParameters. messagePayloadRepresentation
482
- return try await evaluateMacroAsString ( macro, context: . components( level: level. toSWBRequest, buildParameters: parameters) , overrides: overrides)
416
+ let request = MacroEvaluationRequest ( sessionHandle: uid, context: . components( level: level. toSWBRequest, buildParameters: parameters) , request: . macro( macro) , overrides: overrides, resultType: . string)
417
+ return try await sendMacroEvaluationStringRequest ( self , request)
483
418
}
484
419
485
420
public func evaluateMacroAsStringList( _ macro: String, level: SWBMacroEvaluationLevel, buildParameters: SWBBuildParameters, overrides: [ String : String] ? ) async throws -> [ String] {
486
421
let parameters = buildParameters. messagePayloadRepresentation
487
- return try await evaluateMacroAsStringList ( macro, context: . components( level: level. toSWBRequest, buildParameters: parameters) , overrides: overrides)
422
+ let request = MacroEvaluationRequest ( sessionHandle: uid, context: . components( level: level. toSWBRequest, buildParameters: parameters) , request: . macro( macro) , overrides: overrides, resultType: . stringList)
423
+ return try await sendMacroEvaluationStringListRequest ( self , request)
488
424
}
489
425
490
426
public func evaluateMacroAsBoolean( _ macro: String, level: SWBMacroEvaluationLevel, buildParameters: SWBBuildParameters, overrides: [ String : String] ? ) async throws -> Bool {
491
427
let parameters = buildParameters. messagePayloadRepresentation
492
- return try await evaluateMacroAsBoolean ( macro, context: . components( level: level. toSWBRequest, buildParameters: parameters) , overrides: overrides)
428
+ let request = MacroEvaluationRequest ( sessionHandle: uid, context: . components( level: level. toSWBRequest, buildParameters: parameters) , request: . macro( macro) , overrides: overrides, resultType: . string)
429
+ return try await sendMacroEvaluationStringRequest ( self , request) == " YES "
493
430
}
494
431
495
432
public func evaluateMacroExpressionAsString( _ expr: String, level: SWBMacroEvaluationLevel, buildParameters: SWBBuildParameters, overrides: [ String : String] ? ) async throws -> String {
496
433
let parameters = buildParameters. messagePayloadRepresentation
497
- return try await evaluateMacroExpressionAsString ( expr, context: . components( level: level. toSWBRequest, buildParameters: parameters) , overrides: overrides)
434
+ let request = MacroEvaluationRequest ( sessionHandle: uid, context: . components( level: level. toSWBRequest, buildParameters: parameters) , request: . stringExpression( expr) , overrides: overrides, resultType: . string)
435
+ return try await sendMacroEvaluationStringRequest ( self , request)
498
436
}
499
437
500
438
public func evaluateMacroExpressionAsStringList( _ expr: String, level: SWBMacroEvaluationLevel, buildParameters: SWBBuildParameters, overrides: [ String : String] ? ) async throws -> [ String] {
501
439
let parameters = buildParameters. messagePayloadRepresentation
502
- return try await evaluateMacroExpressionAsStringList ( expr, context: . components( level: level. toSWBRequest, buildParameters: parameters) , overrides: overrides)
440
+ let request = MacroEvaluationRequest ( sessionHandle: uid, context: . components( level: level. toSWBRequest, buildParameters: parameters) , request: . stringExpression( expr) , overrides: overrides, resultType: . stringList)
441
+ return try await sendMacroEvaluationStringListRequest ( self , request)
503
442
}
504
443
505
444
public func evaluateMacroExpressionArrayAsStringList( _ expr: [ String] , level: SWBMacroEvaluationLevel, buildParameters: SWBBuildParameters, overrides: [ String : String] ? ) async throws -> [ String] {
506
445
let parameters = buildParameters. messagePayloadRepresentation
507
- return try await evaluateMacroExpressionArrayAsStringList ( expr, context: . components( level: level. toSWBRequest, buildParameters: parameters) , overrides: overrides)
446
+ let request = MacroEvaluationRequest ( sessionHandle: uid, context: . components( level: level. toSWBRequest, buildParameters: parameters) , request: . stringExpressionArray( expr) , overrides: overrides, resultType: . stringList)
447
+ return try await sendMacroEvaluationStringListRequest ( self , request)
508
448
}
509
449
510
450
@@ -525,61 +465,6 @@ public final class SWBBuildServiceSession: Sendable {
525
465
}
526
466
527
467
528
- // MARK: Macro evaluation scopes
529
-
530
-
531
- // FIXME: rdar://142511013 (Remove deprecated macro evaluation scope logic from SWBuild)
532
- /// Request a macro evaluation scope for given level and build parameters.
533
- @available ( * , deprecated, message: " SWBMacroEvaluationScope is deprecated and should not be used " )
534
- public func createMacroEvaluationScope( level: SWBMacroEvaluationLevel , buildParameters: SWBBuildParameters ) async throws -> SWBMacroEvaluationScope {
535
- let parameters = buildParameters. messagePayloadRepresentation
536
- let request = CreateMacroEvaluationScopeRequest ( sessionHandle: uid, level: level. toSWBRequest, buildParameters: parameters)
537
- let scope = try await SWBMacroEvaluationScope ( self , service. send ( request: request) . value)
538
- await sessionResourceTracker. append ( scope)
539
- return scope
540
- }
541
-
542
- // FIXME: rdar://142511013 (Remove deprecated macro evaluation scope logic from SWBuild)
543
- @available ( * , deprecated, message: " SWBMacroEvaluationScope is deprecated and should not be used " )
544
- public func createMacroEvaluationScope( _ level: MacroEvaluationScopeLevel , buildParameters: SWBBuildParameters ) async throws -> SWBMacroEvaluationScope {
545
- switch level {
546
- case . defaults:
547
- return try await createMacroEvaluationScope ( level: . defaults, buildParameters: buildParameters)
548
- case . project( let guid) :
549
- return try await createMacroEvaluationScope ( level: . project( guid) , buildParameters: buildParameters)
550
- case . target( let guid) :
551
- return try await createMacroEvaluationScope ( level: . target( guid) , buildParameters: buildParameters)
552
- }
553
- }
554
-
555
- // FIXME: rdar://142511013 (Remove deprecated macro evaluation scope logic from SWBuild)
556
- @available ( * , deprecated, message: " MacroEvaluationScopeLevel is deprecated and should not be used " )
557
- public enum MacroEvaluationScopeLevel : Sendable {
558
- case defaults
559
- case project( _ guid: String )
560
- case target( _ guid: String )
561
- }
562
-
563
- // FIXME: rdar://142511013 (Remove deprecated macro evaluation scope logic from SWBuild)
564
- @available ( * , deprecated, message: " SWBMacroEvaluationScope is deprecated and should not be used " )
565
- public func createMacroEvaluationScope( projectGUID: String , buildParameters: SWBBuildParameters ) async throws -> SWBMacroEvaluationScope {
566
- return try await createMacroEvaluationScope ( level: . project( projectGUID) , buildParameters: buildParameters)
567
- }
568
-
569
- // FIXME: rdar://142511013 (Remove deprecated macro evaluation scope logic from SWBuild)
570
- @available ( * , deprecated, message: " SWBMacroEvaluationScope is deprecated and should not be used " )
571
- public func createMacroEvaluationScope( targetGUID: String , buildParameters: SWBBuildParameters ) async throws -> SWBMacroEvaluationScope {
572
- return try await createMacroEvaluationScope ( level: . project( targetGUID) , buildParameters: buildParameters)
573
- }
574
-
575
- // FIXME: rdar://142511013 (Remove deprecated macro evaluation scope logic from SWBuild)
576
- /// Discard a macro evaluation scope.
577
- @available ( * , deprecated, message: " SWBMacroEvaluationScope is deprecated and should not be used " )
578
- public func discardMacroEvaluationScope( _ scope: SWBMacroEvaluationScope ) async throws {
579
- await sessionResourceTracker. remove ( scope)
580
- _ = try await service. send ( request: DiscardMacroEvaluationScope ( sessionHandle: uid, settingsHandle: scope. settingsHandle) )
581
- }
582
-
583
468
/// Loads the workspace at the specified container path.
584
469
///
585
470
/// The container path may be:
0 commit comments