Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/CppInterOp/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3310,12 +3310,28 @@ void AddLibrarySearchPaths(const std::string& ResourceDir,
false, false);
}
}
std::string ExtractArgument(const std::vector<const char*>& Args,
const std::string& Arg) {
size_t I = 0;
for (auto i = Args.begin(); i != Args.end(); i++)
if ((++I < Args.size()) && (*i == Arg))
return *(++i);
return "";
}
} // namespace

TInterp_t CreateInterpreter(const std::vector<const char*>& Args /*={}*/,
const std::vector<const char*>& GpuArgs /*={}*/) {
std::string MainExecutableName = sys::fs::getMainExecutable(nullptr, nullptr);
std::string ResourceDir = MakeResourcesPath();
// In some systems, CppInterOp cannot manually detect the correct resource.
// Then the -resource-dir passed by the user is assumed to be the correct
// location. Prioritising it over detecting it within CppInterOp. Extracting
// the resource-dir from the arguments is required because we set the
// necessary library search location explicitly below. Because by default,
// linker flags are ignored in repl (issue #748)
std::string ResourceDir = ExtractArgument(Args, "-resource-dir");
if (ResourceDir.empty())
ResourceDir = MakeResourcesPath();
llvm::Triple T(llvm::sys::getProcessTriple());
namespace fs = std::filesystem;
if ((!fs::is_directory(ResourceDir)) && (T.isOSDarwin() || T.isOSLinux()))
Expand Down
Loading