[Macro] Add a new macro loading option that do not involve searching

Add flag `-load-resolved-plugin` to load macro plugin, which provides a
pre-resolved entry into PluginLoader so the plugins can be loaded based
on module name without searching the file system. The option is mainly
intended to be used by explicitly module build and the flag is supplied
by dependency scanner.
This commit is contained in:
Steven Wu
2024-09-20 14:30:28 -07:00
parent 56ec62570f
commit 47b3efdb6e
11 changed files with 112 additions and 8 deletions

View File

@@ -2169,6 +2169,27 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
resolveSearchPath(dylibPath), resolveSearchPath(serverPath)});
break;
}
case OPT_load_resolved_plugin: {
StringRef libraryPath;
StringRef executablePath;
StringRef modulesStr;
std::tie(libraryPath, executablePath) =
StringRef(A->getValue()).split('#');
std::tie(executablePath, modulesStr) = executablePath.split('#');
if (modulesStr.empty() ||
(libraryPath.empty() && executablePath.empty())) {
Diags.diagnose(SourceLoc(), diag::error_load_resolved_plugin,
A->getValue());
}
std::vector<std::string> moduleNames;
for (auto name : llvm::split(modulesStr, ',')) {
moduleNames.emplace_back(name);
}
Opts.PluginSearchOpts.emplace_back(
PluginSearchOption::ResolvedPluginConfig{
libraryPath.str(), executablePath.str(), std::move(moduleNames)});
break;
}
default:
llvm_unreachable("unhandled plugin search option");
}