From a849b38390c66f968678630eb44eb6061d82b333 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Tue, 23 Jul 2019 17:45:54 +0300 Subject: [PATCH] [build] Mark explicitly visible symbols Easier to maintain than a linker script. We build everything with visibility hidden by default. --- benchmark/include/mbgl/benchmark.hpp | 4 +++- include/mbgl/util/util.hpp | 21 +++++++++++++++++++++ platform/android/src/jni.hpp | 2 ++ platform/android/src/jni_native.hpp | 4 +++- platform/android/src/test/runtime.cpp | 1 + test/include/mbgl/test.hpp | 4 +++- 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/benchmark/include/mbgl/benchmark.hpp b/benchmark/include/mbgl/benchmark.hpp index 1a9904de5..f68c847a7 100644 --- a/benchmark/include/mbgl/benchmark.hpp +++ b/benchmark/include/mbgl/benchmark.hpp @@ -1,7 +1,9 @@ #pragma once +#include + namespace mbgl { -int runBenchmark(int argc, char* argv[]); +MBGL_EXPORT int runBenchmark(int argc, char* argv[]); } // namespace mbgl diff --git a/include/mbgl/util/util.hpp b/include/mbgl/util/util.hpp index 7960b4029..178f1cba4 100644 --- a/include/mbgl/util/util.hpp +++ b/include/mbgl/util/util.hpp @@ -19,3 +19,24 @@ #else #define MBGL_CONSTEXPR inline #endif + +// Compiler defines for making symbols visible, otherwise they +// will be defined as hidden by default. + +#if defined WIN32 + #ifdef MBGL_BUILDING_LIB + #ifdef __GNUC__ + #define MBGL_EXPORT __attribute__((dllexport)) + #else + #define MBGL_EXPORT __declspec(dllexport) + #endif + #else + #ifdef __GNUC__ + #define MBGL_EXPORT __attribute__((dllimport)) + #else + #define MBGL_EXPORT __declspec(dllimport) + #endif + #endif +#else + #define MBGL_EXPORT __attribute__((visibility ("default"))) // NOLINT +#endif diff --git a/platform/android/src/jni.hpp b/platform/android/src/jni.hpp index cb519f911..9bfe2ce5b 100644 --- a/platform/android/src/jni.hpp +++ b/platform/android/src/jni.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include diff --git a/platform/android/src/jni_native.hpp b/platform/android/src/jni_native.hpp index a4c89d303..1cc9a7e81 100644 --- a/platform/android/src/jni_native.hpp +++ b/platform/android/src/jni_native.hpp @@ -1,11 +1,13 @@ #pragma once +#include + #include "jni.hpp" namespace mbgl { namespace android { -void registerNatives(JavaVM* vm); +MBGL_EXPORT void registerNatives(JavaVM* vm); } // namespace android } // namespace mbgl diff --git a/platform/android/src/test/runtime.cpp b/platform/android/src/test/runtime.cpp index 9cf79c501..1f8f16da3 100644 --- a/platform/android/src/test/runtime.cpp +++ b/platform/android/src/test/runtime.cpp @@ -1,5 +1,6 @@ #include "runtime.hpp" #include "../jni.hpp" +#include "../jni_native.hpp" #include #include diff --git a/test/include/mbgl/test.hpp b/test/include/mbgl/test.hpp index ad5b868f3..db47ebb8d 100644 --- a/test/include/mbgl/test.hpp +++ b/test/include/mbgl/test.hpp @@ -1,7 +1,9 @@ #pragma once +#include + namespace mbgl { -int runTests(int argc, char* argv[]); +MBGL_EXPORT int runTests(int argc, char* argv[]); } // namespace mbgl