@@ -2947,7 +2947,7 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
2947
2947
return ( isEnabled, isExplicitlyEnabled)
2948
2948
}
2949
2949
2950
- private func staticallyLinkSwiftStdlib( _ producer: any CommandProducer , scope: MacroEvaluationScope ) -> Bool {
2950
+ private func staticallyLinkSwiftStdlib( _ producer: any CommandProducer , scope: MacroEvaluationScope , lookup : @escaping ( ( MacroDeclaration ) -> MacroStringExpression ? ) ) -> Bool {
2951
2951
// Determine whether we should statically link the Swift stdlib, and determined
2952
2952
// by the following logic in the following order:
2953
2953
//
@@ -2960,17 +2960,17 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
2960
2960
//
2961
2961
// NOTE: With Swift in the OS, static libs aren't being supplied by the toolchains
2962
2962
// so users of this flag will need to provide their own.
2963
- if scope. evaluate ( BuiltinMacros . SWIFT_FORCE_STATIC_LINK_STDLIB) {
2963
+ if scope. evaluate ( BuiltinMacros . SWIFT_FORCE_STATIC_LINK_STDLIB, lookup : lookup ) {
2964
2964
return true
2965
2965
}
2966
2966
return false
2967
2967
}
2968
2968
2969
- public override func computeAdditionalLinkerArgs( _ producer: any CommandProducer , scope: MacroEvaluationScope , inputFileTypes: [ FileTypeSpec ] , optionContext: ( any BuildOptionGenerationContext ) ? , delegate: any TaskGenerationDelegate ) async -> ( args: [ [ String ] ] , inputPaths: [ Path ] ) {
2970
- return await computeAdditionalLinkerArgs ( producer, scope: scope, inputFileTypes: inputFileTypes, optionContext: optionContext, forTAPI: false , delegate: delegate)
2969
+ public override func computeAdditionalLinkerArgs( _ producer: any CommandProducer , scope: MacroEvaluationScope , lookup : @escaping ( ( MacroDeclaration ) -> MacroStringExpression ? ) , inputFileTypes: [ FileTypeSpec ] , optionContext: ( any BuildOptionGenerationContext ) ? , delegate: any TaskGenerationDelegate ) async -> ( args: [ [ String ] ] , inputPaths: [ Path ] ) {
2970
+ return await computeAdditionalLinkerArgs ( producer, scope: scope, lookup : lookup , inputFileTypes: inputFileTypes, optionContext: optionContext, forTAPI: false , delegate: delegate)
2971
2971
}
2972
2972
2973
- func computeAdditionalLinkerArgs( _ producer: any CommandProducer , scope: MacroEvaluationScope , inputFileTypes: [ FileTypeSpec ] , optionContext: ( any BuildOptionGenerationContext ) ? , forTAPI: Bool = false , delegate: any TaskGenerationDelegate ) async -> ( args: [ [ String ] ] , inputPaths: [ Path ] ) {
2973
+ func computeAdditionalLinkerArgs( _ producer: any CommandProducer , scope: MacroEvaluationScope , lookup : @escaping ( ( MacroDeclaration ) -> MacroStringExpression ? ) , inputFileTypes: [ FileTypeSpec ] , optionContext: ( any BuildOptionGenerationContext ) ? , forTAPI: Bool = false , delegate: any TaskGenerationDelegate ) async -> ( args: [ [ String ] ] , inputPaths: [ Path ] ) {
2974
2974
guard let swiftToolSpec = optionContext as? DiscoveredSwiftCompilerToolSpecInfo else {
2975
2975
// An error message would have already been emitted by this point
2976
2976
return ( args: [ [ ] ] , inputPaths: [ ] )
@@ -2983,21 +2983,21 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
2983
2983
var inputPaths : [ Path ] = [ ]
2984
2984
if !forTAPI {
2985
2985
// TAPI can't use all of the additional linker options, and its spec has all of the build setting/option arguments that it can use.
2986
- args = producer. effectiveFlattenedOrderedBuildOptions ( self ) . map { $0. getAdditionalLinkerArgs ( producer, scope: scope, inputFileTypes: inputFileTypes) } . filter { !$0. isEmpty }
2986
+ args = producer. effectiveFlattenedOrderedBuildOptions ( self ) . map { $0. getAdditionalLinkerArgs ( producer, scope: scope, lookup : lookup , inputFileTypes: inputFileTypes) } . filter { !$0. isEmpty }
2987
2987
}
2988
2988
2989
2989
// Determine if we are forced to use the standard system location; this is currently only for OS adopters of Swift, not any client.
2990
- let useSystemSwift = scope. evaluate ( BuiltinMacros . SWIFT_FORCE_SYSTEM_LINK_STDLIB)
2990
+ let useSystemSwift = scope. evaluate ( BuiltinMacros . SWIFT_FORCE_SYSTEM_LINK_STDLIB, lookup : lookup )
2991
2991
2992
2992
// Determine whether we should statically link the Swift stdlib.
2993
- let shouldStaticLinkStdlib = staticallyLinkSwiftStdlib ( producer, scope: scope)
2993
+ let shouldStaticLinkStdlib = staticallyLinkSwiftStdlib ( producer, scope: scope, lookup : lookup )
2994
2994
2995
- let swiftStdlibName = scope. evaluate ( BuiltinMacros . SWIFT_STDLIB)
2996
- var swiftLibraryPath = scope. evaluate ( BuiltinMacros . SWIFT_LIBRARY_PATH)
2997
- let dynamicLibraryExtension = scope. evaluate ( BuiltinMacros . DYNAMIC_LIBRARY_EXTENSION)
2995
+ let swiftStdlibName = scope. evaluate ( BuiltinMacros . SWIFT_STDLIB, lookup : lookup )
2996
+ var swiftLibraryPath = scope. evaluate ( BuiltinMacros . SWIFT_LIBRARY_PATH, lookup : lookup )
2997
+ let dynamicLibraryExtension = scope. evaluate ( BuiltinMacros . DYNAMIC_LIBRARY_EXTENSION, lookup : lookup )
2998
2998
2999
2999
// If we weren't given an explicit library path, compute one
3000
- let platformName = scope. evaluate ( BuiltinMacros . PLATFORM_NAME)
3000
+ let platformName = scope. evaluate ( BuiltinMacros . PLATFORM_NAME, lookup : lookup )
3001
3001
if swiftLibraryPath. isEmpty {
3002
3002
// Look next to the compiler and in the toolchains for one.
3003
3003
if shouldStaticLinkStdlib {
@@ -3015,13 +3015,13 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
3015
3015
}
3016
3016
}
3017
3017
3018
- let isMacCatalystUnzippered = producer. sdkVariant? . isMacCatalyst == true && !scope. evaluate ( BuiltinMacros . IS_ZIPPERED)
3018
+ let isMacCatalystUnzippered = producer. sdkVariant? . isMacCatalyst == true && !scope. evaluate ( BuiltinMacros . IS_ZIPPERED, lookup : lookup )
3019
3019
3020
3020
var sdkPathArgument : [ String ] = [ ]
3021
3021
var unzipperedSDKPathArgument : [ String ] = [ ]
3022
3022
if forTAPI {
3023
3023
// TAPI requires absolute paths.
3024
- let sdkroot = scope. evaluate ( BuiltinMacros . SDKROOT)
3024
+ let sdkroot = scope. evaluate ( BuiltinMacros . SDKROOT, lookup : lookup )
3025
3025
if !sdkroot. isEmpty {
3026
3026
sdkPathArgument = [ " -L " + sdkroot. join ( " usr/lib/swift " ) . str]
3027
3027
unzipperedSDKPathArgument = [ " -L " + sdkroot. join ( " System/iOSSupport/usr/lib/swift " ) . str]
@@ -3072,24 +3072,24 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
3072
3072
// be a source-less target which just contains object files in it's framework phase.
3073
3073
let currentPlatformFilter = PlatformFilter ( scope)
3074
3074
let containsSources = ( producer. configuredTarget? . target as? StandardTarget ) ? . sourcesBuildPhase? . buildFiles. filter { currentPlatformFilter. matches ( $0. platformFilters) } . isEmpty == false
3075
- if containsSources && inputFileTypes. contains ( where: { $0. conformsTo ( identifier: " sourcecode.swift " ) } ) && scope. evaluate ( BuiltinMacros . GCC_GENERATE_DEBUGGING_SYMBOLS) && !scope. evaluate ( BuiltinMacros . PLATFORM_REQUIRES_SWIFT_MODULEWRAP) {
3076
- let moduleName = scope. evaluate ( BuiltinMacros . SWIFT_MODULE_NAME)
3077
- let moduleFileDir = scope. evaluate ( BuiltinMacros . PER_ARCH_MODULE_FILE_DIR)
3075
+ if containsSources && inputFileTypes. contains ( where: { $0. conformsTo ( identifier: " sourcecode.swift " ) } ) && scope. evaluate ( BuiltinMacros . GCC_GENERATE_DEBUGGING_SYMBOLS, lookup : lookup ) && !scope. evaluate ( BuiltinMacros . PLATFORM_REQUIRES_SWIFT_MODULEWRAP, lookup : lookup ) {
3076
+ let moduleName = scope. evaluate ( BuiltinMacros . SWIFT_MODULE_NAME, lookup : lookup )
3077
+ let moduleFileDir = scope. evaluate ( BuiltinMacros . PER_ARCH_MODULE_FILE_DIR, lookup : lookup )
3078
3078
let moduleFilePath = moduleFileDir. join ( moduleName + " .swiftmodule " )
3079
3079
args += [ [ " -Xlinker " , " -add_ast_path " , " -Xlinker " , moduleFilePath. str] ]
3080
- if scope. evaluate ( BuiltinMacros . SWIFT_GENERATE_ADDITIONAL_LINKER_ARGS) {
3080
+ if scope. evaluate ( BuiltinMacros . SWIFT_GENERATE_ADDITIONAL_LINKER_ARGS, lookup : lookup ) {
3081
3081
args += [ [ " @ \( Path ( moduleFilePath. appendingFileNameSuffix ( " -linker-args " ) . withoutSuffix + " .resp " ) . str) " ] ]
3082
3082
}
3083
3083
}
3084
3084
}
3085
3085
3086
- if scope. evaluate ( BuiltinMacros . SWIFT_ADD_TOOLCHAIN_SWIFTSYNTAX_SEARCH_PATHS) {
3086
+ if scope. evaluate ( BuiltinMacros . SWIFT_ADD_TOOLCHAIN_SWIFTSYNTAX_SEARCH_PATHS, lookup : lookup ) {
3087
3087
args += [ [ " -L \( swiftToolSpec. hostLibraryDirectory. str) " ] ]
3088
3088
}
3089
3089
3090
3090
let containsSwiftSources = ( producer. configuredTarget? . target as? StandardTarget ) ? . sourcesBuildPhase? . containsSwiftSources ( producer, producer, scope, producer. filePathResolver) == true
3091
- if scope. evaluate ( BuiltinMacros . PLATFORM_REQUIRES_SWIFT_AUTOLINK_EXTRACT) && containsSwiftSources {
3092
- let inputPath = scope. evaluate ( BuiltinMacros . SWIFT_AUTOLINK_EXTRACT_OUTPUT_PATH)
3091
+ if scope. evaluate ( BuiltinMacros . PLATFORM_REQUIRES_SWIFT_AUTOLINK_EXTRACT, lookup : lookup ) && containsSwiftSources {
3092
+ let inputPath = scope. evaluate ( BuiltinMacros . SWIFT_AUTOLINK_EXTRACT_OUTPUT_PATH, lookup : lookup )
3093
3093
args += [ [ " @ \( inputPath. str) " ] ]
3094
3094
inputPaths. append ( inputPath)
3095
3095
}
0 commit comments