12
12
13
13
import SWBCore
14
14
import SWBUtil
15
+ import SWBTaskConstruction
15
16
16
17
final class AppIntentsMetadataTaskProducer : PhasedTaskProducer , TaskProducer {
17
- var sourcesBuildPhase : SourcesBuildPhase ?
18
- var resourcesBuildPhase : ResourcesBuildPhase ?
19
18
20
- init ( _ context: TargetTaskProducerContext , sourcesBuildPhase: SourcesBuildPhase ? , resourcesBuildPhase: ResourcesBuildPhase ? , phaseStartNodes: [ any PlannedNode ] , phaseEndNode: any PlannedNode ) {
21
- self . sourcesBuildPhase = sourcesBuildPhase
22
- self . resourcesBuildPhase = resourcesBuildPhase
19
+ init ( _ context: TargetTaskProducerContext , phaseStartNodes: [ any PlannedNode ] , phaseEndNode: any PlannedNode ) {
23
20
super. init ( context, phaseStartNodes: phaseStartNodes, phaseEndNode: phaseEndNode)
24
21
}
25
22
@@ -54,12 +51,15 @@ final class AppIntentsMetadataTaskProducer: PhasedTaskProducer, TaskProducer {
54
51
guard !context. settings. globalScope. evaluate ( BuiltinMacros . LM_SKIP_METADATA_EXTRACTION) else {
55
52
return [ ]
56
53
}
54
+ guard let configuredTarget = self . targetContext. configuredTarget, let buildPhaseTarget = configuredTarget. target as? BuildPhaseTarget else {
55
+ return [ ]
56
+ }
57
57
58
58
context. addDeferredProducer {
59
59
let scope = self . context. settings. globalScope
60
60
var deferredTasks : [ any PlannedTask ] = [ ]
61
- let buildFilesProcessingContext = BuildFilesProcessingContext ( scope )
62
- let swiftSources : [ FileToBuild ] = self . filterBuildFiles ( self . sourcesBuildPhase? . buildFiles, identifiers: [ " sourcecode.swift " ] , buildFilesProcessingContext: buildFilesProcessingContext)
61
+ let buildFilesProcessingContext = BuildFilesProcessingContext ( self . context . settings . globalScope )
62
+ let swiftSources : [ FileToBuild ] = self . filterBuildFiles ( buildPhaseTarget . sourcesBuildPhase? . buildFiles, identifiers: [ " sourcecode.swift " ] , buildFilesProcessingContext: buildFilesProcessingContext)
63
63
let perArchConstMetadataFiles = self . context. generatedSwiftConstMetadataFiles ( )
64
64
65
65
var metadataDependencyList : Set < Path > = [ ]
@@ -136,12 +136,12 @@ final class AppIntentsMetadataTaskProducer: PhasedTaskProducer, TaskProducer {
136
136
}
137
137
138
138
}
139
- let appShortcutStringsSources : [ FileToBuild ] = self . filterBuildFiles ( self . resourcesBuildPhase? . buildFiles, identifiers: [ " text.plist.strings " , " text.json.xcstrings " ] , buildFilesProcessingContext: buildFilesProcessingContext) . filter { [ " AppShortcuts.strings " , " AppShortcuts.xcstrings " ] . contains ( $0. absolutePath. basename) }
139
+ let appShortcutStringsSources : [ FileToBuild ] = self . filterBuildFiles ( buildPhaseTarget . resourcesBuildPhase? . buildFiles, identifiers: [ " text.plist.strings " , " text.json.xcstrings " ] , buildFilesProcessingContext: buildFilesProcessingContext) . filter { [ " AppShortcuts.strings " , " AppShortcuts.xcstrings " ] . contains ( $0. absolutePath. basename) }
140
140
141
141
let cbc = CommandBuildContext ( producer: self . context, scope: scope, inputs: swiftSources + constMetadataFilesToBuild + appShortcutStringsSources, resourcesDir: buildFilesProcessingContext. resourcesDir)
142
142
143
143
144
- let assistantIntentsStringsSources : [ FileToBuild ] = self . filterBuildFiles ( self . resourcesBuildPhase? . buildFiles, identifiers: [ " text.plist.strings " , " text.json.xcstrings " ] , buildFilesProcessingContext: buildFilesProcessingContext) . filter { [ " AssistantIntents.strings " , " AssistantIntents.xcstrings " ] . contains ( $0. absolutePath. basename) }
144
+ let assistantIntentsStringsSources : [ FileToBuild ] = self . filterBuildFiles ( buildPhaseTarget . resourcesBuildPhase? . buildFiles, identifiers: [ " text.plist.strings " , " text.json.xcstrings " ] , buildFilesProcessingContext: buildFilesProcessingContext) . filter { [ " AssistantIntents.strings " , " AssistantIntents.xcstrings " ] . contains ( $0. absolutePath. basename) }
145
145
await self . appendGeneratedTasks ( & deferredTasks) { delegate in
146
146
let shouldConstructAppIntentsMetadataTask = self . context. appIntentsMetadataCompilerSpec. shouldConstructAppIntentsMetadataTask ( cbc)
147
147
let isInstallLoc = scope. evaluate ( BuiltinMacros . BUILD_COMPONENTS) . contains ( " installLoc " )
@@ -161,13 +161,13 @@ final class AppIntentsMetadataTaskProducer: PhasedTaskProducer, TaskProducer {
161
161
( ( !scope. effectiveInputInfoPlistPath ( ) . isEmpty && shouldConstructAppIntentsMetadataTask) || isInstallLoc) {
162
162
var infoPlistSources : [ FileToBuild ]
163
163
if isInstallLoc {
164
- infoPlistSources = self . filterBuildFiles ( self . resourcesBuildPhase? . buildFiles, identifiers: [ " text.plist.strings " , " text.json.xcstrings " ] , buildFilesProcessingContext: buildFilesProcessingContext) . filter { $0. absolutePath. basename. hasSuffix ( " InfoPlist.strings " ) || $0. absolutePath. basename. hasSuffix ( " InfoPlist.xcstrings " ) }
164
+ infoPlistSources = self . filterBuildFiles ( buildPhaseTarget . resourcesBuildPhase? . buildFiles, identifiers: [ " text.plist.strings " , " text.json.xcstrings " ] , buildFilesProcessingContext: buildFilesProcessingContext) . filter { $0. absolutePath. basename. hasSuffix ( " InfoPlist.strings " ) || $0. absolutePath. basename. hasSuffix ( " InfoPlist.xcstrings " ) }
165
165
// The installLoc builds should include an AppShortcuts strings/xcstrings file to run SSU tasks
166
166
guard appShortcutStringsSources. count == 1 else {
167
167
return
168
168
}
169
169
} else {
170
- infoPlistSources = [ FileToBuild ( context : self . context , absolutePath: scope. evaluate ( BuiltinMacros . TARGET_BUILD_DIR) . join ( scope. evaluate ( BuiltinMacros . INFOPLIST_PATH) ) ) ]
170
+ infoPlistSources = [ FileToBuild ( absolutePath: scope. evaluate ( BuiltinMacros . TARGET_BUILD_DIR) . join ( scope. evaluate ( BuiltinMacros . INFOPLIST_PATH) ) , inferringTypeUsing : self . context ) ]
171
171
}
172
172
let yamlGenerationInputs : [ FileToBuild ] = infoPlistSources + appShortcutStringsSources
173
173
let appIntentsSsuTrainingCbc = CommandBuildContext ( producer: self . context, scope: scope, inputs: yamlGenerationInputs, resourcesDir: buildFilesProcessingContext. resourcesDir)
@@ -180,3 +180,13 @@ final class AppIntentsMetadataTaskProducer: PhasedTaskProducer, TaskProducer {
180
180
return tasks
181
181
}
182
182
}
183
+
184
+ extension TaskProducerContext {
185
+ var appIntentsMetadataCompilerSpec : AppIntentsMetadataCompilerSpec {
186
+ return workspaceContext. core. specRegistry. getSpec ( " com.apple.compilers.appintentsmetadata " , domain: domain) as! AppIntentsMetadataCompilerSpec
187
+ }
188
+
189
+ var appIntentsSsuTrainingCompilerSpec : AppIntentsSSUTrainingCompilerSpec {
190
+ return workspaceContext. core. specRegistry. getSpec ( " com.apple.compilers.appintents-ssu-training " , domain: domain) as! AppIntentsSSUTrainingCompilerSpec
191
+ }
192
+ }
0 commit comments