aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-29 15:01:40 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-01 10:51:58 +0200
commit430d02db24b95a56ae0acc6a9df6a0effe49da0d (patch)
tree8713f11a51f42205dcf2d06894f7f9caa9a49cbe /sources/shiboken2/libshiboken
parent26e4ba3639bac57b0481bd6bb3964b1afa340ab9 (diff)
Consolidate export/import macros
For the 3 libraries that need to export symbols, (libshiboken, libpyside, pysidetest), fix up the export/import macros to follow the Qt convention: - Define generic export/import macros LIBSHIBOKEN_EX/IMPORT equivalent to Q_DECL_EX/IMPORT. Remove definitions for the ancient g++ 4.X. - Reuse those in libpyside, pysidetest as PYSIDE_EX/IMPORT and PYSIDETEST_EX/IMPORT. - While building, define some BUILD_ macro indicating export. - Define the _API macros depending on the BUILD_ macro to be export or import, respectively as is done in Qt. Remove the ugly hack in pysidetest that tried to re-use the PYSIDE_API macro. - Brush up the headers a bit. Change-Id: I635891b7eec5a52a1dcf45022f7bfb6a9cfee83f Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/libshiboken')
-rw-r--r--sources/shiboken2/libshiboken/CMakeLists.txt2
-rw-r--r--sources/shiboken2/libshiboken/shibokenmacros.h33
2 files changed, 18 insertions, 17 deletions
diff --git a/sources/shiboken2/libshiboken/CMakeLists.txt b/sources/shiboken2/libshiboken/CMakeLists.txt
index a53402e0f..a209dc711 100644
--- a/sources/shiboken2/libshiboken/CMakeLists.txt
+++ b/sources/shiboken2/libshiboken/CMakeLists.txt
@@ -120,7 +120,7 @@ endif()
set_target_properties(libshiboken PROPERTIES OUTPUT_NAME "shiboken2${shiboken2_SUFFIX}${PYTHON_SHARED_LIBRARY_SUFFIX}"
VERSION ${libshiboken_VERSION}
SOVERSION ${libshiboken_SOVERSION}
- DEFINE_SYMBOL LIBSHIBOKEN_EXPORTS)
+ DEFINE_SYMBOL BUILD_LIBSHIBOKEN)
install(FILES
autodecref.h
diff --git a/sources/shiboken2/libshiboken/shibokenmacros.h b/sources/shiboken2/libshiboken/shibokenmacros.h
index 7bebd85e4..d8f45868a 100644
--- a/sources/shiboken2/libshiboken/shibokenmacros.h
+++ b/sources/shiboken2/libshiboken/shibokenmacros.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt for Python.
@@ -42,22 +42,23 @@
// LIBSHIBOKEN_API macro is used for the public API symbols.
#if defined _WIN32
- #if LIBSHIBOKEN_EXPORTS
- #define LIBSHIBOKEN_API __declspec(dllexport)
- #else
- #ifdef _MSC_VER
- #define LIBSHIBOKEN_API __declspec(dllimport)
- #endif
- #endif
- #define SBK_DEPRECATED(func) __declspec(deprecated) func
-#elif __GNUC__ >= 4
- #define LIBSHIBOKEN_API __attribute__ ((visibility("default")))
- #define SBK_DEPRECATED(func) func __attribute__ ((deprecated))
+# define LIBSHIBOKEN_EXPORT __declspec(dllexport)
+# ifdef _MSC_VER
+# define LIBSHIBOKEN_IMPORT __declspec(dllimport)
+# else
+# define LIBSHIBOKEN_IMPORT
+# endif
+# define SBK_DEPRECATED(func) __declspec(deprecated) func
+#else
+# define LIBSHIBOKEN_EXPORT __attribute__ ((visibility("default")))
+# define LIBSHIBOKEN_IMPORT
+# define SBK_DEPRECATED(func) func __attribute__ ((deprecated))
#endif
-#ifndef LIBSHIBOKEN_API
- #define LIBSHIBOKEN_API
- #define SBK_DEPRECATED(func) func
+#ifdef BUILD_LIBSHIBOKEN
+# define LIBSHIBOKEN_API LIBSHIBOKEN_EXPORT
+#else
+# define LIBSHIBOKEN_API LIBSHIBOKEN_IMPORT
#endif
-#endif
+#endif // SHIBOKENMACROS_H