@@ -97,9 +97,9 @@ public struct Destination: Encodable, Equatable {
97
97
let binDir = customBinDir ?? binDir ?? Destination . hostBinDir (
98
98
originalWorkingDirectory: originalWorkingDirectory)
99
99
100
- #if os(macOS)
100
+ let sdkPath : AbsolutePath ?
101
+ #if os(macOS)
101
102
// Get the SDK.
102
- let sdkPath : AbsolutePath
103
103
if let value = lookupExecutablePath ( filename: ProcessEnv . vars [ " SDKROOT " ] ) {
104
104
sdkPath = value
105
105
} else {
@@ -111,35 +111,41 @@ public struct Destination: Encodable, Equatable {
111
111
}
112
112
sdkPath = AbsolutePath ( sdkPathStr)
113
113
}
114
+ #else
115
+ sdkPath = nil
116
+ #endif
114
117
115
118
// Compute common arguments for clang and swift.
116
119
var extraCCFlags : [ String ] = [ ]
117
120
var extraSwiftCFlags : [ String ] = [ ]
121
+ #if os(macOS)
118
122
if let sdkPaths = Destination . sdkPlatformFrameworkPaths ( environment: environment) {
119
123
extraCCFlags += [ " -F " , sdkPaths. fwk. pathString]
120
124
extraSwiftCFlags += [ " -F " , sdkPaths. fwk. pathString]
121
125
extraSwiftCFlags += [ " -I " , sdkPaths. lib. pathString]
122
126
extraSwiftCFlags += [ " -L " , sdkPaths. lib. pathString]
123
127
}
128
+ #endif
129
+
130
+ #if !os(Windows)
131
+ extraCCFlags += [ " -fPIC " ]
132
+ #endif
133
+
134
+ var extraCPPFlags : [ String ] = [ ]
135
+ #if os(macOS)
136
+ extraCPPFlags += [ " -lc++ " ]
137
+ #else
138
+ extraCPPFlags += [ " -lstdc++ " ]
139
+ #endif
124
140
125
141
return Destination (
126
142
target: nil ,
127
143
sdk: sdkPath,
128
144
binDir: binDir,
129
145
extraCCFlags: extraCCFlags,
130
146
extraSwiftCFlags: extraSwiftCFlags,
131
- extraCPPFlags: [ " -lc++ " ]
132
- )
133
- #else
134
- return Destination (
135
- target: nil ,
136
- sdk: nil ,
137
- binDir: binDir,
138
- extraCCFlags: [ " -fPIC " ] ,
139
- extraSwiftCFlags: [ ] ,
140
- extraCPPFlags: [ " -lstdc++ " ]
147
+ extraCPPFlags: extraCPPFlags
141
148
)
142
- #endif
143
149
}
144
150
145
151
/// Returns macosx sdk platform framework path.
0 commit comments