From 75fba23b736a44706e727bf120a639adbd895327 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 8 Jan 2016 22:18:22 +0100 Subject: [PATCH] [DEV] correct the Vector2D dependency with cxx --- etk/math/Vector2D.cpp | 8 ++++---- etk/math/Vector2D.h | 2 +- etk/math/Vector3D.h | 10 +++------- etk/tool.cpp | 6 ++---- lutin_etk.py | 4 +++- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/etk/math/Vector2D.cpp b/etk/math/Vector2D.cpp index 681dafd..b4f896d 100644 --- a/etk/math/Vector2D.cpp +++ b/etk/math/Vector2D.cpp @@ -88,12 +88,12 @@ std::ostream& etk::operator <<(std::ostream& _os, const std::vector& _ob vec2 vec2rotate(const vec2& _val, const vec2& _point, float _angle) { vec2 out = _val; - #if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs) || __cplusplus < 201103L) - float sinAngle = sin(_angle); - float cosAngle = cos(_angle); - #else + #if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__) float sinAngle = std::sin(_angle); float cosAngle = std::cos(_angle); + #else + float sinAngle = sin(_angle); + float cosAngle = cos(_angle); #endif if (_point == vec2(0,0)) { float tempX = out.x() * cosAngle - out.y() * sinAngle; diff --git a/etk/math/Vector2D.h b/etk/math/Vector2D.h index f006c15..f25a3e4 100644 --- a/etk/math/Vector2D.h +++ b/etk/math/Vector2D.h @@ -242,7 +242,7 @@ namespace etk { * @brief Return the length of the vector */ float length() const { - #if __CPP_VERSION__ >= 2011 && !defined(__TARGET_OS__MacOs) && !defined(__TARGET_OS__IOs) + #if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__) return std::sqrt(length2()); #else return sqrt(length2()); diff --git a/etk/math/Vector3D.h b/etk/math/Vector3D.h index 539a0ed..9fab434 100644 --- a/etk/math/Vector3D.h +++ b/etk/math/Vector3D.h @@ -155,14 +155,10 @@ namespace etk { * @brief Return the length of the vector */ btScalar length() const { - #ifdef ETK_BUILD_LINEARMATH - return btSqrt(length2()); + #if __CPP_VERSION__ >= 2011 && !defined(__STDCPP_LLVM__) + return std::sqrt(length2()); #else - #if __CPP_VERSION__ >= 2011 && !defined(__TARGET_OS__MacOs) && !defined(__TARGET_OS__IOs) - return std::sqrt(length2()); - #else - return sqrt(length2()); - #endif + return sqrt(length2()); #endif } diff --git a/etk/tool.cpp b/etk/tool.cpp index 267fde2..ea5a36f 100644 --- a/etk/tool.cpp +++ b/etk/tool.cpp @@ -14,13 +14,11 @@ #include #include -double etk::tool::frand(double _a, double _b) -{ +double etk::tool::frand(double _a, double _b) { return (float)(( (double)rand()/(double)RAND_MAX ) * ((double)_b-(double)_a) + (double)_a); } -int32_t etk::tool::irand(int32_t _a, int32_t _b) -{ +int32_t etk::tool::irand(int32_t _a, int32_t _b) { return (int32_t)(( rand()/(double)RAND_MAX ) * ((double)_b-(double)_a) + (double)_a); } diff --git a/lutin_etk.py b/lutin_etk.py index d8eb90c..f098c6b 100644 --- a/lutin_etk.py +++ b/lutin_etk.py @@ -88,8 +88,10 @@ def create(target, module_name): elif target.name != "Windows": my_module.add_export_flag('link', [ '-ldl']) - + # build in C++ mode my_module.compile_version("c++", 2011) + # ad dependency of the generic C++ library: + my_module.add_module_depend('cxx') my_module.add_optionnal_module_depend('minizip', ["c++", "-DETK_BUILD_MINIZIP"]) my_module.add_optionnal_module_depend('linearmath', ["c", "-DETK_BUILD_LINEARMATH"], export=True)