Skip to content

Commit 6f23c24

Browse files
authored
Merge pull request #2075 from kimdv/kimdv/2070-build-swiftrefactorextensionxcodeproj-in-ci
Build EditorExtension as part of CI job
2 parents b05dfb6 + 733c5d3 commit 6f23c24

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/Build.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,13 @@ struct Build: ParsableCommand, BuildCommand {
2020
func run() throws {
2121
try buildTarget(packageDir: Paths.packageDir, targetName: "SwiftSyntax-all")
2222
try buildTarget(packageDir: Paths.examplesDir, targetName: "Examples-all")
23+
try buildEditorExtension()
24+
}
25+
26+
private func buildEditorExtension() throws {
27+
#if os(macOS)
28+
logSection("Building Editor Extension")
29+
try invokeXcodeBuild(projectPath: Paths.editorExtensionProjectPath)
30+
#endif
2331
}
2432
}

SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/common/BuildCommand.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,27 @@ extension BuildCommand {
8989
return result
9090
}
9191

92+
@discardableResult
93+
func invokeXcodeBuild(projectPath: URL) throws -> ProcessResult {
94+
guard let xcodebuildExec = Paths.xcodebuildExec else {
95+
throw ScriptExectutionError(
96+
message: """
97+
Error: Could not find xcodebuild.
98+
Looking at '\(Paths.xcodebuildExec?.path ?? "N/A")'.
99+
"""
100+
)
101+
}
102+
let processRunner = ProcessRunner(
103+
executableURL: xcodebuildExec,
104+
arguments: ["-project", projectPath.path],
105+
additionalEnvironment: [:]
106+
)
107+
108+
let result = try processRunner.run(verbose: arguments.verbose)
109+
110+
return result
111+
}
112+
92113
private func build(packageDir: URL, name: String, isProduct: Bool) throws {
93114
let args: [String]
94115

SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/common/Paths.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ enum Paths {
3737
.appendingPathComponent("CodeGeneration")
3838
}
3939

40+
static var editorExtensionProjectPath: URL {
41+
packageDir
42+
.appendingPathComponent("EditorExtension")
43+
.appendingPathComponent("SwiftRefactorExtension.xcodeproj")
44+
}
45+
4046
static var workspaceDir: URL {
4147
packageDir
4248
.deletingLastPathComponent()
@@ -63,6 +69,10 @@ enum Paths {
6369
return lookupExecutable(for: "diff")
6470
}
6571

72+
static var xcodebuildExec: URL? {
73+
return lookupExecutable(for: "xcodebuild")
74+
}
75+
6676
private static var envSearchPaths: [URL] {
6777
// Compute search paths from PATH variable.
6878
#if os(Windows)

0 commit comments

Comments
 (0)