mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user