From d1f1ef922f329f3a5f729c34dde615d5afeb5ac6 Mon Sep 17 00:00:00 2001 From: Sudarsana Babu Nagineni Date: Thu, 9 Aug 2018 17:13:05 +0300 Subject: Fix Android build Cherry picked from commit fc0745a699a0ef60c080e9c2ff5eaecde9cb5306 --- include/mbgl/math/log2.hpp | 16 ++++++++++++++++ mapbox-gl-native.pro | 4 ++++ src/mbgl/renderer/buckets/symbol_bucket.cpp | 4 ++-- src/mbgl/util/tile_cover.cpp | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/mbgl/math/log2.hpp b/include/mbgl/math/log2.hpp index 6a1ba23ed9..3136ac22b4 100644 --- a/include/mbgl/math/log2.hpp +++ b/include/mbgl/math/log2.hpp @@ -2,6 +2,11 @@ #include #include +#include + +#if defined(__ANDROID__) +#include +#endif namespace mbgl { namespace util { @@ -12,3 +17,14 @@ uint32_t ceil_log2(uint64_t x); } // namespace util } // namespace mbgl + +// log2 is not available on Android before API 18. +#if defined(__ANDROID__) && defined(__GNUC__) && \ + defined(__ANDROID_API__) && __ANDROID_API__ < 18 + +template +typename std::enable_if_t::value, T> log2(T x) { + return ::log(x) / M_LN2; +} + +#endif diff --git a/mapbox-gl-native.pro b/mapbox-gl-native.pro index 2f499b6ec5..ed974db779 100644 --- a/mapbox-gl-native.pro +++ b/mapbox-gl-native.pro @@ -29,6 +29,10 @@ android|win32|darwin|qnx { platform/default/thread.cpp } +android|gcc { + QMAKE_CFLAGS += -std=c99 +} + darwin { LIBS += \ -framework Foundation diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index 0a1530ae74..9b73124be4 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -193,8 +193,8 @@ void SymbolBucket::sortFeatures(const float angle) { std::sort(symbolInstanceIndexes.begin(), symbolInstanceIndexes.end(), [sin, cos, this](size_t &aIndex, size_t &bIndex) { const SymbolInstance& a = symbolInstances[aIndex]; const SymbolInstance& b = symbolInstances[bIndex]; - const int32_t aRotated = static_cast(std::lround(sin * a.anchor.point.x + cos * a.anchor.point.y)); - const int32_t bRotated = static_cast(std::lround(sin * b.anchor.point.x + cos * b.anchor.point.y)); + const int32_t aRotated = static_cast(::lround(sin * a.anchor.point.x + cos * a.anchor.point.y)); + const int32_t bRotated = static_cast(::lround(sin * b.anchor.point.x + cos * b.anchor.point.y)); return aRotated != bRotated ? aRotated < bRotated : a.dataFeatureIndex > b.dataFeatureIndex; diff --git a/src/mbgl/util/tile_cover.cpp b/src/mbgl/util/tile_cover.cpp index 3f39e53d40..f58d1270bd 100644 --- a/src/mbgl/util/tile_cover.cpp +++ b/src/mbgl/util/tile_cover.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include -- cgit v1.2.1