summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-07-23 17:45:54 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-09-09 13:26:27 +0300
commitf809ec760aad0f6532f284f3c89daa99638d5b0c (patch)
tree7321ce9a36644962aedf4034560f31ad7fbdf92e
parent324e1f0f035f901aa04a520cb76e36aeca5cf54b (diff)
downloadqtlocation-mapboxgl-f809ec760aad0f6532f284f3c89daa99638d5b0c.tar.gz
[build] Mark explicitly visible symbols
Easier to maintain than a linker script. We build everything with visibility hidden by default.
-rw-r--r--benchmark/include/mbgl/benchmark.hpp4
-rw-r--r--include/mbgl/util/util.hpp21
-rw-r--r--platform/android/src/jni.hpp2
-rw-r--r--platform/android/src/jni_native.hpp4
-rw-r--r--platform/android/src/test/runtime.cpp1
-rw-r--r--test/include/mbgl/test.hpp4
6 files changed, 33 insertions, 3 deletions
diff --git a/benchmark/include/mbgl/benchmark.hpp b/benchmark/include/mbgl/benchmark.hpp
index 1a9904de51..f78bcb09c6 100644
--- a/benchmark/include/mbgl/benchmark.hpp
+++ b/benchmark/include/mbgl/benchmark.hpp
@@ -1,7 +1,9 @@
#pragma once
+#include <mbgl/util/util.hpp>
+
namespace mbgl {
-int runBenchmark(int argc, char* argv[]);
+MBGL_PUBLIC int runBenchmark(int argc, char* argv[]);
} // namespace mbgl
diff --git a/include/mbgl/util/util.hpp b/include/mbgl/util/util.hpp
index 7960b40299..6b6107b0e6 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_PUBLIC __attribute__((dllexport))
+ #else
+ #define MBGL_PUBLIC __declspec(dllexport)
+ #endif
+ #else
+ #ifdef __GNUC__
+ #define MBGL_PUBLIC __attribute__((dllimport))
+ #else
+ #define MBGL_PUBLIC __declspec(dllimport)
+ #endif
+ #endif
+#else
+ #define MBGL_PUBLIC __attribute__((visibility ("default")))
+#endif
diff --git a/platform/android/src/jni.hpp b/platform/android/src/jni.hpp
index cb519f911d..9bfe2ce5b7 100644
--- a/platform/android/src/jni.hpp
+++ b/platform/android/src/jni.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <mbgl/util/util.hpp>
+
#include <string>
#include <jni/jni.hpp>
diff --git a/platform/android/src/jni_native.hpp b/platform/android/src/jni_native.hpp
index a4c89d3036..c8e284a523 100644
--- a/platform/android/src/jni_native.hpp
+++ b/platform/android/src/jni_native.hpp
@@ -1,11 +1,13 @@
#pragma once
+#include <mbgl/util/util.hpp>
+
#include "jni.hpp"
namespace mbgl {
namespace android {
-void registerNatives(JavaVM* vm);
+MBGL_PUBLIC 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 9cf79c501c..1f8f16da3c 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 <cassert>
#include <dlfcn.h>
diff --git a/test/include/mbgl/test.hpp b/test/include/mbgl/test.hpp
index ad5b868f30..4524b6bf23 100644
--- a/test/include/mbgl/test.hpp
+++ b/test/include/mbgl/test.hpp
@@ -1,7 +1,9 @@
#pragma once
+#include <mbgl/util/util.hpp>
+
namespace mbgl {
-int runTests(int argc, char* argv[]);
+MBGL_PUBLIC int runTests(int argc, char* argv[]);
} // namespace mbgl