@@ -23,7 +23,26 @@ import Utility
23
23
/// sources is not necessarily related to this path; the source root directory
24
24
/// is the path of the root package in the package graph, independent of the
25
25
/// directory to which the .xcodeproj is being generated.
26
- public func pbxproj( xcodeprojPath: AbsolutePath , graph: PackageGraph , extraDirs: [ AbsolutePath ] , options: XcodeprojOptions ) throws -> String {
26
+ public func pbxproj(
27
+ xcodeprojPath: AbsolutePath ,
28
+ graph: PackageGraph ,
29
+ extraDirs: [ AbsolutePath ] ,
30
+ options: XcodeprojOptions ,
31
+ fileSystem: FileSystem = localFileSystem
32
+ ) throws -> String {
33
+ let project = try xcodeProject ( xcodeprojPath: xcodeprojPath, graph: graph, extraDirs: extraDirs, options: options, fileSystem: fileSystem)
34
+ // Serialize the project model we created to a plist, and return
35
+ // its string description.
36
+ return " // !$*UTF8*$! \n " + project. generatePlist ( ) . description
37
+ }
38
+
39
+ func xcodeProject(
40
+ xcodeprojPath: AbsolutePath ,
41
+ graph: PackageGraph ,
42
+ extraDirs: [ AbsolutePath ] ,
43
+ options: XcodeprojOptions ,
44
+ fileSystem: FileSystem
45
+ ) throws -> Xcode . Project {
27
46
28
47
// Create the project.
29
48
let project = Xcode . Project ( )
@@ -257,12 +276,12 @@ public func pbxproj(xcodeprojPath: AbsolutePath, graph: PackageGraph, extraDirs:
257
276
targetSettings. common. DEFINES_MODULE = " YES "
258
277
let moduleMapPath : AbsolutePath
259
278
// If user provided the modulemap no need to generate.
260
- if isFile ( clangModule. moduleMapPath) {
279
+ if fileSystem . isFile ( clangModule. moduleMapPath) {
261
280
moduleMapPath = clangModule. moduleMapPath
262
281
} else {
263
282
// Generate and drop the modulemap inside Xcodeproj folder.
264
283
let path = xcodeprojPath. appending ( components: " GeneratedModuleMap " , clangModule. c99name)
265
- var moduleMapGenerator = ModuleMapGenerator ( for: clangModule)
284
+ var moduleMapGenerator = ModuleMapGenerator ( for: clangModule, fileSystem : fileSystem )
266
285
try moduleMapGenerator. generateModuleMap ( inDir: path)
267
286
moduleMapPath = path. appending ( component: moduleMapFilename)
268
287
}
@@ -362,10 +381,8 @@ public func pbxproj(xcodeprojPath: AbsolutePath, graph: PackageGraph, extraDirs:
362
381
let _ = linkPhase. addBuildFile ( fileRef: otherTarget. productReference!)
363
382
}
364
383
}
365
-
366
- // Finally, serialize the project model we created to a plist, and return
367
- // its string description.
368
- return " // !$*UTF8*$! \n " + project. generatePlist ( ) . description
384
+
385
+ return project
369
386
}
370
387
371
388
extension Module {
0 commit comments