Skip to content

Commit f0f5dbe

Browse files
committed
[Xcodeproj] Push system-module filtering a little lower.
1 parent 60f2d6a commit f0f5dbe

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

Sources/Xcodeproj/generate().swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ public func generate(dstdir: AbsolutePath, projectName: String, graph: PackageGr
3737
let srcroot = graph.rootPackage.path
3838

3939
// Filter out the CModule type, which we don't support.
40-
//
41-
// FIXME: Sink this lower.
42-
let modules = graph.modules.filter{ $0.type != .systemModule }
43-
let externalModules = graph.externalModules.filter{ $0.type != .systemModule }
4440

4541
let xcodeprojName = "\(projectName).xcodeproj"
4642
let xcodeprojPath = dstdir.appending(RelativePath(xcodeprojName))
@@ -52,13 +48,13 @@ public func generate(dstdir: AbsolutePath, projectName: String, graph: PackageGr
5248

5349
////// the pbxproj file describes the project and its targets
5450
try open(xcodeprojPath.appending("project.pbxproj")) { stream in
55-
try pbxproj(srcroot: srcroot, projectRoot: dstdir, xcodeprojPath: xcodeprojPath, modules: modules, externalModules: externalModules, products: graph.products, directoryReferences: directoryReferences, options: options, printer: stream)
51+
try pbxproj(srcroot: srcroot, projectRoot: dstdir, xcodeprojPath: xcodeprojPath, graph: graph, directoryReferences: directoryReferences, options: options, printer: stream)
5652
}
5753

5854
////// the scheme acts like an aggregate target for all our targets
5955
/// it has all tests associated so CMD+U works
6056
try open(schemesDirectory.appending(RelativePath(schemeName))) { stream in
61-
xcscheme(container: xcodeprojName, modules: modules, printer: stream)
57+
xcscheme(container: xcodeprojName, graph: graph, printer: stream)
6258
}
6359

6460
////// we generate this file to ensure our main scheme is listed
@@ -78,7 +74,7 @@ public func generate(dstdir: AbsolutePath, projectName: String, graph: PackageGr
7874
print("</plist>")
7975
}
8076

81-
for module in modules where module.isLibrary {
77+
for module in graph.modules where module.isLibrary {
8278
///// For framework targets, generate module.c99Name_Info.plist files in the
8379
///// directory that Xcode project is generated
8480
let name = module.infoPlistFileName

Sources/Xcodeproj/pbxproj().swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@
1010

1111
import Basic
1212
import POSIX
13+
import PackageGraph
1314
import PackageModel
1415
import Utility
1516

1617

1718
// FIXME: escaping
1819

1920

20-
public func pbxproj(srcroot: AbsolutePath, projectRoot: AbsolutePath, xcodeprojPath: AbsolutePath, modules: [Module], externalModules: [Module], products _: [Product], directoryReferences: [AbsolutePath], options: XcodeprojOptions, printer print: (String) -> Void) throws {
21+
public func pbxproj(srcroot: AbsolutePath, projectRoot: AbsolutePath, xcodeprojPath: AbsolutePath, graph: PackageGraph, directoryReferences: [AbsolutePath], options: XcodeprojOptions, printer print: (String) -> Void) throws {
22+
// FIXME: Push this lower.
23+
let modules = graph.modules.filter{ $0.type != .systemModule }
24+
let externalModules = graph.externalModules.filter{ $0.type != .systemModule }
25+
2126
// let rootModulesSet = Set(modules).subtract(Set(externalModules))
2227
let rootModulesSet = modules
2328
let nonTestRootModules = rootModulesSet.filter{ !$0.isTest }

Sources/Xcodeproj/xcscheme().swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,25 @@
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
*/
1010

11+
import PackageGraph
1112
import PackageModel
1213

13-
func xcscheme(container: String, modules: [Module], printer print: (String) -> Void) {
14+
func xcscheme(container: String, graph: PackageGraph, printer print: (String) -> Void) {
1415
print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
1516
print("<Scheme LastUpgradeVersion = \"9999\" version = \"1.3\">")
1617
print(" <BuildAction parallelizeBuildables = \"YES\" buildImplicitDependencies = \"YES\">")
1718
print(" <BuildActionEntries>")
1819

1920
// Create buildable references for non-test modules.
20-
for module in modules where !module.isTest {
21+
for module in graph.modules where !module.isTest {
22+
// Ignore system modules.
23+
//
24+
// FIXME: We shouldn't need to manually do this here, instead this
25+
// should be phrased in terms of the set of targets we computed.
26+
if module.type == .systemModule {
27+
continue
28+
}
29+
2130
print(" <BuildActionEntry buildForTesting = \"YES\" buildForRunning = \"YES\" buildForProfiling = \"YES\" buildForArchiving = \"YES\" buildForAnalyzing = \"YES\">")
2231
print(" <BuildableReference")
2332
print(" BuildableIdentifier = \"primary\"")
@@ -40,7 +49,7 @@ func xcscheme(container: String, modules: [Module], printer print: (String) -> V
4049
print(" <Testables>")
4150

4251
// Create testable references.
43-
for module in modules where module.isTest {
52+
for module in graph.modules where module.isTest {
4453
print(" <TestableReference")
4554
print(" skipped = \"NO\">")
4655
print(" <BuildableReference")

0 commit comments

Comments
 (0)