From 99bf02f27f727331ec9e5442c229cb8a552b7c8d Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Fri, 10 Dec 2021 11:24:59 +0100 Subject: [PATCH] Thunks/gen: Add support for libraries with "-" in the filename --- ThunkLibs/Generator/gen.cpp | 10 ++++++++-- ThunkLibs/Generator/interface.h | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ThunkLibs/Generator/gen.cpp b/ThunkLibs/Generator/gen.cpp index 07d8bf0c7..195c6d037 100644 --- a/ThunkLibs/Generator/gen.cpp +++ b/ThunkLibs/Generator/gen.cpp @@ -377,7 +377,13 @@ public: }; FrontendAction::FrontendAction(const std::string& libname_, const OutputFilenames& output_filenames_) - : libname(libname_), output_filenames(output_filenames_) { + : libfilename(libname_), libname(libname_), output_filenames(output_filenames_) { + for (auto& c : libname) { + if (c == '-') { + c = '_'; + } + } + thunks.clear(); thunked_api.clear(); namespaces.clear(); @@ -628,7 +634,7 @@ void FrontendAction::EndSourceFileAction() { if (lib_version) { version_suffix = '.' + std::to_string(*lib_version); } - const std::string library_filename = libname + ".so" + version_suffix; + const std::string library_filename = libfilename + ".so" + version_suffix; file << " fexldr_ptr_" << libname << "_so = dlopen(\"" << library_filename << "\", RTLD_LOCAL | RTLD_LAZY);\n"; file << " if (!fexldr_ptr_" << libname << "_so) { return false; }\n\n"; diff --git a/ThunkLibs/Generator/interface.h b/ThunkLibs/Generator/interface.h index 861f6f066..5bf583055 100644 --- a/ThunkLibs/Generator/interface.h +++ b/ThunkLibs/Generator/interface.h @@ -32,6 +32,7 @@ public: std::unique_ptr CreateASTConsumer(clang::CompilerInstance&, clang::StringRef /*file*/) override; private: - const std::string& libname; + const std::string& libfilename; + std::string libname; // sanitized filename, usable as part of emitted function names const OutputFilenames& output_filenames; };