@@ -155,7 +155,7 @@ extension Module {
155
155
}
156
156
}
157
157
158
- var headerSearchPaths : ( key: String , value: String ) ? {
158
+ var headerSearchPaths : ( key: String , value: Plist ) ? {
159
159
let headerPathKey = " HEADER_SEARCH_PATHS "
160
160
let headerPaths = dependencies. flatMap { module -> AbsolutePath ? in
161
161
switch module {
@@ -169,36 +169,28 @@ extension Module {
169
169
}
170
170
171
171
guard !headerPaths. isEmpty else { return nil }
172
-
173
- if headerPaths. count == 1 , let first = headerPaths. first {
174
- return ( headerPathKey, first. asString)
175
- }
176
-
177
- let headerPathValue = headerPaths. map { $0. asString } . joined ( separator: " " )
178
172
179
- return ( headerPathKey, headerPathValue )
173
+ return ( headerPathKey, . array ( headerPaths . map { . string ( $0 . asString ) } ) )
180
174
}
181
175
182
176
func getDebugBuildSettings( _ options: XcodeprojOptions , xcodeProjectPath: AbsolutePath ) throws -> String {
183
177
var buildSettings = try getCommonBuildSettings ( options, xcodeProjectPath: xcodeProjectPath)
184
178
if let headerSearchPaths = headerSearchPaths {
185
179
buildSettings [ headerSearchPaths. key] = headerSearchPaths. value
186
180
}
187
- // FIXME: Need to honor actual quoting rules here.
188
- return buildSettings. map { " \( $0) = ' \( $1) '; " } . joined ( separator: " " )
181
+ return Plist . dictionary ( buildSettings) . serialize ( )
189
182
}
190
183
191
184
func getReleaseBuildSettings( _ options: XcodeprojOptions , xcodeProjectPath: AbsolutePath ) throws -> String {
192
185
var buildSettings = try getCommonBuildSettings ( options, xcodeProjectPath: xcodeProjectPath)
193
186
if let headerSearchPaths = headerSearchPaths {
194
187
buildSettings [ headerSearchPaths. key] = headerSearchPaths. value
195
188
}
196
- // FIXME: Need to honor actual quoting rules here.
197
- return buildSettings. map { " \( $0) = ' \( $1) '; " } . joined ( separator: " " )
189
+ return Plist . dictionary ( buildSettings) . serialize ( )
198
190
}
199
191
200
- private func getCommonBuildSettings( _ options: XcodeprojOptions , xcodeProjectPath: AbsolutePath ) throws -> [ String : String ] {
201
- var buildSettings = [ String: String ] ( )
192
+ private func getCommonBuildSettings( _ options: XcodeprojOptions , xcodeProjectPath: AbsolutePath ) throws -> [ String : Plist ] {
193
+ var buildSettings = [ String: Plist ] ( )
202
194
let plistPath = xcodeProjectPath. appending ( component: infoPlistFileName)
203
195
204
196
if isTest {
@@ -207,15 +199,15 @@ extension Module {
207
199
//FIXME this should not be required
208
200
buildSettings [ " LD_RUNPATH_SEARCH_PATHS " ] = " @loader_path/../Frameworks "
209
201
210
- buildSettings [ " INFOPLIST_FILE " ] = plistPath. relative ( to: xcodeProjectPath. parentDirectory) . asString
202
+ buildSettings [ " INFOPLIST_FILE " ] = . string ( plistPath. relative ( to: xcodeProjectPath. parentDirectory) . asString)
211
203
} else {
212
204
// We currently force a search path to the toolchain, since we
213
205
// cannot establish an expected location for the Swift standard
214
206
// libraries.
215
207
//
216
208
// This means the built binaries are not suitable for distribution,
217
209
// among other things.
218
- buildSettings [ " LD_RUNPATH_SEARCH_PATHS " ] = " $(TOOLCHAIN_DIR)/usr/lib/swift/macosx "
210
+ let toolchainPath = " $(TOOLCHAIN_DIR)/usr/lib/swift/macosx "
219
211
if isLibrary {
220
212
buildSettings [ " ENABLE_TESTABILITY " ] = " YES "
221
213
@@ -234,12 +226,13 @@ extension Module {
234
226
// default behavior on all packages.
235
227
236
228
buildSettings [ " PRODUCT_NAME " ] = " $(TARGET_NAME:c99extidentifier) "
237
- buildSettings [ " INFOPLIST_FILE " ] = plistPath. relative ( to: xcodeProjectPath. parentDirectory) . asString
229
+ buildSettings [ " INFOPLIST_FILE " ] = . string ( plistPath. relative ( to: xcodeProjectPath. parentDirectory) . asString)
238
230
239
231
buildSettings [ " PRODUCT_MODULE_NAME " ] = " $(TARGET_NAME:c99extidentifier) "
240
232
241
233
// FIXME: This should be user speficiable
242
- buildSettings [ " PRODUCT_BUNDLE_IDENTIFIER " ] = c99name
234
+ buildSettings [ " PRODUCT_BUNDLE_IDENTIFIER " ] = . string( c99name)
235
+ buildSettings [ " LD_RUNPATH_SEARCH_PATHS " ] = . string( toolchainPath)
243
236
} else {
244
237
// override default behavior, instead link dynamically
245
238
buildSettings [ " SWIFT_FORCE_STATIC_LINK_STDLIB " ] = " NO "
@@ -254,13 +247,13 @@ extension Module {
254
247
// example would be `@executable_path/../lib` but there are
255
248
// other problems to solve first, e.g. how to deal with the
256
249
// Swift standard library paths).
257
- buildSettings [ " LD_RUNPATH_SEARCH_PATHS " ] = buildSettings [ " LD_RUNPATH_SEARCH_PATHS " ] ! + " @executable_path"
250
+ buildSettings [ " LD_RUNPATH_SEARCH_PATHS " ] = . array ( [ . string ( toolchainPath ) , " @executable_path " ] )
258
251
}
259
252
}
260
253
261
254
if let pkgArgs = try ? self . pkgConfigArgs ( ) {
262
- buildSettings [ " OTHER_LDFLAGS " ] = ( [ " $(inherited) " ] + pkgArgs. libs) . joined ( separator : " " )
263
- buildSettings [ " OTHER_SWIFT_FLAGS " ] = ( [ " $(inherited) " ] + pkgArgs. cFlags) . joined ( separator : " " )
255
+ buildSettings [ " OTHER_LDFLAGS " ] = . array ( [ " $(inherited) " ] + pkgArgs. libs. map ( Plist . string ) )
256
+ buildSettings [ " OTHER_SWIFT_FLAGS " ] = . array ( [ " $(inherited) " ] + pkgArgs. cFlags. map ( Plist . string ) )
264
257
}
265
258
266
259
// Add framework search path to build settings.
@@ -281,7 +274,7 @@ extension Module {
281
274
moduleMapPath = path. appending ( component: moduleMapFilename)
282
275
}
283
276
284
- buildSettings [ " MODULEMAP_FILE " ] = moduleMapPath. relative ( to: xcodeProjectPath. parentDirectory) . asString
277
+ buildSettings [ " MODULEMAP_FILE " ] = . string ( moduleMapPath. relative ( to: xcodeProjectPath. parentDirectory) . asString)
285
278
}
286
279
287
280
// At the moment, set the Swift version to 3 (we will need to make this dynamic), but for now this is necessary.
0 commit comments