@@ -776,7 +776,7 @@ open class CommandLineToolSpec : PropertyDomainSpec, SpecType, TaskTypeDescripti
776
776
let scope = cbc. scope
777
777
let inputFileType = cbc. inputs. first? . fileType
778
778
let lookup = { self . lookup ( $0, cbc, delegate) }
779
- for buildOption in self . flattenedOrderedBuildOptions {
779
+ for buildOption in cbc . producer . effectiveFlattenedOrderedBuildOptions ( self ) {
780
780
guard let dependencyFormat = buildOption. dependencyFormat else {
781
781
continue
782
782
}
@@ -916,7 +916,12 @@ open class CommandLineToolSpec : PropertyDomainSpec, SpecType, TaskTypeDescripti
916
916
917
917
// Add the additional outputs defined by the spec. These are not declared as outputs but should be processed by the tool separately.
918
918
let additionalEvaluatedOutputsResult = await additionalEvaluatedOutputs ( cbc, delegate)
919
- outputs. append ( contentsOf: additionalEvaluatedOutputsResult. outputs. map ( { delegate. createNode ( $0) } ) )
919
+ outputs. append ( contentsOf: additionalEvaluatedOutputsResult. outputs. map { output in
920
+ if let fileTypeIdentifier = output. fileType, let fileType = cbc. producer. lookupFileType ( identifier: fileTypeIdentifier) {
921
+ delegate. declareOutput ( FileToBuild ( absolutePath: output. path, fileType: fileType) )
922
+ }
923
+ return delegate. createNode ( output. path)
924
+ } )
920
925
921
926
if let infoPlistContent = additionalEvaluatedOutputsResult. generatedInfoPlistContent {
922
927
delegate. declareGeneratedInfoPlistContent ( infoPlistContent)
@@ -978,7 +983,7 @@ open class CommandLineToolSpec : PropertyDomainSpec, SpecType, TaskTypeDescripti
978
983
}
979
984
980
985
public struct AdditionalEvaluatedOutputsResult {
981
- public var outputs = [ Path] ( )
986
+ public var outputs = [ ( path : Path, fileType : String ? ) ] ( )
982
987
public var generatedInfoPlistContent : Path ? = nil
983
988
}
984
989
@@ -994,20 +999,25 @@ open class CommandLineToolSpec : PropertyDomainSpec, SpecType, TaskTypeDescripti
994
999
995
1000
// FIXME: In Xcode, this is also marked as an "auxiliary output", which we use in conjunction with the "MightNotEmitAllOutput" flag to determine whether or not the tool needs to rerun if the output is missing.
996
1001
997
- result. outputs. append ( output)
1002
+ result. outputs. append ( ( output, nil ) )
998
1003
}
999
1004
1000
1005
let producer = cbc. producer
1001
1006
let scope = cbc. scope
1002
1007
let inputFileType = cbc. inputs. first? . fileType
1003
1008
let lookup = { self . lookup ( $0, cbc, delegate) }
1004
1009
let optionContext = await discoveredCommandLineToolSpecInfo ( producer, scope, delegate)
1005
- result. outputs. append ( contentsOf: self . flattenedOrderedBuildOptions . flatMap { buildOption -> [ Path ] in
1010
+ result. outputs. append ( contentsOf: cbc . producer . effectiveFlattenedOrderedBuildOptions ( self , filter : . all ) . flatMap { buildOption -> [ ( Path , String ? ) ] in
1006
1011
// Check if the effective arguments for this build option were non-empty as a proxy for whether it got filtered out by architecture mismatch, etc.
1007
1012
guard let outputDependencies = buildOption. outputDependencies, !buildOption. getArgumentsForCommand ( producer, scope: scope, inputFileType: inputFileType, optionContext: optionContext, lookup: lookup) . isEmpty else {
1008
1013
return [ ]
1009
1014
}
1010
- return outputDependencies. compactMap { Path ( scope. evaluate ( $0, lookup: lookup) ) . nilIfEmpty? . normalize ( ) }
1015
+ return outputDependencies. compactMap { outputDependency in
1016
+ guard let path = Path ( scope. evaluate ( outputDependency. path, lookup: lookup) ) . nilIfEmpty else {
1017
+ return nil
1018
+ }
1019
+ return ( path. normalize ( ) , outputDependency. fileType. map { scope. evaluate ( $0, lookup: lookup) . nilIfEmpty } ?? nil )
1020
+ }
1011
1021
} )
1012
1022
1013
1023
return result
@@ -1231,7 +1241,7 @@ open class CommandLineToolSpec : PropertyDomainSpec, SpecType, TaskTypeDescripti
1231
1241
return cbc. scope. evaluate ( value, lookup: lookup) . map { . literal( ByteString ( encodingAsUTF8: $0) ) }
1232
1242
1233
1243
case . options:
1234
- return self . commandLineFromOptions ( cbc, delegate, optionContext: optionContext, lookup: lookup)
1244
+ return self . commandLineFromOptions ( cbc, delegate, optionContext: optionContext, buildOptionsFilter : . all , lookup: lookup)
1235
1245
1236
1246
case . output:
1237
1247
// We always resolve the Output via a recursive macro evaluation. See constructTasks() for more information.
@@ -1260,22 +1270,22 @@ open class CommandLineToolSpec : PropertyDomainSpec, SpecType, TaskTypeDescripti
1260
1270
/// Creates and returns the command line arguments generated by the options of the specification.
1261
1271
///
1262
1272
/// - parameter lookup: An optional closure which functionally defined overriding values during build setting evaluation.
1263
- public func commandLineFromOptions( _ producer: any CommandProducer , scope: MacroEvaluationScope , inputFileType: FileTypeSpec ? , optionContext: ( any BuildOptionGenerationContext ) ? , lookup: ( ( MacroDeclaration ) -> MacroExpression ? ) ? = nil ) -> [ CommandLineArgument ] {
1264
- return self . flattenedOrderedBuildOptions . flatMap { $0. getArgumentsForCommand ( producer, scope: scope, inputFileType: inputFileType, optionContext: optionContext, lookup: lookup) }
1273
+ public func commandLineFromOptions( _ producer: any CommandProducer , scope: MacroEvaluationScope , inputFileType: FileTypeSpec ? , optionContext: ( any BuildOptionGenerationContext ) ? , buildOptionsFilter : BuildOptionsFilter , lookup: ( ( MacroDeclaration ) -> MacroExpression ? ) ? = nil ) -> [ CommandLineArgument ] {
1274
+ return producer . effectiveFlattenedOrderedBuildOptions ( self , filter : buildOptionsFilter ) . flatMap { $0. getArgumentsForCommand ( producer, scope: scope, inputFileType: inputFileType, optionContext: optionContext, lookup: lookup) }
1265
1275
}
1266
1276
1267
1277
/// Creates and returns the command line arguments generated by the options of the specification.
1268
1278
///
1269
1279
/// - parameter lookup: An optional closure which functionally defined overriding values during build setting evaluation.
1270
- public func commandLineFromOptions( _ cbc: CommandBuildContext , _ delegate: any DiagnosticProducingDelegate , optionContext: ( any BuildOptionGenerationContext ) ? , lookup: ( ( MacroDeclaration ) -> MacroExpression ? ) ? = nil ) -> [ CommandLineArgument ] {
1271
- return commandLineFromOptions ( cbc. producer, scope: cbc. scope, inputFileType: cbc. inputs. first? . fileType, optionContext: optionContext, lookup: { self . lookup ( $0, cbc, delegate, lookup) } )
1280
+ public func commandLineFromOptions( _ cbc: CommandBuildContext , _ delegate: any DiagnosticProducingDelegate , optionContext: ( any BuildOptionGenerationContext ) ? , buildOptionsFilter : BuildOptionsFilter = . all , lookup: ( ( MacroDeclaration ) -> MacroExpression ? ) ? = nil ) -> [ CommandLineArgument ] {
1281
+ return commandLineFromOptions ( cbc. producer, scope: cbc. scope, inputFileType: cbc. inputs. first? . fileType, optionContext: optionContext, buildOptionsFilter : buildOptionsFilter , lookup: { self . lookup ( $0, cbc, delegate, lookup) } )
1272
1282
}
1273
1283
1274
1284
/// Creates and returns the command line arguments generated by the specification's build setting corresponding to the given macro declaration.
1275
1285
///
1276
1286
/// - parameter lookup: An optional closure which functionally defined overriding values during build setting evaluation.
1277
1287
func commandLineFromMacroDeclaration( _ producer: any CommandProducer , optionContext: ( any BuildOptionGenerationContext ) ? , scope: MacroEvaluationScope , macro: MacroDeclaration , inputFileType: FileTypeSpec ? , lookup: ( ( MacroDeclaration ) -> MacroExpression ? ) ? = nil ) -> [ CommandLineArgument ] {
1278
- return buildOptions . first { $0. name == macro. name } ? . getArgumentsForCommand ( producer, scope: scope, inputFileType: inputFileType, optionContext: optionContext, lookup: lookup) ?? [ ]
1288
+ return producer . effectiveBuildOptions ( self ) . first { $0. name == macro. name } ? . getArgumentsForCommand ( producer, scope: scope, inputFileType: inputFileType, optionContext: optionContext, lookup: lookup) ?? [ ]
1279
1289
}
1280
1290
1281
1291
/// Creates and returns the command line arguments generated by the specification's build setting corresponding to the given macro declaration.
@@ -1291,7 +1301,7 @@ open class CommandLineToolSpec : PropertyDomainSpec, SpecType, TaskTypeDescripti
1291
1301
let scope = cbc. scope
1292
1302
let inputFileType = cbc. inputs. first? . fileType
1293
1303
let lookup = { self . lookup ( $0, cbc, delegate, lookup) }
1294
- return self . flattenedOrderedBuildOptions . flatMap { buildOption -> [ Path ] in
1304
+ return cbc . producer . effectiveFlattenedOrderedBuildOptions ( self ) . flatMap { buildOption -> [ Path ] in
1295
1305
// Check if the effective arguments for this build option were non-empty as a proxy for whether it got filtered out by architecture mismatch, etc.
1296
1306
guard let inputInclusions = buildOption. inputInclusions, !buildOption. getArgumentsForCommand ( producer, scope: scope, inputFileType: inputFileType, optionContext: optionContext, lookup: lookup) . isEmpty else {
1297
1307
return [ ]
@@ -1303,7 +1313,7 @@ open class CommandLineToolSpec : PropertyDomainSpec, SpecType, TaskTypeDescripti
1303
1313
/// Compute the list of additional linker arguments to use when this tool is used for building with the given scope.
1304
1314
public func computeAdditionalLinkerArgs( _ producer: any CommandProducer , scope: MacroEvaluationScope , inputFileTypes: [ FileTypeSpec ] , optionContext: ( any BuildOptionGenerationContext ) ? , delegate: any TaskGenerationDelegate ) async -> ( args: [ [ String ] ] , inputPaths: [ Path ] ) {
1305
1315
// FIXME: Optimize the list to search here.
1306
- return ( args: self . flattenedOrderedBuildOptions . map { $0. getAdditionalLinkerArgs ( producer, scope: scope, inputFileTypes: inputFileTypes) } , inputPaths: [ ] )
1316
+ return ( args: producer . effectiveFlattenedOrderedBuildOptions ( self ) . map { $0. getAdditionalLinkerArgs ( producer, scope: scope, inputFileTypes: inputFileTypes) } , inputPaths: [ ] )
1307
1317
}
1308
1318
1309
1319
// Creates and returns the environment from the specification. This includes both the 'EnvironmentVariables' property for this tool spec, and any build options which define that their value should be exported via their 'SetValueInEnvironmentVariable' property.
@@ -1319,7 +1329,7 @@ open class CommandLineToolSpec : PropertyDomainSpec, SpecType, TaskTypeDescripti
1319
1329
1320
1330
// Add environment variables from build options which specify they should be added via a 'SetValueInEnvironmentVariable' property.
1321
1331
// FIXME: Optimize the list to search here.
1322
- for buildOption in self . flattenedOrderedBuildOptions {
1332
+ for buildOption in cbc . producer . effectiveFlattenedOrderedBuildOptions ( self ) {
1323
1333
if let assignment = buildOption. getEnvironmentAssignmentForCommand ( cbc, lookup: wrappedLookup) {
1324
1334
environment. append ( assignment)
1325
1335
}
0 commit comments