@@ -620,6 +620,51 @@ void toolchains::Darwin::addCommonFrontendArgs(
620620 }
621621}
622622
623+ // / Add the frontend arguments needed to find external plugins in standard
624+ // / locations based on the base path.
625+ static void addExternalPluginFrontendArgs (
626+ StringRef basePath, const llvm::opt::ArgList &inputArgs,
627+ llvm::opt::ArgStringList &arguments) {
628+ // Plugin server: $BASE/usr/bin/swift-plugin-server
629+ SmallString<128 > pluginServer;
630+ llvm::sys::path::append (
631+ pluginServer, basePath, " usr" , " bin" , " swift-plugin-server" );
632+
633+ SmallString<128 > pluginDir;
634+ llvm::sys::path::append (pluginDir, basePath, " usr" , " lib" );
635+ llvm::sys::path::append (pluginDir, " swift" , " host" , " plugins" );
636+ arguments.push_back (" -external-plugin-path" );
637+ arguments.push_back (inputArgs.MakeArgString (pluginDir + " #" + pluginServer));
638+
639+ pluginDir.clear ();
640+ llvm::sys::path::append (pluginDir, basePath, " usr" , " local" , " lib" );
641+ llvm::sys::path::append (pluginDir, " swift" , " host" , " plugins" );
642+ arguments.push_back (" -external-plugin-path" );
643+ arguments.push_back (inputArgs.MakeArgString (pluginDir + " #" + pluginServer));
644+ }
645+
646+ void toolchains::Darwin::addPlatformSpecificPluginFrontendArgs (
647+ const OutputInfo &OI,
648+ const CommandOutput &output,
649+ const llvm::opt::ArgList &inputArgs,
650+ llvm::opt::ArgStringList &arguments) const {
651+ // Add SDK-relative directories for plugins.
652+ if (!OI.SDKPath .empty ()) {
653+ addExternalPluginFrontendArgs (OI.SDKPath , inputArgs, arguments);
654+ }
655+
656+ // Add platform-relative directories for plugins.
657+ if (!OI.SDKPath .empty ()) {
658+ SmallString<128 > platformPath;
659+ llvm::sys::path::append (platformPath, OI.SDKPath );
660+ llvm::sys::path::remove_filename (platformPath); // specific SDK
661+ llvm::sys::path::remove_filename (platformPath); // SDKs
662+ llvm::sys::path::remove_filename (platformPath); // Developer
663+ llvm::sys::path::append (platformPath, " Developer" );
664+ addExternalPluginFrontendArgs (platformPath, inputArgs, arguments);
665+ }
666+ }
667+
623668ToolChain::InvocationInfo
624669toolchains::Darwin::constructInvocation (const DynamicLinkJobAction &job,
625670 const JobContext &context) const {
0 commit comments