[icinga-checkins] icinga.org: icinga2/master: Fix building Icinga with -fvisibility=hidden

git at icinga.org git at icinga.org
Tue Aug 9 09:00:43 CEST 2016


Module: icinga2
Branch: master
Commit: 9f425cdcafae84292a4ee1030ea40c47dff0cebb
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=9f425cdcafae84292a4ee1030ea40c47dff0cebb

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Tue Aug  9 09:00:19 2016 +0200

Fix building Icinga with -fvisibility=hidden

fixes #12331

---

 lib/base/configobject.cpp       |    3 +++
 lib/base/configobject.ti        |    5 ++++-
 lib/base/type.hpp               |    2 +-
 lib/base/visibility.hpp         |    3 ++-
 tools/mkclass/classcompiler.cpp |   24 +++++++++++++++---------
 5 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/lib/base/configobject.cpp b/lib/base/configobject.cpp
index 84071ac..7db364f 100644
--- a/lib/base/configobject.cpp
+++ b/lib/base/configobject.cpp
@@ -690,3 +690,6 @@ ConfigObject::Ptr ConfigObject::GetZone(void) const
 {
 	return m_Zone;
 }
+
+NameComposer::~NameComposer(void)
+{ }
diff --git a/lib/base/configobject.ti b/lib/base/configobject.ti
index bd2ff91..57a760e 100644
--- a/lib/base/configobject.ti
+++ b/lib/base/configobject.ti
@@ -31,8 +31,11 @@ enum HAMode
 	HARunEverywhere
 };
 
-class NameComposer {
+class I2_BASE_API NameComposer
+{
 public:
+	virtual ~NameComposer(void);
+
 	virtual String MakeName(const String& shortName, const Object::Ptr& context) const = 0;
 	virtual Dictionary::Ptr ParseName(const String& name) const = 0;
 };
diff --git a/lib/base/type.hpp b/lib/base/type.hpp
index f1d8049..eced9e7 100644
--- a/lib/base/type.hpp
+++ b/lib/base/type.hpp
@@ -132,7 +132,7 @@ protected:
 };
 
 template<typename T>
-class TypeImpl
+class I2_BASE_API TypeImpl
 {
 };
 
diff --git a/lib/base/visibility.hpp b/lib/base/visibility.hpp
index 7e5270e..8a2afc2 100644
--- a/lib/base/visibility.hpp
+++ b/lib/base/visibility.hpp
@@ -22,10 +22,11 @@
 
 #ifndef _WIN32
 #	define I2_EXPORT __attribute__ ((visibility("default")))
-#	define I2_IMPORT
+#	define I2_IMPORT __attribute__ ((visibility("default")))
 #else /* _WIN32 */
 #	define I2_EXPORT __declspec(dllexport)
 #	define I2_IMPORT __declspec(dllimport)
+#	define I2_HIDDEN
 #endif /* _WIN32 */
 
 #define TOKENPASTE(x, y) x ## y
diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp
index 4c71364..80c0b10 100644
--- a/tools/mkclass/classcompiler.cpp
+++ b/tools/mkclass/classcompiler.cpp
@@ -109,6 +109,20 @@ void ClassCompiler::HandleCode(const std::string& code, const ClassDebugInfo&)
 void ClassCompiler::HandleLibrary(const std::string& library, const ClassDebugInfo& locp)
 {
 	m_Library = library;
+
+	std::string libName = m_Library;
+	std::locale locale;
+
+	for (std::string::size_type i = 0; i < libName.size(); i++)
+		libName[i] = std::toupper(libName[i], locale);
+
+	m_Header << "#ifndef I2_" << libName << "_API" << std::endl
+		 << "#	ifdef I2_" << libName << "_BUILD" << std::endl
+		 << "#		define I2_" << libName << "_API I2_EXPORT" << std::endl
+		 << "#	else /* I2_" << libName << "_BUILD */" << std::endl
+		 << "#		define I2_" << libName << "_API I2_IMPORT" << std::endl
+		 << "#	endif /* I2_" << libName << "_BUILD */" << std::endl
+		 << "#endif /* I2_" << libName << "_API */" << std::endl << std::endl;
 }
 
 unsigned long ClassCompiler::SDBM(const std::string& str, size_t len = std::string::npos)
@@ -204,14 +218,6 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
 		for (std::string::size_type i = 0; i < libName.size(); i++)
 			libName[i] = std::toupper(libName[i], locale);
 
-		m_Header << "#ifndef I2_" << libName << "_API" << std::endl
-			 << "#	ifdef I2_" << libName << "_BUILD" << std::endl
-			 << "#		define I2_" << libName << "_API I2_EXPORT" << std::endl
-			 << "#	else /* I2_" << libName << "_BUILD */" << std::endl
-			 << "#		define I2_" << libName << "_API I2_IMPORT" << std::endl
-			 << "#	endif /* I2_" << libName << "_BUILD */" << std::endl
-			 << "#endif /* I2_" << libName << "_API */" << std::endl << std::endl;
-
 		apiMacro = "I2_" + libName + "_API ";
 	}
 
@@ -233,7 +239,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
 
 	/* TypeImpl */
 	m_Header << "template<>" << std::endl
-		 << "class TypeImpl<" << klass.Name << ">"
+		 << "class " << apiMacro << "TypeImpl<" << klass.Name << ">"
 		 << " : public Type";
 	
 	if (!klass.TypeBase.empty())



More information about the icinga-checkins mailing list