diff --git a/AGENTS.md b/AGENTS.md index ec068fb8..c06ee9c6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,28 +5,28 @@ ### Basic Build ```bash # Configure with CMake (release build) -cmake -B build +cmake -B build -j16 # Build the project -cmake --build build +cmake --build build -j16 # Install (default system location) -cmake --build build --target install +cmake --build build --target install -j16 # Local install (bin/lib/include in build directory) -cmake -B build -DLOCAL=ON +cmake -B build -DLOCAL=ON -j16 ``` ### With Tests ```bash -cmake -B build -DTESTS=ON -cmake --build build +cmake -B build -DTESTS=ON -j16 +cmake --build build -j16 cd build && ctest ``` ### Build Only ```bash -cmake --build build +cmake --build build -j16 ``` ### Run Single Test @@ -162,4 +162,4 @@ libs/ - Project uses custom CMake macros from `cmake/` directory - Version format: `MAJOR.MINOR.REVISION` (e.g., 5.6.0) - All files have LGPL license header -- Support for multiple platforms: Windows, Linux, QNX, Android, Apple \ No newline at end of file +- Support for multiple platforms: Windows, Linux, QNX, Android, Apple diff --git a/CMakeLists.txt b/CMakeLists.txt index cc063fd0..35e6f0d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,8 @@ option(STD_IOSTREAM "Building with std iostream operators support" OFF) option(INTROSPECTION "Build with introspection" OFF) option(TESTS "Build tests and perform their before install step" OFF) option(COVERAGE "Build project with coverage info" OFF) +option(PIP_NO_FILESYSTEM "Disable filesystem support" OFF) +option(PIP_NO_THREADS "Disable threading support" OFF) option(PIP_FFTW_F "Support fftw module for float" ON) option(PIP_FFTW_L "Support fftw module for long double" ON) option(PIP_FFTW_Q "Support fftw module for quad double" OFF) @@ -231,9 +233,17 @@ if(PIP_FREERTOS) endif() if(DEFINED PICO_BOARD) add_definitions(-DPICO_SDK) + set(PIP_NO_FILESYSTEM ON CACHE BOOL "" FORCE) message(STATUS "Building PIP for Pi Pico SDK ${PICO_SDK_VERSION_STRING}") endif() +if(PIP_NO_FILESYSTEM) + add_definitions(-DPIP_NO_FILESYSTEM) +endif() +if(PIP_NO_THREADS) + add_definitions(-DPIP_NO_THREADS) +endif() + # Check Bessel functions set(CMAKE_REQUIRED_INCLUDES math.h) set(CMAKE_REQUIRED_LIBRARIES m) diff --git a/libs/main/core/piinit.h b/libs/main/core/piinit.h index d01eac26..3fa25ef7 100644 --- a/libs/main/core/piinit.h +++ b/libs/main/core/piinit.h @@ -35,6 +35,7 @@ class PIFile; class PIStringList; +class PIInit; class PIP_EXPORT __PIInit_Initializer__ { diff --git a/libs/main/io_devices/pidir.cpp b/libs/main/io_devices/pidir.cpp index bb0607b4..0239624a 100644 --- a/libs/main/io_devices/pidir.cpp +++ b/libs/main/io_devices/pidir.cpp @@ -16,6 +16,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ +#ifndef PIP_NO_FILESYSTEM #include "pidir.h" #include "piincludes_p.h" @@ -610,3 +611,4 @@ void PIDir::CurrentDirOverrider::save(const PIFile::FileInfo & info) { else PIDir::setCurrent(PIDir::current().path() + PIDir::separator + p); } +#endif // PIP_NO_FILESYSTEM diff --git a/libs/main/io_devices/pidir.h b/libs/main/io_devices/pidir.h index f97efdf8..c71a6199 100644 --- a/libs/main/io_devices/pidir.h +++ b/libs/main/io_devices/pidir.h @@ -30,6 +30,7 @@ #include "piregularexpression.h" +#ifndef PIP_NO_FILESYSTEM //! \ingroup IO //! \~\brief //! \~english Local directory. @@ -217,8 +218,10 @@ private: PIString path_, scan_; }; +#endif // PIP_NO_FILESYSTEM +#ifndef PIP_NO_FILESYSTEM inline bool operator<(const PIFile::FileInfo & v0, const PIFile::FileInfo & v1) { return (v0.path < v1.path); } @@ -242,6 +245,7 @@ inline PICout operator<<(PICout s, const PIDir & v) { s.restoreControls(); return s; } +#endif // PIP_NO_FILESYSTEM #endif // PIDIR_H diff --git a/libs/main/io_devices/pifile.cpp b/libs/main/io_devices/pifile.cpp index 9bc1b073..2bd86ef3 100644 --- a/libs/main/io_devices/pifile.cpp +++ b/libs/main/io_devices/pifile.cpp @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#ifndef PIP_NO_FILESYSTEM #include "pifile.h" #include "pidir.h" @@ -635,3 +636,4 @@ int PIFile::writeAll(const PIString & path, const PIByteArray & data) { f.clear(); return f.write(data.data(), data.size_s()); } +#endif // PIP_NO_FILESYSTEM diff --git a/libs/main/io_devices/pifile.h b/libs/main/io_devices/pifile.h index f33ff682..44cb9859 100644 --- a/libs/main/io_devices/pifile.h +++ b/libs/main/io_devices/pifile.h @@ -30,6 +30,7 @@ #include "pipropertystorage.h" +#ifndef PIP_NO_FILESYSTEM //! \ingroup IO //! \~\brief //! \~english Local file. @@ -345,8 +346,10 @@ private: llong _size = -1; PIString prec_str; }; +#endif // PIP_NO_FILESYSTEM +#ifndef PIP_NO_FILESYSTEM //! \relatesalso PICout //! \~english Output operator to \a PICout //! \~russian Оператор вывода в \a PICout @@ -377,5 +380,6 @@ BINARY_STREAM_READ(PIFile::FileInfo) { v.perm_group.raw >> v.perm_other.raw; return s; } +#endif // PIP_NO_FILESYSTEM #endif // PIFILE_H diff --git a/libs/main/piplatform.h b/libs/main/piplatform.h index ec9ed6c8..e35ad80b 100644 --- a/libs/main/piplatform.h +++ b/libs/main/piplatform.h @@ -56,7 +56,7 @@ # define PIP_NO_THREADS # endif # ifndef LWIP -# define PIP_NO_SOCKET +# define PIP_NO_SOCKET # endif # define PISERIAL_NO_PINS #endif diff --git a/libs/main/thread/piconditionvar.cpp b/libs/main/thread/piconditionvar.cpp index 0c6412c4..0df181e9 100644 --- a/libs/main/thread/piconditionvar.cpp +++ b/libs/main/thread/piconditionvar.cpp @@ -23,6 +23,7 @@ # define _WIN32_WINNT 0x0600 #endif +#ifndef PIP_NO_THREADS #include "piconditionvar.h" #include "piincludes_p.h" #ifdef WINDOWS @@ -179,3 +180,4 @@ void PIConditionVariable::notifyAll() { pthread_cond_broadcast(&PRIVATE->nativeHandle); #endif } +#endif // PIP_NO_THREADS diff --git a/libs/main/thread/piconditionvar.h b/libs/main/thread/piconditionvar.h index ee11ac78..d07a7ac3 100644 --- a/libs/main/thread/piconditionvar.h +++ b/libs/main/thread/piconditionvar.h @@ -30,6 +30,7 @@ #include "pisystemtime.h" +#ifndef PIP_NO_THREADS /** * \brief A condition variable is an object able to block the calling thread until notified to resume. * @@ -121,5 +122,5 @@ private: PRIVATE_DECLARATION(PIP_EXPORT) }; - +#endif // PIP_NO_THREADS #endif // PICONDITIONVAR_H diff --git a/libs/main/thread/pimutex.cpp b/libs/main/thread/pimutex.cpp index a432e6a4..78a8dc15 100644 --- a/libs/main/thread/pimutex.cpp +++ b/libs/main/thread/pimutex.cpp @@ -107,6 +107,7 @@ //! \} +#ifndef PIP_NO_THREADS #include "pimutex.h" #include "piincludes_p.h" @@ -228,3 +229,4 @@ void PIMutex::destroy() { pthread_mutex_destroy(&(PRIVATE->mutex)); #endif } +#endif // PIP_NO_THREADS diff --git a/libs/main/thread/pimutex.h b/libs/main/thread/pimutex.h index c8315fdf..b4b6e40c 100644 --- a/libs/main/thread/pimutex.h +++ b/libs/main/thread/pimutex.h @@ -29,6 +29,7 @@ #include "piinit.h" +#ifndef PIP_NO_THREADS class PIP_EXPORT PIMutex { public: NO_COPY_CLASS(PIMutex); @@ -85,5 +86,5 @@ private: bool cond; }; - +#endif // PIP_NO_THREADS #endif // PIMUTEX_H diff --git a/libs/main/thread/pithread.cpp b/libs/main/thread/pithread.cpp index 4e03b73a..2d5e6bad 100644 --- a/libs/main/thread/pithread.cpp +++ b/libs/main/thread/pithread.cpp @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#ifndef PIP_NO_THREADS #include "pithread.h" #include "piincludes_p.h" @@ -1086,3 +1087,4 @@ bool PIThread::_waitForFinish(PISystemTime max_tm) { #endif return false; } +#endif // PIP_NO_THREADS diff --git a/libs/main/thread/pithread.h b/libs/main/thread/pithread.h index af97009e..42d04c89 100644 --- a/libs/main/thread/pithread.h +++ b/libs/main/thread/pithread.h @@ -33,6 +33,7 @@ class PIThread; +#ifndef PIP_NO_THREADS #ifndef MICRO_PIP class PIIntrospectionThreads; @@ -304,5 +305,5 @@ private: void setThreadName(); }; - +#endif // PIP_NO_THREADS #endif // PITHREAD_H diff --git a/libs/main/thread/pitimer.cpp b/libs/main/thread/pitimer.cpp index 84a72e6f..a50ec43d 100644 --- a/libs/main/thread/pitimer.cpp +++ b/libs/main/thread/pitimer.cpp @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#ifndef PIP_NO_THREADS #include "pitimer.h" #include "piconditionvar.h" @@ -302,3 +303,4 @@ void PITimer::stop() { thread->stop(); event.notifyAll(); } +#endif // PIP_NO_THREADS diff --git a/libs/main/thread/pitimer.h b/libs/main/thread/pitimer.h index 1f40ac4c..e9f931cf 100644 --- a/libs/main/thread/pitimer.h +++ b/libs/main/thread/pitimer.h @@ -33,6 +33,7 @@ class PIThread; +#ifndef PIP_NO_THREADS class PIP_EXPORT PITimer: public PIObject { PIOBJECT_SUBCLASS(PITimer, PIObject); @@ -209,5 +210,5 @@ protected: PIConditionVariable event; }; - +#endif // PIP_NO_THREADS #endif // PITIMER_H diff --git a/libs/main/types/pitime.cpp b/libs/main/types/pitime.cpp index 66a181e9..68f608ae 100644 --- a/libs/main/types/pitime.cpp +++ b/libs/main/types/pitime.cpp @@ -26,6 +26,8 @@ # include "pisystemtests.h" #elif defined(ARDUINO) # include +#elif defined(PICO_SDK) +# include "hardware/time.h" #endif #ifdef MICRO_PIP # include @@ -48,28 +50,13 @@ void piUSleep(int usecs) { if (usecs <= 0) return; #ifdef WINDOWS - // printf("Sleep %d\n", usecs / 1000); - if (usecs > 0) Sleep(usecs / 1000); - // printf("Sleep end"); -#else -# ifdef FREERTOS + Sleep(usecs / 1000); +#elif defined(FREERTOS) vTaskDelay(usecs / 1000 / portTICK_PERIOD_MS); -# else -# ifdef MICRO_PIP - if (usecs > 0) { - struct timeval start; - gettimeofday(&start, nullptr); - long long elapsed = 0; - while (elapsed < usecs) { - struct timeval now; - gettimeofday(&now, nullptr); - elapsed = (now.tv_sec - start.tv_sec) * 1000000LL + (now.tv_usec - start.tv_usec); - } - } -# else +#elif defined(PICO_SDK) + sleep_us(usecs); +#else usecs -= PISystemTests::usleep_offset_us; if (usecs > 0) usleep(usecs); -# endif -# endif #endif }