From fa60f43751b097e3e0621b3ca46538fbe523fa6f Mon Sep 17 00:00:00 2001
From: Danilo Piparo <danilo.piparo@cern.ch>
Date: Mon, 13 May 2019 10:08:59 +0200
Subject: [PATCH] [DictGen][ROOT-8566] Include extra includes in dictionary
 payload

---
 core/dictgen/res/TModuleGenerator.h   | 4 +++-
 core/dictgen/src/TModuleGenerator.cxx | 9 ++++++---
 core/dictgen/src/rootcling_impl.cxx   | 4 +++-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/core/dictgen/res/TModuleGenerator.h b/core/dictgen/res/TModuleGenerator.h
index cf7cbedd08f..22678f2762d 100644
--- a/core/dictgen/res/TModuleGenerator.h
+++ b/core/dictgen/res/TModuleGenerator.h
@@ -83,6 +83,7 @@ namespace ROOT {
       const std::vector<std::string> &GetHeaders() const {
          return fHeaders;
       }
+
       const std::vector<std::string> &GetIncludePaths() const {
          return fCompI;
       }
@@ -93,7 +94,8 @@ namespace ROOT {
       void WriteRegistrationSource(std::ostream &out,
                                    const std::string &fwdDeclnArgsToKeepString,
                                    const std::string &headersClassesMapString,
-                                   const std::string &fwdDeclsString) const;
+                                   const std::string &fwdDeclsString,
+                                   const std::string &extraIncludes) const;
       void WriteContentHeader(std::ostream &out) const;
       void WriteUmbrellaHeader(std::ostream &out) const;
 
diff --git a/core/dictgen/src/TModuleGenerator.cxx b/core/dictgen/src/TModuleGenerator.cxx
index d5404418afd..a7608e0b914 100644
--- a/core/dictgen/src/TModuleGenerator.cxx
+++ b/core/dictgen/src/TModuleGenerator.cxx
@@ -344,7 +344,8 @@ std::ostream &TModuleGenerator::WriteStringPairVec(const StringPairVec_t &vec,
 void TModuleGenerator::WriteRegistrationSource(std::ostream &out,
       const std::string &fwdDeclnArgsToKeepString,
       const std::string &headersClassesMapString,
-      const std::string &fwdDeclString) const
+      const std::string &fwdDeclString,
+      const std::string &extraIncludes) const
 {
 
    std::string fwdDeclStringSanitized = fwdDeclString;
@@ -441,8 +442,10 @@ void TModuleGenerator::WriteRegistrationSource(std::ostream &out,
    // way to express as a pragma the option "-Wno-deprecated" the
    // _BACKWARD_BACKWARD_WARNING_H macro, used to avoid to go through
    // backward/backward_warning.h.
-   payloadCode += "#define _BACKWARD_BACKWARD_WARNING_H\n" +
-                  inlinedHeaders + "\n"
+   payloadCode += "#define _BACKWARD_BACKWARD_WARNING_H\n"
+                  "// Inline headers\n"+
+                  inlinedHeaders + "\n"+
+                  (extraIncludes.empty() ? "" : "// Extra includes\n" + extraIncludes + "\n") +
                   "#undef  _BACKWARD_BACKWARD_WARNING_H\n";
 
    // Dictionary initialization code for loading the module
diff --git a/core/dictgen/src/rootcling_impl.cxx b/core/dictgen/src/rootcling_impl.cxx
index 4a6271c5193..c3a9158b09a 100644
--- a/core/dictgen/src/rootcling_impl.cxx
+++ b/core/dictgen/src/rootcling_impl.cxx
@@ -4639,6 +4639,7 @@ int RootClingMain(int argc,
          ROOT::TMetaUtils::Error(0, "Error loading the #pragma extra_include.\n");
          return 1;
       }
+
    } else if (isSelXML) {
 
       selectionRules.SetSelectionFileType(SelectionRules::kSelectionXMLFile);
@@ -4686,6 +4687,7 @@ int RootClingMain(int argc,
          ROOT::TMetaUtils::Error(0, "Error loading the #pragma extra_include.\n");
          return 1;
       }
+      
    } else {
 
       ROOT::TMetaUtils::Error(0, "Unrecognized selection file: %s\n", linkdefFilename.c_str());
@@ -4893,7 +4895,7 @@ int RootClingMain(int argc,
          }
       }
 
-      modGen.WriteRegistrationSource(dictStream, fwdDeclnArgsToKeepString, headersClassesMapString, fwdDeclsString);
+      modGen.WriteRegistrationSource(dictStream, fwdDeclnArgsToKeepString, headersClassesMapString, fwdDeclsString, extraIncludes);
       // If we just want to inline the input header, we don't need
       // to generate any files.
       if (!inlineInputHeader) {
-- 
GitLab