From af0e1abffdccde30f31abc714d1434c68beaf1a3 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Fri, 8 Mar 2024 14:07:13 +0100 Subject: [PATCH] [core] only return core as shared lib for doxygen documentation purposes --- core/meta/inc/TInterpreter.h | 2 +- core/metacling/src/TCling.cxx | 15 +++++++---- core/metacling/src/TCling.h | 2 +- core/metacling/test/TClingTests.cxx | 41 +---------------------------- documentation/doxygen/libs.C | 2 +- 5 files changed, 14 insertions(+), 48 deletions(-) diff --git a/core/meta/inc/TInterpreter.h b/core/meta/inc/TInterpreter.h index c974184392651..165ce9079bc05 100644 --- a/core/meta/inc/TInterpreter.h +++ b/core/meta/inc/TInterpreter.h @@ -157,7 +157,7 @@ class TInterpreter : public TNamed { virtual Int_t GenerateDictionary(const char *classes, const char *includes = nullptr, const char *options = nullptr) = 0; virtual char *GetPrompt() = 0; virtual const char *GetSharedLibs() = 0; - virtual const char *GetClassSharedLibs(const char *cls) = 0; + virtual const char *GetClassSharedLibs(const char *cls, bool skipCore = true) = 0; virtual const char *GetSharedLibDeps(const char *lib, bool tryDyld = false) = 0; virtual const char *GetIncludePath() = 0; virtual const char *GetSTLIncludePath() const { return ""; } diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 490736ef426ab..c159a89101a4e 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -630,9 +630,9 @@ extern "C" int TCling__AutoParseCallback(const char* className) return ((TCling*)gCling)->AutoParse(className); } -extern "C" const char* TCling__GetClassSharedLibs(const char* className) +extern "C" const char* TCling__GetClassSharedLibs(const char* className, bool skipCore) { - return ((TCling*)gCling)->GetClassSharedLibs(className); + return ((TCling*)gCling)->GetClassSharedLibs(className, skipCore); } // Returns 0 for failure 1 for success @@ -6942,7 +6942,7 @@ const char* TCling::GetSharedLibs() return fSharedLibs; } -static std::string GetClassSharedLibsForModule(const char *cls, cling::LookupHelper &LH) +static std::string GetClassSharedLibsForModule(const char *cls, cling::LookupHelper &LH, bool skipCore) { if (!cls || !*cls) return {}; @@ -7019,6 +7019,9 @@ static std::string GetClassSharedLibsForModule(const char *cls, cling::LookupHel // link declaration. if (!M->LinkLibraries.size()) continue; + // We have preloaded the Core module thus libCore.so + if (M->Name == "Core" && skipCore) + continue; assert(M->LinkLibraries.size() == 1); if (!result.empty()) result += ' '; @@ -7034,8 +7037,10 @@ static std::string GetClassSharedLibsForModule(const char *cls, cling::LookupHel /// The first library in the list is the one containing the class, the /// others are the libraries the first one depends on. Returns 0 /// in case the library is not found. +/// \param cls the name of the class +/// \param skipCore if true (default), remove "Core" from the returned list -const char* TCling::GetClassSharedLibs(const char* cls) +const char* TCling::GetClassSharedLibs(const char* cls, bool skipCore) { if (fCxxModulesEnabled) { // Lock the interpreter mutex before interacting with cling. @@ -7054,7 +7059,7 @@ const char* TCling::GetClassSharedLibs(const char* cls) // Limit the recursion which can be induced by GetClassSharedLibsForModule. SuspendAutoLoadingRAII AutoLoadingDisabled(this); cling::LookupHelper &LH = fInterpreter->getLookupHelper(); - std::string libs = GetClassSharedLibsForModule(cls, LH); + std::string libs = GetClassSharedLibsForModule(cls, LH, skipCore); if (!libs.empty()) { fAutoLoadLibStorage.push_back(libs); return fAutoLoadLibStorage.back().c_str(); diff --git a/core/metacling/src/TCling.h b/core/metacling/src/TCling.h index 0f3d57e07ab72..8c728b71db8f1 100644 --- a/core/metacling/src/TCling.h +++ b/core/metacling/src/TCling.h @@ -216,7 +216,7 @@ class TCling final : public TInterpreter { Int_t GenerateDictionary(const char* classes, const char* includes = "", const char* options = nullptr) final; char* GetPrompt() final { return fPrompt; } const char* GetSharedLibs() final; - const char* GetClassSharedLibs(const char* cls) final; + const char* GetClassSharedLibs(const char* cls, bool skipCore = true) final; const char* GetSharedLibDeps(const char* lib, bool tryDyld = false) final; const char* GetIncludePath() final; virtual const char* GetSTLIncludePath() const final; diff --git a/core/metacling/test/TClingTests.cxx b/core/metacling/test/TClingTests.cxx index 50f6ea8426f96..432de8616c5de 100644 --- a/core/metacling/test/TClingTests.cxx +++ b/core/metacling/test/TClingTests.cxx @@ -132,7 +132,7 @@ TEST_F(TClingTests, GetClassSharedLibs) { // Shortens the invocation. auto GetLibs = [](const char *cls) -> std::string { - if (const char *val = gInterpreter->GetClassSharedLibs(cls)) + if (const char *val = gInterpreter->GetClassSharedLibs(cls,false)) return val; return ""; }; @@ -169,45 +169,6 @@ TEST_F(TClingTests, GetClassSharedLibs) // GetLibs("ROOT::Math::LorentzVector >") // != GetLibs("ROOT::Math::LorentzVector>") // note the missing space. - - lib = GetLibs("TArray"); - EXPECT_EQ("Core", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TInterpreter"); - EXPECT_EQ("Core", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TRandom"); - EXPECT_EQ("MathCore", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TTree"); - EXPECT_EQ("Tree", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TTreeViewer"); - EXPECT_EQ("TreeViewer", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TGraph"); - EXPECT_EQ("Hist", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TGWindow"); - EXPECT_EQ("Gui", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TPad"); - EXPECT_EQ("Gpad", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TArrow"); - EXPECT_EQ("Graf", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TImage"); - EXPECT_EQ("Graf", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TASImage"); - EXPECT_EQ("ASImage", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TSpectrum"); - EXPECT_EQ("Spectrum", MakeLibNamePlatformIndependent(lib)); - - lib = GetLibs("TFile"); - EXPECT_EQ("RIO", MakeLibNamePlatformIndependent(lib)); } static std::string MakeDepLibsPlatformIndependent(const std::string &libs) { diff --git a/documentation/doxygen/libs.C b/documentation/doxygen/libs.C index e1b7c2bc5c595..782be1d604a64 100644 --- a/documentation/doxygen/libs.C +++ b/documentation/doxygen/libs.C @@ -12,7 +12,7 @@ void libs(TString classname) int i = classname.Index("_3"); if (i>0) classname.Remove(i,classname.Length()-i); - libname = gInterpreter->GetClassSharedLibs(classname.Data()); + libname = gInterpreter->GetClassSharedLibs(classname.Data(),false); if (!libname) return;