@@ -3,7 +3,9 @@ import ToolCommon
3
3
import ZippyJSON
4
4
5
5
struct OutputGroupsCalculator {
6
- func calculateOutputGroups( arguments: Arguments ) async throws {
6
+ let logger : Logger
7
+
8
+ func calculateOutputGroups( arguments: Arguments ) async throws -> String {
7
9
let pifCache = arguments. baseObjRoot. appendingPathComponent ( " XCBuildData/PIFCache " )
8
10
let projectCache = pifCache. appendingPathComponent ( " project " )
9
11
let targetCache = pifCache. appendingPathComponent ( " target " )
@@ -30,12 +32,11 @@ struct OutputGroupsCalculator {
30
32
targetCache: targetCache
31
33
)
32
34
33
- let output = try await outputGroups (
35
+ return try await outputGroups (
34
36
buildRequest: buildRequest,
35
37
targets: targetMap,
36
38
prefixes: arguments. outputGroupPrefixes
37
39
)
38
- print ( output)
39
40
}
40
41
41
42
private func loadBuildRequestFile( inPath path: URL , since: Date ) async throws -> BuildRequest {
@@ -54,22 +55,33 @@ struct OutputGroupsCalculator {
54
55
}
55
56
56
57
// If the file was not immediately found, kick off a process to wait for the file to be created (or time out).
57
- let findTask = Task {
58
- while true {
59
- try Task . checkCancellation ( )
60
- try await Task . sleep ( for: . seconds( 1 ) )
61
- if let buildRequestURL = findBuildRequestURL ( ) {
62
- return buildRequestURL
58
+ do {
59
+ let findTask = Task {
60
+ logger. logWarning ( " The latest build-request.json file has not been updated yet. Waiting… " )
61
+ while true {
62
+ try Task . checkCancellation ( )
63
+ try await Task . sleep ( for: . seconds( 1 ) )
64
+ if let buildRequestURL = findBuildRequestURL ( ) {
65
+ return buildRequestURL
66
+ }
63
67
}
64
68
}
65
- }
66
- let timeoutTask = Task {
67
- try await Task . sleep ( for: . seconds( 10 ) )
68
- findTask. cancel ( )
69
- }
69
+ let waitingTask = Task {
70
+ try await Task . sleep ( for: . seconds( 10 ) )
71
+ try Task . checkCancellation ( )
72
+ logger. logWarning ( """
73
+ The latest build-request.json file has still not been updated after 10 seconds. If this happens frequently, please file a bug report here:
74
+ https://github.com/MobileNativeFoundation/rules_xcodeproj/issues/new?template=bug.md
75
+ """ )
76
+ }
77
+ let timeoutTask = Task {
78
+ try await Task . sleep ( for: . seconds( 30 ) )
79
+ guard !Task. isCancelled else { return }
80
+ findTask. cancel ( )
81
+ }
70
82
71
- do {
72
83
let result = try await findTask. value
84
+ waitingTask. cancel ( )
73
85
timeoutTask. cancel ( )
74
86
return try result. decode ( BuildRequest . self)
75
87
} catch {
0 commit comments