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:
+127
-103
@@ -3,6 +3,9 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||
if (POLICY CMP0177)
|
||||
cmake_policy(SET CMP0177 OLD)
|
||||
endif()
|
||||
if(DEFINED PICO_SDK_PATH)
|
||||
include(${PICO_SDK_PATH}/pico_sdk_init.cmake)
|
||||
endif()
|
||||
project(PIP)
|
||||
set(PIP_MAJOR 5)
|
||||
set(PIP_MINOR 8)
|
||||
@@ -72,6 +75,11 @@ option(TESTS_RUN "Run tests 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_NO_SOCKET "Disable socket/network support" OFF)
|
||||
option(PIP_NO_PROCESS "Disable process management" OFF)
|
||||
option(PIP_NO_DYNLIB "Disable dynamic library loading" OFF)
|
||||
option(PIP_NO_FFT "Disable FFT support" OFF)
|
||||
option(PIP_NO_SERIAL "Disable serial port 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)
|
||||
@@ -225,26 +233,64 @@ if (TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
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)
|
||||
add_definitions(-DPIP_EMBEDDED)
|
||||
set(PIP_NO_FILESYSTEM ON CACHE BOOL "" FORCE)
|
||||
if(NOT DEFINED PICO_FREERTOS)
|
||||
set(PIP_NO_THREADS ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
if(NOT DEFINED PICO_LWIP)
|
||||
set(PIP_NO_SOCKET ON CACHE BOOL "" FORCE)
|
||||
set(PIP_BUILD_MQTT_CLIENT OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
set(PIP_NO_PROCESS ON CACHE BOOL "" FORCE)
|
||||
set(PIP_NO_DYNLIB ON CACHE BOOL "" FORCE)
|
||||
set(PIP_NO_FFT ON CACHE BOOL "" FORCE)
|
||||
set(PIP_NO_SERIAL ON CACHE BOOL "" FORCE)
|
||||
message(STATUS "Building PIP for Pi Pico SDK ${PICO_SDK_VERSION_STRING}")
|
||||
endif()
|
||||
|
||||
if(PIP_FREERTOS)
|
||||
add_definitions(-DPIP_FREERTOS)
|
||||
add_definitions(-DPIP_EMBEDDED)
|
||||
set(PIP_NO_FILESYSTEM ON CACHE BOOL "" FORCE)
|
||||
if(NOT DEFINED LWIP)
|
||||
set(PIP_NO_SOCKET ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
set(PIP_NO_PROCESS ON CACHE BOOL "" FORCE)
|
||||
set(PIP_NO_DYNLIB ON CACHE BOOL "" FORCE)
|
||||
set(PIP_NO_FFT ON CACHE BOOL "" FORCE)
|
||||
set(PIP_NO_SERIAL ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
if(DEFINED ANDROID_PLATFORM)
|
||||
set(PIP_NO_PROCESS ON CACHE BOOL "" FORCE)
|
||||
set(PIP_NO_DYNLIB ON CACHE BOOL "" FORCE)
|
||||
set(PIP_NO_FFT ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
if(PIP_NO_FILESYSTEM)
|
||||
add_definitions(-DPIP_NO_FILESYSTEM)
|
||||
endif()
|
||||
if(PIP_NO_THREADS)
|
||||
add_definitions(-DPIP_NO_THREADS)
|
||||
endif()
|
||||
if(PIP_NO_SOCKET)
|
||||
add_definitions(-DPIP_NO_SOCKET)
|
||||
endif()
|
||||
if(PIP_NO_PROCESS)
|
||||
add_definitions(-DPIP_NO_PROCESS)
|
||||
endif()
|
||||
if(PIP_NO_DYNLIB)
|
||||
add_definitions(-DPIP_NO_DYNLIB)
|
||||
endif()
|
||||
if(PIP_NO_FFT)
|
||||
add_definitions(-DPIP_NO_FFT)
|
||||
endif()
|
||||
if(PIP_NO_SERIAL)
|
||||
add_definitions(-DPIP_NO_SERIAL)
|
||||
endif()
|
||||
|
||||
# Check Bessel functions
|
||||
set(CMAKE_REQUIRED_INCLUDES math.h)
|
||||
@@ -348,34 +394,28 @@ if ((NOT DEFINED SHSTKPROJECT) AND (DEFINED ANDROID_PLATFORM))
|
||||
#message("${ANDROID_NDK}/sysroot/usr/include")
|
||||
endif()
|
||||
|
||||
if(NOT PIP_MICRO)
|
||||
if(WIN32)
|
||||
if(${C_COMPILER} STREQUAL "cl.exe")
|
||||
else()
|
||||
list(APPEND LIBS_MAIN ws2_32 iphlpapi psapi cfgmgr32 setupapi hid)
|
||||
endif()
|
||||
if(WIN32)
|
||||
if(${C_COMPILER} STREQUAL "cl.exe")
|
||||
else()
|
||||
list(APPEND LIBS_MAIN dl)
|
||||
if(DEFINED ENV{QNX_HOST})
|
||||
list(APPEND LIBS_MAIN socket)
|
||||
else()
|
||||
if (NOT DEFINED ANDROID_PLATFORM)
|
||||
list(APPEND LIBS_MAIN pthread util)
|
||||
if (NOT APPLE)
|
||||
list(APPEND LIBS_MAIN rt)
|
||||
endif()
|
||||
list(APPEND LIBS_MAIN ws2_32 iphlpapi psapi cfgmgr32 setupapi hid)
|
||||
endif()
|
||||
else()
|
||||
list(APPEND LIBS_MAIN dl)
|
||||
if(DEFINED ENV{QNX_HOST})
|
||||
list(APPEND LIBS_MAIN socket)
|
||||
else()
|
||||
if (NOT DEFINED ANDROID_PLATFORM)
|
||||
list(APPEND LIBS_MAIN pthread util)
|
||||
if (NOT APPLE)
|
||||
list(APPEND LIBS_MAIN rt)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
set(PIP_LIBS)
|
||||
if(PIP_MICRO)
|
||||
set(PIP_LIBS ${LIBS_MAIN})
|
||||
else()
|
||||
foreach(LIB_ ${LIBS_MAIN})
|
||||
pip_find_lib(${LIB_})
|
||||
endforeach()
|
||||
endif()
|
||||
foreach(LIB_ ${LIBS_MAIN})
|
||||
pip_find_lib(${LIB_})
|
||||
endforeach()
|
||||
if(WIN32)
|
||||
add_definitions(-DPSAPI_VERSION=1)
|
||||
if(${C_COMPILER} STREQUAL "cl.exe")
|
||||
@@ -388,7 +428,7 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
if(DEFINED ENV{QNX_HOST} OR PIP_MICRO)
|
||||
if(DEFINED ENV{QNX_HOST})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
|
||||
endif()
|
||||
|
||||
@@ -428,9 +468,7 @@ endif()
|
||||
|
||||
|
||||
if (NOT CROSSTOOLS)
|
||||
if (NOT PIP_MICRO)
|
||||
|
||||
if (PIP_BUILD_CONSOLE)
|
||||
if (PIP_BUILD_CONSOLE)
|
||||
pip_module(console "" "PIP console support" "" "" "")
|
||||
endif()
|
||||
|
||||
@@ -561,6 +599,9 @@ if (NOT CROSSTOOLS)
|
||||
else()
|
||||
target_compile_definitions(pip_lua PRIVATE LUA_USE_POSIX)
|
||||
endif()
|
||||
if(DEFINED PICO_SDK_PATH)
|
||||
target_compile_definitions(pip_lua PRIVATE LUA_32BITS)
|
||||
endif()
|
||||
list(APPEND HDR_DIRS "${PIP_3PL_DIR}/LuaBridge")
|
||||
list(APPEND HDRS ${_lua_src_hdr})
|
||||
endif()
|
||||
@@ -654,55 +695,36 @@ if (NOT CROSSTOOLS)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
if (PIP_BUILD_CRYPT)
|
||||
pip_module(crypt "" "PIP crypt support" "" "" "")
|
||||
endif()
|
||||
|
||||
if (PIP_BUILD_COMPRESS)
|
||||
pip_module(compress "" "PIP compression support" "" "" "")
|
||||
endif()
|
||||
|
||||
if (PIP_BUILD_IO_UTILS)
|
||||
if(PIP_BUILD_CRYPT)
|
||||
pip_module(io_utils "pip_crypt" "PIP I/O support" "" "" " (+crypt)")
|
||||
else()
|
||||
pip_module(io_utils "" "PIP I/O support" "" "" "")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" "," PIP_EXPORTS_STR "${PIP_EXPORTS}")
|
||||
target_compile_definitions(pip PRIVATE "PICODE_DEFINES=\"${PIP_EXPORTS_STR}\"")
|
||||
|
||||
|
||||
if(NOT PIP_MICRO)
|
||||
|
||||
# Auxiliary
|
||||
if (NOT CROSSTOOLS)
|
||||
add_subdirectory("utils/piterminal")
|
||||
endif()
|
||||
if (NOT CROSSTOOLS AND NOT DEFINED PICO_SDK_PATH)
|
||||
add_subdirectory("utils/piterminal")
|
||||
endif()
|
||||
|
||||
# Utils
|
||||
add_subdirectory("utils/code_model_generator")
|
||||
add_subdirectory("utils/resources_compiler")
|
||||
add_subdirectory("utils/deploy_tool")
|
||||
add_subdirectory("utils/qt_support")
|
||||
add_subdirectory("utils/translator")
|
||||
add_subdirectory("utils/value_tree_translator")
|
||||
if(PIP_UTILS AND (NOT CROSSTOOLS))
|
||||
add_subdirectory("utils/system_calib")
|
||||
add_subdirectory("utils/udp_file_transfer")
|
||||
if(sodium_FOUND)
|
||||
add_subdirectory("utils/system_daemon")
|
||||
add_subdirectory("utils/crypt_tool")
|
||||
add_subdirectory("utils/cloud_dispatcher")
|
||||
endif()
|
||||
if(NOT DEFINED PICO_SDK_PATH)
|
||||
add_subdirectory("utils/code_model_generator")
|
||||
add_subdirectory("utils/resources_compiler")
|
||||
add_subdirectory("utils/deploy_tool")
|
||||
add_subdirectory("utils/qt_support")
|
||||
endif()
|
||||
if(NOT DEFINED PICO_SDK_PATH)
|
||||
add_subdirectory("utils/translator")
|
||||
add_subdirectory("utils/value_tree_translator")
|
||||
endif()
|
||||
if(PIP_UTILS AND (NOT CROSSTOOLS) AND (NOT DEFINED PICO_SDK_PATH))
|
||||
add_subdirectory("utils/system_calib")
|
||||
add_subdirectory("utils/udp_file_transfer")
|
||||
if(sodium_FOUND)
|
||||
add_subdirectory("utils/system_daemon")
|
||||
add_subdirectory("utils/crypt_tool")
|
||||
add_subdirectory("utils/cloud_dispatcher")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
@@ -756,20 +778,18 @@ if(NOT LOCAL)
|
||||
install(TARGETS ${PIP_MODULES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
endif()
|
||||
else()
|
||||
if(NOT PIP_MICRO)
|
||||
if(WIN32)
|
||||
install(TARGETS ${PIP_MODULES} RUNTIME DESTINATION bin)
|
||||
install(TARGETS ${PIP_MODULES} ARCHIVE DESTINATION lib)
|
||||
else()
|
||||
install(TARGETS ${PIP_MODULES} DESTINATION lib)
|
||||
endif()
|
||||
install(FILES ${HDRS} DESTINATION include/pip)
|
||||
if(PIP_LANG)
|
||||
install(FILES ${PIP_LANG} DESTINATION share/pip/lang)
|
||||
endif()
|
||||
if(HDR_DIRS)
|
||||
install(DIRECTORY ${HDR_DIRS} DESTINATION include/pip)
|
||||
endif()
|
||||
if(WIN32)
|
||||
install(TARGETS ${PIP_MODULES} RUNTIME DESTINATION bin)
|
||||
install(TARGETS ${PIP_MODULES} ARCHIVE DESTINATION lib)
|
||||
else()
|
||||
install(TARGETS ${PIP_MODULES} DESTINATION lib)
|
||||
endif()
|
||||
install(FILES ${HDRS} DESTINATION include/pip)
|
||||
if(PIP_LANG)
|
||||
install(FILES ${PIP_LANG} DESTINATION share/pip/lang)
|
||||
endif()
|
||||
if(HDR_DIRS)
|
||||
install(DIRECTORY ${HDR_DIRS} DESTINATION include/pip)
|
||||
endif()
|
||||
endif()
|
||||
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in")
|
||||
@@ -784,7 +804,7 @@ endif()
|
||||
#
|
||||
# Build Documentation
|
||||
#
|
||||
if ((NOT PIP_MICRO) AND (NOT CROSSTOOLS))
|
||||
if (NOT CROSSTOOLS)
|
||||
include(PIPDocumentation)
|
||||
find_package(Doxygen)
|
||||
if(DOXYGEN_FOUND)
|
||||
@@ -853,9 +873,7 @@ message(" Type : ${CMAKE_BUILD_TYPE}")
|
||||
if (NOT LOCAL)
|
||||
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
|
||||
else()
|
||||
if(NOT PIP_MICRO)
|
||||
message(" Install: local \"bin\", \"lib\" and \"include\"")
|
||||
endif()
|
||||
message(" Install: local \"bin\", \"lib\" and \"include\"")
|
||||
endif()
|
||||
message("")
|
||||
message(" Options:")
|
||||
@@ -863,6 +881,14 @@ message(" std::iostream: ${PIP_STD_IOSTREAM}")
|
||||
message(" ICU strings : ${PIP_ICU}")
|
||||
message(" Introspection: ${PIP_INTROSPECTION}")
|
||||
message(" Coverage : ${PIP_COVERAGE}")
|
||||
message(" Feature flags:")
|
||||
message(" PIP_NO_FILESYSTEM: ${PIP_NO_FILESYSTEM}")
|
||||
message(" PIP_NO_THREADS : ${PIP_NO_THREADS}")
|
||||
message(" PIP_NO_SOCKET : ${PIP_NO_SOCKET}")
|
||||
message(" PIP_NO_PROCESS : ${PIP_NO_PROCESS}")
|
||||
message(" PIP_NO_DYNLIB : ${PIP_NO_DYNLIB}")
|
||||
message(" PIP_NO_FFT : ${PIP_NO_FFT}")
|
||||
message(" PIP_NO_SERIAL : ${PIP_NO_SERIAL}")
|
||||
if(INTROSPECTION)
|
||||
message(STATUS " Warning: Introspection reduces the performance!")
|
||||
endif()
|
||||
@@ -889,17 +915,15 @@ message(" Utilites:")
|
||||
foreach(_util ${PIP_UTILS_LIST})
|
||||
message(" * ${_util}")
|
||||
endforeach()
|
||||
if(NOT PIP_MICRO)
|
||||
message("")
|
||||
message(" Using libraries:")
|
||||
foreach(LIB_ ${LIBS_STATUS})
|
||||
if (NOT TARGET ${LIB_})
|
||||
if(${LIB_}_FOUND)
|
||||
message(" ${LIB_} -> ${${LIB_}_LIBRARIES}")
|
||||
else()
|
||||
message(" ${LIB_} not found, may fail")
|
||||
endif()
|
||||
message("")
|
||||
message(" Using libraries:")
|
||||
foreach(LIB_ ${LIBS_STATUS})
|
||||
if (NOT TARGET ${LIB_})
|
||||
if(${LIB_}_FOUND)
|
||||
message(" ${LIB_} -> ${${LIB_}_LIBRARIES}")
|
||||
else()
|
||||
message(" ${LIB_} not found, may fail")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
message("-----------------------")
|
||||
|
||||
Reference in New Issue
Block a user