From 8b64fa547468dc32cbdf95d414596ad54dc27add Mon Sep 17 00:00:00 2001 From: Andrew Woloszyn Date: Mon, 17 Aug 2015 11:39:38 -0400 Subject: [PATCH] Fixes for compiling glslang on Android. Primarily fix is due to Android not supporting std::to_string(). --- SPIRV/SPVRemapper.cpp | 1 + StandAlone/CMakeLists.txt | 4 +++- glslang/Include/Common.h | 11 +++++++++++ glslang/MachineIndependent/intermOut.cpp | 2 ++ glslang/OSDependent/Linux/ossource.cpp | 4 ++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/SPIRV/SPVRemapper.cpp b/SPIRV/SPVRemapper.cpp index 1b06032..0f303e3 100755 --- a/SPIRV/SPVRemapper.cpp +++ b/SPIRV/SPVRemapper.cpp @@ -42,6 +42,7 @@ #include #include +#include "../glslang/Include/Common.h" namespace spv { diff --git a/StandAlone/CMakeLists.txt b/StandAlone/CMakeLists.txt index f5ebab9..bc35c08 100644 --- a/StandAlone/CMakeLists.txt +++ b/StandAlone/CMakeLists.txt @@ -24,7 +24,9 @@ set(LIBRARIES if(WIN32) set(LIBRARIES ${LIBRARIES} psapi) elseif(UNIX) - set(LIBRARIES ${LIBRARIES} pthread) + if(NOT ANDROID) + set(LIBRARIES ${LIBRARIES} pthread) + endif() endif(WIN32) target_link_libraries(glslangValidator ${LIBRARIES}) diff --git a/glslang/Include/Common.h b/glslang/Include/Common.h index 6076a34..9df6466 100644 --- a/glslang/Include/Common.h +++ b/glslang/Include/Common.h @@ -51,6 +51,17 @@ #define UINT_PTR uintptr_t #endif +#ifdef __ANDROID__ +#include +namespace std { +template +std::string to_string(const T& val) { + std::ostringstream os; + os << val; + return os.str(); +} +} +#endif /* windows only pragma */ #ifdef _MSC_VER #pragma warning(disable : 4786) // Don't warn about too long identifiers diff --git a/glslang/MachineIndependent/intermOut.cpp b/glslang/MachineIndependent/intermOut.cpp index 2b65ee1..16a3ec2 100644 --- a/glslang/MachineIndependent/intermOut.cpp +++ b/glslang/MachineIndependent/intermOut.cpp @@ -48,6 +48,8 @@ namespace { bool is_positive_infinity(double x) { #ifdef _MSC_VER return _fpclass(x) == _FPCLASS_PINF; +#elif defined __ANDROID__ + return std::isinf(x) && (x >= 0); #else return isinf(x) && (x >= 0); #endif diff --git a/glslang/OSDependent/Linux/ossource.cpp b/glslang/OSDependent/Linux/ossource.cpp index 8a1c53f..d66bead 100644 --- a/glslang/OSDependent/Linux/ossource.cpp +++ b/glslang/OSDependent/Linux/ossource.cpp @@ -62,6 +62,9 @@ void DetachThreadLinux(void *) // void OS_CleanupThreadData(void) { +#ifdef __ANDROID__ + DetachThread(); +#else int old_cancel_state, old_cancel_type; void *cleanupArg = NULL; @@ -85,6 +88,7 @@ void OS_CleanupThreadData(void) // Restore the thread's previous cancellation mode. // pthread_setcanceltype(old_cancel_state, NULL); +#endif } -- 2.7.4