From 0504fa187e3d6b24b73c55cbc66bd97bd6e8d7e4 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 14 Jan 2022 14:37:51 +0300 Subject: [PATCH] define PIP_MICRO detect AVR_GCC add library.json --- include_pip.py | 3 +++ library.json | 29 +++++++++++++++++++++++++++++ libs/main/containers/picontainers.h | 10 ++++++---- libs/main/core/pibase.h | 18 ++++++++++-------- libs/main/core/piincludes.h | 5 +++-- libs/main/piplatform.h | 4 ++++ 6 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 include_pip.py create mode 100644 library.json diff --git a/include_pip.py b/include_pip.py new file mode 100644 index 00000000..c9fb712d --- /dev/null +++ b/include_pip.py @@ -0,0 +1,3 @@ +Import("env") + +env.Append(CCFLAGS=["-Ilib/pip/libs/main/core", "-Ilib/pip/libs/main/containers", "-Ilib/pip/libs/main/introspection"]) diff --git a/library.json b/library.json new file mode 100644 index 00000000..c5cd63bf --- /dev/null +++ b/library.json @@ -0,0 +1,29 @@ +{ + "name": "PIP", + "version": "2.33.0", + "keywords": "pip", + "description": "Platform-Independent Primitives", + "repository": + { + "type": "git", + "url": "https://git.shs.tools/SHS/pip.git" + }, + "frameworks": "*", + "platforms": "*", + "dependencies": {"mike-matera/ArduinoSTL": "^1.3.2"}, + "build": + { + "srcDir": "libs/main", + "srcFilter": [ + "+", + "+", + "+", + "+" + ], + "flags": [ + "-std=c++11", + "-DPIP_MICRO" + ], + "extraScript": "include_pip.py" + } +} \ No newline at end of file diff --git a/libs/main/containers/picontainers.h b/libs/main/containers/picontainers.h index b14fce98..5c67211b 100644 --- a/libs/main/containers/picontainers.h +++ b/libs/main/containers/picontainers.h @@ -28,10 +28,12 @@ #include "picout.h" #include "piintrospection_containers.h" -#ifdef MAC_OS -# include -#else -# include +#ifndef PIP_MICRO +# ifdef MAC_OS +# include +# else +# include +# endif #endif #include #include diff --git a/libs/main/core/pibase.h b/libs/main/core/pibase.h index de83702b..bc26962e 100644 --- a/libs/main/core/pibase.h +++ b/libs/main/core/pibase.h @@ -31,8 +31,6 @@ #include "pip_export.h" #include "pip_defs.h" #include "string.h" -#include - //! Meta-information section for any entity. //! Parsing by \a pip_cmg and can be accessed by \a PICodeInfo. //! Contains sequence of key=value pairs, e.g. @@ -119,9 +117,14 @@ #endif //DOXYGEN +#ifdef CC_AVR_GCC +# include +#endif #include - #include +#include +#include + #ifdef WINDOWS # ifdef CC_VC # define SHUT_RDWR 2 @@ -162,7 +165,6 @@ #ifdef NDEBUG # undef NDEBUG #endif -#include #ifndef assert # define assert(x) # define assertm(exp, msg) @@ -364,7 +366,7 @@ inline bool piCompareBinary(const void * f, const void * s, size_t size) { */ template inline bool piCompare(const T & a, const T & b, const T & epsilon = std::numeric_limits::epsilon()) { - return std::abs(a - b) <= epsilon; + return piAbs(a - b) <= epsilon; } /*! @brief Templated function return round of float falue @@ -499,13 +501,13 @@ template inline void piLetobe(T * v) {piLetobe(v, sizeof(T));} template inline T piLetobe(const T & v) {T tv(v); piLetobe(&tv, sizeof(T)); return tv;} // specialization -template<> inline ushort piLetobe(const ushort & v) {return (v << 8) | (v >> 8);} -template<> inline uint piLetobe(const uint & v) {return (v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | ((v << 24) & 0xFF000000);} +template<> inline uint16_t piLetobe(const uint16_t & v) {return (v << 8) | (v >> 8);} +template<> inline uint32_t piLetobe(const uint32_t & v) {return (v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | ((v << 24) & 0xFF000000);} template<> inline float piLetobe(const float & v) { union _pletobe_f { _pletobe_f(const float &f_) {f = f_;} float f; - uint v; + uint32_t v; }; _pletobe_f a(v); a.v = (a.v >> 24) | ((a.v >> 8) & 0xFF00) | ((a.v << 8) & 0xFF0000) | ((a.v << 24) & 0xFF000000); diff --git a/libs/main/core/piincludes.h b/libs/main/core/piincludes.h index af46c13b..c9b44e2a 100644 --- a/libs/main/core/piincludes.h +++ b/libs/main/core/piincludes.h @@ -26,8 +26,9 @@ #ifdef PIP_STD_IOSTREAM # include #endif -#include - +#ifndef PIP_MICRO +# include +#endif class PIMutex; class PIMutexLocker; diff --git a/libs/main/piplatform.h b/libs/main/piplatform.h index cb46423d..0c86dd68 100644 --- a/libs/main/piplatform.h +++ b/libs/main/piplatform.h @@ -84,6 +84,10 @@ # define CC_OTHER #endif +#ifdef __AVR__ +# define CC_AVR_GCC +#endif + #ifdef WINDOWS # ifdef CC_GCC # define typeof __typeof