Skip to content

Commit a615f58

Browse files
committed
Revert "[Macros] Set -external-plugin-path when the toolchain is not Xcode"
This reverts commit 53ad3a9.
1 parent ac7ceb5 commit a615f58

File tree

4 files changed

+2
-118
lines changed

4 files changed

+2
-118
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,6 @@ extension Driver {
275275
commandLine.appendPath(localPluginPath)
276276
}
277277

278-
if isFrontendArgSupported(.externalPluginPath) {
279-
try commandLine.appendAll(.externalPluginPath, from: &parsedOptions)
280-
}
281-
282278
if isFrontendArgSupported(.blockListFile) {
283279
try Driver.findBlocklists(RelativeTo: try toolchain.executableDir).forEach {
284280
commandLine.appendFlag(.blockListFile)

Sources/SwiftDriver/Toolchains/DarwinToolchain.swift

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -373,32 +373,6 @@ public final class DarwinToolchain: Toolchain {
373373
frontendTargetInfo: FrontendTargetInfo,
374374
driver: inout Driver
375375
) throws {
376-
// Pass -external-plugin-path if the current toolchain is not a Xcode
377-
// default toolchain.
378-
if
379-
driver.isFrontendArgSupported(.externalPluginPath),
380-
let xcodeDir = try self.findCurrentSelectedXcodeDir(),
381-
try !self.executableDir.isDescendant(of: xcodeDir),
382-
let xcodeExecutableDir = try self.findXcodeExecutableDir()
383-
{
384-
let xcodePluginServerPath = xcodeExecutableDir
385-
.appending(component: "swift-plugin-server")
386-
387-
if fileSystem.isExecutableFile(xcodePluginServerPath) {
388-
let xcodeToolchainUsrPath = xcodeExecutableDir.parentDirectory
389-
390-
let xcodePluginPath = xcodeToolchainUsrPath
391-
.appending(components: "lib", "swift", "host", "plugins")
392-
commandLine.appendFlag(.externalPluginPath)
393-
commandLine.appendFlag(xcodePluginPath.pathString + "#" + xcodePluginServerPath.pathString)
394-
395-
let xcodeLocalPluginPath = xcodeToolchainUsrPath
396-
.appending(components: "local", "lib", "swift", "host", "plugins")
397-
commandLine.appendFlag(.externalPluginPath)
398-
commandLine.appendFlag(xcodeLocalPluginPath.pathString + "#" + xcodePluginServerPath.pathString)
399-
}
400-
}
401-
402376
guard let sdkPath = frontendTargetInfo.sdkPath?.path,
403377
let sdkInfo = getTargetSDKInfo(sdkPath: sdkPath) else { return }
404378

@@ -467,38 +441,3 @@ private extension Version {
467441
return self.description
468442
}
469443
}
470-
471-
extension DarwinToolchain {
472-
func findXcodeExecutableDir() throws -> AbsolutePath? {
473-
#if os(macOS)
474-
let result = try executor.checkNonZeroExit(
475-
args: "xcrun", "-toolchain", "default", "-f", "swiftc",
476-
environment: env
477-
).trimmingCharacters(in: .whitespacesAndNewlines)
478-
479-
guard !result.isEmpty else {
480-
return nil
481-
}
482-
return try AbsolutePath(validating: result)
483-
.parentDirectory // swiftc
484-
#else
485-
return nil
486-
#endif
487-
}
488-
489-
func findCurrentSelectedXcodeDir() throws -> AbsolutePath? {
490-
#if os(macOS)
491-
let result = try executor.checkNonZeroExit(
492-
args: "xcode-select", "-p",
493-
environment: env
494-
).trimmingCharacters(in: .whitespacesAndNewlines)
495-
496-
guard !result.isEmpty else {
497-
return nil
498-
}
499-
return try AbsolutePath(validating: result)
500-
#else
501-
return nil
502-
#endif
503-
}
504-
}

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6769,55 +6769,6 @@ final class SwiftDriverTests: XCTestCase {
67696769
XCTAssertTrue(job.commandLine.contains(.path(.absolute(try driver.toolchain.executableDir.parentDirectory.appending(components: "local", "lib", "swift", "host", "plugins")))))
67706770
}
67716771

6772-
func testExternalPluginPaths() throws {
6773-
#if !os(macOS)
6774-
throw XCTSkip("Supported only in macOS")
6775-
#endif
6776-
6777-
try withTemporaryDirectory { tmpDir in
6778-
var driver = try Driver(args: ["swiftc", "-typecheck", "foo.swift"],
6779-
compilerExecutableDir: tmpDir)
6780-
guard driver.isFrontendArgSupported(.externalPluginPath) else {
6781-
return
6782-
}
6783-
6784-
let jobs = try driver.planBuild().removingAutolinkExtractJobs()
6785-
XCTAssertEqual(jobs.count, 1)
6786-
let job = jobs.first!
6787-
6788-
// This happens only Xcode toolchain has 'swift-plugin-server' which we
6789-
// don't know.
6790-
let idx1 = job.commandLine.firstIndex(of: .flag("-external-plugin-path"))
6791-
try XCTSkipIf(idx1 == nil)
6792-
switch job.commandLine[job.commandLine.index(after: idx1!)] {
6793-
case .flag(let value):
6794-
let components = value.split(separator: "#")
6795-
if components.count == 2 {
6796-
XCTAssertTrue(components[0].hasSuffix("/usr/lib/swift/host/plugins"))
6797-
XCTAssertTrue(components[1].hasSuffix("/usr/bin/swift-plugin-server"))
6798-
} else {
6799-
XCTFail("# separated count must 2")
6800-
}
6801-
default:
6802-
XCTFail("invalid arg type after '-external-plugin-path'")
6803-
}
6804-
6805-
let idx2 = job.commandLine[job.commandLine.index(after: idx1!)...].firstIndex(of: .flag("-external-plugin-path"))
6806-
switch job.commandLine[job.commandLine.index(after: try XCTUnwrap(idx2))] {
6807-
case .flag(let value):
6808-
let components = value.split(separator: "#")
6809-
if (components.count == 2) {
6810-
XCTAssertTrue(components[0].hasSuffix("/usr/local/lib/swift/host/plugins"))
6811-
XCTAssertTrue(components[1].hasSuffix("/usr/bin/swift-plugin-server"))
6812-
} else {
6813-
XCTFail("# separated count must 2")
6814-
}
6815-
default:
6816-
XCTFail("invalid arg type after '-external-plugin-path'")
6817-
}
6818-
}
6819-
}
6820-
68216772
func testClangModuleValidateOnce() throws {
68226773
let flagTest = try Driver(args: ["swiftc", "-typecheck", "foo.swift"])
68236774
guard flagTest.isFrontendArgSupported(.clangBuildSessionFile),

Tests/TestUtilities/DriverExtensions.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ extension Driver {
2323
env: [String: String] = ProcessEnv.vars,
2424
diagnosticsEngine: DiagnosticsEngine = DiagnosticsEngine(handlers: [Driver.stderrDiagnosticsHandler]),
2525
fileSystem: FileSystem = localFileSystem,
26-
integratedDriver: Bool = true,
27-
compilerExecutableDir: AbsolutePath? = nil
26+
integratedDriver: Bool = true
2827
) throws {
2928
let executor = try SwiftDriverExecutor(diagnosticsEngine: diagnosticsEngine,
3029
processSet: ProcessSet(),
@@ -35,8 +34,7 @@ extension Driver {
3534
diagnosticsOutput: .engine(diagnosticsEngine),
3635
fileSystem: fileSystem,
3736
executor: executor,
38-
integratedDriver: integratedDriver,
39-
compilerExecutableDir: compilerExecutableDir)
37+
integratedDriver: integratedDriver)
4038
}
4139

4240
/// For tests that need to set the sdk path.

0 commit comments

Comments
 (0)