Add pico sdk define

This commit is contained in:
2025-10-18 08:53:47 +03:00
parent 6c3c763934
commit 4885623492
5 changed files with 41 additions and 29 deletions

View File

@@ -221,11 +221,18 @@ if (TESTS)
add_subdirectory(tests)
endif()
if(PIP_FREERTOS)
add_definitions(-DPIP_FREERTOS)
if(PIP_MICRO)
add_definitions(-DMICRO_PIP)
set(ICU OFF)
set(LOCAL ON)
endif()
if(PIP_FREERTOS)
add_definitions(-DPIP_FREERTOS)
endif()
if(DEFINED PICO_BOARD)
add_definitions(-DPICO_SDK)
message(STATUS "Building PIP for Pi Pico SDK ${PICO_SDK_VERSION_STRING}")
endif()
# Check Bessel functions
set(CMAKE_REQUIRED_INCLUDES math.h)
@@ -329,7 +336,7 @@ if ((NOT DEFINED SHSTKPROJECT) AND (DEFINED ANDROID_PLATFORM))
#message("${ANDROID_NDK}/sysroot/usr/include")
endif()
if(NOT PIP_FREERTOS)
if(NOT PIP_MICRO)
if(WIN32)
if(${C_COMPILER} STREQUAL "cl.exe")
else()
@@ -350,7 +357,7 @@ if(NOT PIP_FREERTOS)
endif()
endif()
set(PIP_LIBS)
if(PIP_FREERTOS)
if(PIP_MICRO)
set(PIP_LIBS ${LIBS_MAIN})
else()
foreach(LIB_ ${LIBS_MAIN})
@@ -364,11 +371,11 @@ if(WIN32)
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
endif()
endif()
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
if(DEFINED ENV{QNX_HOST} OR PIP_MICRO)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
endif()
set(PCRE2_BUILD_PCRE2_8 OFF)
set(PCRE2_BUILD_PCRE2_16 ON )
@@ -406,7 +413,7 @@ endif()
if (NOT CROSSTOOLS)
if (NOT PIP_FREERTOS)
if (NOT PIP_MICRO)
if (PIP_BUILD_CONSOLE)
pip_module(console "" "PIP console support" "" "" "")
@@ -624,7 +631,7 @@ string(REPLACE ";" "," PIP_EXPORTS_STR "${PIP_EXPORTS}")
target_compile_definitions(pip PRIVATE "PICODE_DEFINES=\"${PIP_EXPORTS_STR}\"")
if(NOT PIP_FREERTOS)
if(NOT PIP_MICRO)
# Auxiliary
if (NOT CROSSTOOLS)
@@ -701,7 +708,7 @@ if(NOT LOCAL)
install(TARGETS ${PIP_MODULES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()
else()
if(NOT PIP_FREERTOS)
if(NOT PIP_MICRO)
if(WIN32)
install(TARGETS ${PIP_MODULES} RUNTIME DESTINATION bin)
install(TARGETS ${PIP_MODULES} ARCHIVE DESTINATION lib)
@@ -729,7 +736,7 @@ endif()
#
# Build Documentation
#
if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
if ((NOT PIP_MICRO) AND (NOT CROSSTOOLS))
include(PIPDocumentation)
find_package(Doxygen)
if(DOXYGEN_FOUND)
@@ -798,7 +805,7 @@ message(" Type : ${CMAKE_BUILD_TYPE}")
if (NOT LOCAL)
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
else()
if(NOT PIP_FREERTOS)
if(NOT PIP_MICRO)
message(" Install: local \"bin\", \"lib\" and \"include\"")
endif()
endif()
@@ -831,7 +838,7 @@ message(" Utilites:")
foreach(_util ${PIP_UTILS_LIST})
message(" * ${_util}")
endforeach()
if(NOT PIP_FREERTOS)
if(NOT PIP_MICRO)
message("")
message(" Using libraries:")
foreach(LIB_ ${LIBS_STATUS})

View File

@@ -71,7 +71,7 @@ if (NOT BUILDING_PIP)
find_library(PTHREAD_LIBRARY pthread)
find_library(UTIL_LIBRARY util)
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT PIP_FREERTOS))
if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT PIP_MICRO))
find_library(RT_LIBRARY rt)
list(APPEND _PIP_ADD_LIBS_ ${RT_LIBRARY})
endif()

View File

@@ -17,6 +17,7 @@ list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/thread")
set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spi_flash libsodium)
register_component()
set(PIP_FREERTOS ON)
set(PIP_MICRO ON)
set(LIB OFF)
set(INCLUDE_DIRS ${IDF_INCLUDE_DIRECTORIES})
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/newlib/platform_include)

View File

@@ -113,7 +113,7 @@ bool PISystemMonitor::startOnProcess(int pID, PISystemTime interval) {
}
# endif
# else
PRIVATE->hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pID_);
PRIVATE->hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pID_);
if (PRIVATE->hProc == 0) {
piCoutObj << "Can`t open process with ID = %1, %2!"_tr("PISystemMonitor").arg(pID_).arg(errorString());
return false;
@@ -178,6 +178,9 @@ PISystemTime uint64toST(uint64_t v) {
void PISystemMonitor::run() {
cur_tm.clear();
tbid.clear();
ProcessStats tstat;
tstat.ID = pID_;
#ifndef PIP_NO_THREADS
__PIThreadCollection * pitc = __PIThreadCollection::instance();
pitc->lock();
PIVector<PIThread *> tv = pitc->threads();
@@ -185,16 +188,14 @@ void PISystemMonitor::run() {
if (t->isPIObject()) tbid[t->tid()] = t->name();
pitc->unlock();
// piCout << tbid.keys().toType<uint>();
ProcessStats tstat;
tstat.ID = pID_;
#ifdef MICRO_PIP
# ifdef FREERTOS
for (auto * t: tv)
if (t->isPIObject()) gatherThread(t->tid());
#else
# ifndef WINDOWS
# else // FREERTOS
# ifndef WINDOWS
double delay_ms = delay_.toMilliseconds();
tbid[pID_] = "main";
# ifdef MAC_OS
# ifdef MAC_OS
rusage_info_current ru;
proc_pid_rusage(pID_, RUSAGE_INFO_CURRENT, (rusage_info_t *)&ru);
// piCout << PISystemTime(((uint*)&(ru.ri_user_time))[1], ((uint*)&(ru.ri_user_time))[0]);
@@ -210,7 +211,7 @@ void PISystemMonitor::run() {
tstat.cpu_load_user = 100.f * (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
cycle = 0;
// piCout << (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
# else
# else // MAC_OS
PRIVATE->file.seekToBegin();
PIString str = PIString::fromAscii(PRIVATE->file.readAll());
int si = str.find('(') + 1, fi = 0, cc = 1;
@@ -264,8 +265,8 @@ void PISystemMonitor::run() {
if (i.flags[PIFile::FileInfo::Dot] || i.flags[PIFile::FileInfo::DotDot]) continue;
gatherThread(i.name().toInt());
}
# endif
# else
# endif // MAC_OS
# else // WINDOWS
if (GetProcessMemoryInfo(PRIVATE->hProc, &PRIVATE->mem_cnt, sizeof(PRIVATE->mem_cnt)) != 0) {
tstat.physical_memsize = PRIVATE->mem_cnt.WorkingSetSize;
}
@@ -315,8 +316,9 @@ void PISystemMonitor::run() {
tstat.cpu_load_user = 0.f;
}
PRIVATE->tm.reset();
# endif
#endif
# endif // WINDOWS
# endif // FREERTOS
#endif // PIP_NO_THREADS
tstat.cpu_load_system = piClampf(tstat.cpu_load_system, 0.f, 100.f);
tstat.cpu_load_user = piClampf(tstat.cpu_load_user, 0.f, 100.f);
@@ -352,7 +354,7 @@ void PISystemMonitor::gatherThread(llong id) {
#ifdef MICRO_PIP
ts.name = tbid.value(id, "<PIThread>");
#else
ts.name = tbid.value(id, "<non-PIThread>");
ts.name = tbid.value(id, "<non-PIThread>");
# ifndef WINDOWS
PIFile f(PRIVATE->proc_dir + "task/" + PIString::fromNumber(id) + "/stat");
// piCout << f.path();

View File

@@ -51,8 +51,10 @@
#ifdef PIP_FREERTOS
# define FREERTOS
#endif
#if defined(FREERTOS) || defined(PLATFORMIO)
# define MICRO_PIP
#ifdef MICRO_PIP
# ifndef FREERTOS
# define PIP_NO_THREADS
# endif
#endif
#ifndef WINDOWS
# ifndef QNX