refactor: migrate MICRO_PIP to fine-grained feature flags
Replace monolithic MICRO_PIP/PIP_MICRO with granular flags: Feature flags (CMake options + platform auto-detection): - PIP_NO_FILESYSTEM, PIP_NO_THREADS, PIP_NO_SOCKET - PIP_NO_PROCESS, PIP_NO_DYNLIB, PIP_NO_FFT, PIP_NO_SERIAL Embedded optimization flag: - PIP_EMBEDDED (auto-set for Pico SDK and FreeRTOS) Controls buffer sizes, time stubs, terminal fallback, init stubs Platform blocks in CMakeLists.txt: - Pico SDK: auto-disables FS, PROCESS, DYNLIB, FFT, SERIAL; conditionally disables THREADS (no FreeRTOS) and SOCKET (no LWIP) - FreeRTOS: auto-disables FS, PROCESS, DYNLIB, FFT, SERIAL; conditionally disables SOCKET (no LWIP) - Android: auto-disables PROCESS, DYNLIB, FFT Updated 96 files across libs/, utils/, tests/, and CMakeLists.txt. Builds verified for Linux (547 tests pass) and Pico SDK (100%). Removed all MICRO_PIP and PIP_MICRO references (0 remaining).
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
# include <mach/clock.h>
|
||||
// # include <crt_externs.h>
|
||||
#endif
|
||||
#ifdef MICRO_PIP
|
||||
#ifdef PIP_EMBEDDED
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Network address
|
||||
Network address
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "pinetworkaddress.h"
|
||||
|
||||
// clang-format off
|
||||
#ifndef PIP_NO_SOCKET
|
||||
#ifdef QNX
|
||||
# include <netdb.h>
|
||||
#else
|
||||
@@ -33,6 +34,7 @@
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#endif // PIP_NO_SOCKET
|
||||
// clang-format on
|
||||
|
||||
|
||||
@@ -145,11 +147,17 @@ PINetworkAddress PINetworkAddress::resolve(const PIString & host_port) {
|
||||
|
||||
|
||||
PINetworkAddress PINetworkAddress::resolve(const PIString & host, ushort port) {
|
||||
#ifndef PIP_NO_SOCKET
|
||||
PINetworkAddress ret(0, port);
|
||||
hostent * he = gethostbyname(host.dataAscii());
|
||||
if (!he) return ret;
|
||||
if (he->h_addr_list[0]) ret.setIP(*((uint *)(he->h_addr_list[0])));
|
||||
return ret;
|
||||
#else
|
||||
(void)host;
|
||||
(void)port;
|
||||
return PINetworkAddress();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -162,5 +170,9 @@ void PINetworkAddress::splitIPPort(const PIString & ipp, PIString * _ip, int * _
|
||||
|
||||
|
||||
void PINetworkAddress::initIP(const PIString & _ip) {
|
||||
#ifndef PIP_NO_SOCKET
|
||||
ip_ = inet_addr(_ip.dataAscii());
|
||||
#else
|
||||
(void)_ip;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#ifdef QNX
|
||||
# include <time.h>
|
||||
#endif
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_EMBEDDED
|
||||
# include "pisystemtests.h"
|
||||
#elif defined(ARDUINO)
|
||||
# include <Arduino.h>
|
||||
@@ -49,7 +49,7 @@ long long __PIQueryPerformanceCounter() {
|
||||
// # include <crt_externs.h>
|
||||
extern clock_serv_t __pi_mac_clock;
|
||||
#endif
|
||||
#ifdef MICRO_PIP
|
||||
#ifdef PIP_EMBEDDED
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
@@ -246,7 +246,7 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) {
|
||||
#elif defined(MAC_OS)
|
||||
mach_timespec_t t_cur;
|
||||
clock_get_time(__pi_mac_clock, &t_cur);
|
||||
#elif defined(MICRO_PIP)
|
||||
#elif defined(PIP_EMBEDDED)
|
||||
timespec t_cur;
|
||||
# ifdef ARDUINO
|
||||
static const uint32_t offSetSinceEpoch_s = 1581897605UL;
|
||||
@@ -278,7 +278,7 @@ PITimeMeasurer::PITimeMeasurer() {
|
||||
|
||||
double PITimeMeasurer::elapsed_n() const {
|
||||
return (PISystemTime::current(true) - t_st).toNanoseconds()
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_EMBEDDED
|
||||
- PISystemTests::time_elapsed_ns
|
||||
#endif
|
||||
;
|
||||
@@ -287,7 +287,7 @@ double PITimeMeasurer::elapsed_n() const {
|
||||
|
||||
double PITimeMeasurer::elapsed_u() const {
|
||||
return (PISystemTime::current(true) - t_st).toMicroseconds()
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_EMBEDDED
|
||||
- PISystemTests::time_elapsed_ns / 1.E+3
|
||||
#endif
|
||||
;
|
||||
@@ -296,7 +296,7 @@ double PITimeMeasurer::elapsed_u() const {
|
||||
|
||||
double PITimeMeasurer::elapsed_m() const {
|
||||
return (PISystemTime::current(true) - t_st).toMilliseconds()
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_EMBEDDED
|
||||
- PISystemTests::time_elapsed_ns / 1.E+6
|
||||
#endif
|
||||
;
|
||||
@@ -305,7 +305,7 @@ double PITimeMeasurer::elapsed_m() const {
|
||||
|
||||
double PITimeMeasurer::elapsed_s() const {
|
||||
return (PISystemTime::current(true) - t_st).toSeconds()
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_EMBEDDED
|
||||
- PISystemTests::time_elapsed_ns / 1.E+9
|
||||
#endif
|
||||
;
|
||||
|
||||
@@ -22,16 +22,16 @@
|
||||
#ifdef QNX
|
||||
# include <time.h>
|
||||
#endif
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_EMBEDDED
|
||||
# include "pisystemtests.h"
|
||||
#elif defined(ARDUINO)
|
||||
# include <Arduino.h>
|
||||
#elif defined(PICO_SDK)
|
||||
# include "hardware/time.h"
|
||||
#endif
|
||||
#ifdef MICRO_PIP
|
||||
#else
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#ifdef PICO_SDK
|
||||
extern "C" void sleep_us(unsigned int);
|
||||
#endif
|
||||
|
||||
|
||||
//! \details
|
||||
@@ -56,7 +56,9 @@ void piUSleep(int usecs) {
|
||||
#elif defined(PICO_SDK)
|
||||
sleep_us(usecs);
|
||||
#else
|
||||
# ifndef PIP_NO_THREADS
|
||||
usecs -= PISystemTests::usleep_offset_us;
|
||||
# endif
|
||||
if (usecs > 0) usleep(usecs);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
#include "pistring.h"
|
||||
|
||||
#include <typeinfo>
|
||||
#ifdef MICRO_PIP
|
||||
#if !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
||||
# include "pivariant.h"
|
||||
#endif
|
||||
#endif // !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
||||
|
||||
|
||||
class __VariantFunctionsBase__ {
|
||||
@@ -52,21 +52,21 @@ public:
|
||||
static __VariantFunctions__<T> ret;
|
||||
return &ret;
|
||||
}
|
||||
#ifdef MICRO_PIP
|
||||
#if !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
||||
PIString typeName() const final {
|
||||
static PIString ret(PIVariant::fromValue<T>(T()).typeName());
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
PIString typeName() const final {
|
||||
#if defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
# if defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
static PIString ret(typeid(T).name());
|
||||
#else
|
||||
# else
|
||||
static PIString ret("unknown");
|
||||
#endif
|
||||
# endif
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#endif // !defined(__GXX_RTTI__) && !defined(__RTTI__)
|
||||
uint hash() const final {
|
||||
static uint ret = typeName().hash();
|
||||
return ret;
|
||||
@@ -182,27 +182,27 @@ private:
|
||||
//! \~\brief
|
||||
//! \~english Registers a readable type name for %PIVariantSimple.
|
||||
//! \~russian Регистрирует читаемое имя типа для %PIVariantSimple.
|
||||
#define REGISTER_PIVARIANTSIMPLE(Type) \
|
||||
template<> \
|
||||
class __VariantFunctions__<Type>: public __VariantFunctionsBase__ { \
|
||||
public: \
|
||||
__VariantFunctionsBase__ * instance() final { \
|
||||
static __VariantFunctions__<Type> ret; \
|
||||
return &ret; \
|
||||
} \
|
||||
PIString typeName() const final { \
|
||||
static PIString ret(#Type); \
|
||||
return ret; \
|
||||
} \
|
||||
uint hash() const final { \
|
||||
static uint ret = typeName().hash(); \
|
||||
return ret; \
|
||||
} \
|
||||
void newT(void *& ptr, const void * value) final { ptr = (void *)(new Type(*(const Type *)value)); } \
|
||||
void newNullT(void *& ptr) final { ptr = (void *)(new Type()); } \
|
||||
void assignT(void *& ptr, const void * value) final { *(Type *)ptr = *(const Type *)value; } \
|
||||
void deleteT(void *& ptr) final { delete (Type *)(ptr); } \
|
||||
};
|
||||
#define REGISTER_PIVARIANTSIMPLE(Type) \
|
||||
template<> \
|
||||
class __VariantFunctions__<Type>: public __VariantFunctionsBase__ { \
|
||||
public: \
|
||||
__VariantFunctionsBase__ * instance() final { \
|
||||
static __VariantFunctions__<Type> ret; \
|
||||
return &ret; \
|
||||
} \
|
||||
PIString typeName() const final { \
|
||||
static PIString ret(#Type); \
|
||||
return ret; \
|
||||
} \
|
||||
uint hash() const final { \
|
||||
static uint ret = typeName().hash(); \
|
||||
return ret; \
|
||||
} \
|
||||
void newT(void *& ptr, const void * value) final { ptr = (void *)(new Type(*(const Type *)value)); } \
|
||||
void newNullT(void *& ptr) final { ptr = (void *)(new Type()); } \
|
||||
void assignT(void *& ptr, const void * value) final { *(Type *)ptr = *(const Type *)value; } \
|
||||
void deleteT(void *& ptr) final { delete (Type *)(ptr); } \
|
||||
};
|
||||
|
||||
REGISTER_PIVARIANTSIMPLE(std::function<void(void *)>)
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
|
||||
#include "colors_p.h"
|
||||
#include "pipropertystorage.h"
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_NO_FILESYSTEM
|
||||
# include "piiodevice.h"
|
||||
#endif
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
|
||||
|
||||
int PIVariantTypes::Enum::selectedValue() const {
|
||||
@@ -84,11 +84,11 @@ PIStringList PIVariantTypes::Enum::names() const {
|
||||
|
||||
|
||||
PIVariantTypes::IODevice::IODevice() {
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_NO_FILESYSTEM
|
||||
mode = PIIODevice::ReadWrite;
|
||||
#else
|
||||
mode = 0; // TODO: PIIODevice for MICRO PIP
|
||||
#endif // MICRO_PIP
|
||||
mode = 0; // TODO: PIIODevice for PIP_NO_FILESYSTEM
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
options = 0;
|
||||
}
|
||||
|
||||
@@ -121,12 +121,12 @@ PIString PIVariantTypes::IODevice::toPICout() const {
|
||||
}
|
||||
if (rwc == 1) s += "o";
|
||||
s += ", flags=";
|
||||
#ifndef MICRO_PIP // TODO: PIIODevice for MICRO PIP
|
||||
#ifndef PIP_NO_FILESYSTEM // TODO: PIIODevice for PIP_NO_FILESYSTEM
|
||||
if (options != 0) {
|
||||
if (((PIIODevice::DeviceOptions)options)[PIIODevice::BlockingRead]) s += " br";
|
||||
if (((PIIODevice::DeviceOptions)options)[PIIODevice::BlockingWrite]) s += " bw";
|
||||
}
|
||||
#endif // MICRO_PIP
|
||||
#endif // PIP_NO_FILESYSTEM
|
||||
PIPropertyStorage ps = get();
|
||||
for (const auto & p: ps) {
|
||||
s += ", " + p.name + "=\"" + p.value.toString() + "\"";
|
||||
|
||||
Reference in New Issue
Block a user