Skip to content

Commit 549b017

Browse files
committed
Revert "[Macros] Set -external-plugin-path when the toolchain is not Xcode"
This reverts commit 9f5ad9b.
1 parent 28111c9 commit 549b017

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
@@ -269,10 +269,6 @@ extension Driver {
269269
commandLine.appendPath(localPluginPath)
270270
}
271271

272-
if isFrontendArgSupported(.externalPluginPath) {
273-
try commandLine.appendAll(.externalPluginPath, from: &parsedOptions)
274-
}
275-
276272
// Pass down -user-module-version if we are working with a compiler that
277273
// supports it.
278274
if let ver = parsedOptions.getLastArgument(.userModuleVersion)?.asSingle,

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
@@ -6727,55 +6727,6 @@ final class SwiftDriverTests: XCTestCase {
67276727
XCTAssertTrue(job.commandLine.contains(.path(.absolute(try driver.toolchain.executableDir.parentDirectory.appending(components: "local", "lib", "swift", "host", "plugins")))))
67286728
}
67296729

6730-
func testExternalPluginPaths() throws {
6731-
#if !os(macOS)
6732-
throw XCTSkip("Supported only in macOS")
6733-
#endif
6734-
6735-
try withTemporaryDirectory { tmpDir in
6736-
var driver = try Driver(args: ["swiftc", "-typecheck", "foo.swift"],
6737-
compilerExecutableDir: tmpDir)
6738-
guard driver.isFrontendArgSupported(.externalPluginPath) else {
6739-
return
6740-
}
6741-
6742-
let jobs = try driver.planBuild().removingAutolinkExtractJobs()
6743-
XCTAssertEqual(jobs.count, 1)
6744-
let job = jobs.first!
6745-
6746-
// This happens only Xcode toolchain has 'swift-plugin-server' which we
6747-
// don't know.
6748-
let idx1 = job.commandLine.firstIndex(of: .flag("-external-plugin-path"))
6749-
try XCTSkipIf(idx1 == nil)
6750-
switch job.commandLine[job.commandLine.index(after: idx1!)] {
6751-
case .flag(let value):
6752-
let components = value.split(separator: "#")
6753-
if components.count == 2 {
6754-
XCTAssertTrue(components[0].hasSuffix("/usr/lib/swift/host/plugins"))
6755-
XCTAssertTrue(components[1].hasSuffix("/usr/bin/swift-plugin-server"))
6756-
} else {
6757-
XCTFail("# separated count must 2")
6758-
}
6759-
default:
6760-
XCTFail("invalid arg type after '-external-plugin-path'")
6761-
}
6762-
6763-
let idx2 = job.commandLine[job.commandLine.index(after: idx1!)...].firstIndex(of: .flag("-external-plugin-path"))
6764-
switch job.commandLine[job.commandLine.index(after: try XCTUnwrap(idx2))] {
6765-
case .flag(let value):
6766-
let components = value.split(separator: "#")
6767-
if (components.count == 2) {
6768-
XCTAssertTrue(components[0].hasSuffix("/usr/local/lib/swift/host/plugins"))
6769-
XCTAssertTrue(components[1].hasSuffix("/usr/bin/swift-plugin-server"))
6770-
} else {
6771-
XCTFail("# separated count must 2")
6772-
}
6773-
default:
6774-
XCTFail("invalid arg type after '-external-plugin-path'")
6775-
}
6776-
}
6777-
}
6778-
67796730
func testClangModuleValidateOnce() throws {
67806731
let flagTest = try Driver(args: ["swiftc", "-typecheck", "foo.swift"])
67816732
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
diagnosticsEngine: 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)