diff --git a/Drv/Ip/CMakeLists.txt b/Drv/Ip/CMakeLists.txt index 7b08f7054c..8656583bf1 100644 --- a/Drv/Ip/CMakeLists.txt +++ b/Drv/Ip/CMakeLists.txt @@ -5,48 +5,48 @@ # MOD_DEPS: (optional) module dependencies # #### -restrict_platforms(Posix) +restrict_platforms(Posix SOCKETS) set(SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/IpSocket.cpp" - "${CMAKE_CURRENT_LIST_DIR}/TcpClientSocket.cpp" - "${CMAKE_CURRENT_LIST_DIR}/TcpServerSocket.cpp" - "${CMAKE_CURRENT_LIST_DIR}/UdpSocket.cpp" - "${CMAKE_CURRENT_LIST_DIR}/SocketComponentHelper.cpp" + "${CMAKE_CURRENT_LIST_DIR}/IpSocket.cpp" + "${CMAKE_CURRENT_LIST_DIR}/TcpClientSocket.cpp" + "${CMAKE_CURRENT_LIST_DIR}/TcpServerSocket.cpp" + "${CMAKE_CURRENT_LIST_DIR}/UdpSocket.cpp" + "${CMAKE_CURRENT_LIST_DIR}/SocketComponentHelper.cpp" ) set(MOD_DEPS - Os - Fw/Buffer + Os + Fw/Buffer ) register_fprime_module() # The PortSelector library and testing helper is only needed on Testing build if (BUILD_TESTING) - add_library(SocketTestHelper STATIC - "${CMAKE_CURRENT_LIST_DIR}/test/ut/PortSelector.cpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/SocketTestHelper.cpp") - target_include_directories(SocketTestHelper PUBLIC - "${FPRIME_FRAMEWORK_PATH}/STest" - "${FPRIME_FRAMEWORK_PATH}/googletest/googletest/include" - ) - add_dependencies(SocketTestHelper STest Fw_Buffer) - target_link_libraries(SocketTestHelper STest Fw_Buffer) + add_library(SocketTestHelper STATIC + "${CMAKE_CURRENT_LIST_DIR}/test/ut/PortSelector.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/SocketTestHelper.cpp") + target_include_directories(SocketTestHelper PUBLIC + "${FPRIME_FRAMEWORK_PATH}/STest" + "${FPRIME_FRAMEWORK_PATH}/googletest/googletest/include" + ) + add_dependencies(SocketTestHelper STest Fw_Buffer) + target_link_libraries(SocketTestHelper STest Fw_Buffer) endif() set(UT_MOD_DEPS - SocketTestHelper + SocketTestHelper ) ### UTs ### set(UT_SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/test/ut/TestTcp.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/TestTcp.cpp" ) register_fprime_ut("Drv_Ip_Tcp_test") set(UT_SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/test/ut/TestUdp.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/TestUdp.cpp" ) register_fprime_ut("Drv_Ip_Udp_test") diff --git a/Drv/TcpClient/CMakeLists.txt b/Drv/TcpClient/CMakeLists.txt index 747bdd15e5..30d977cbef 100644 --- a/Drv/TcpClient/CMakeLists.txt +++ b/Drv/TcpClient/CMakeLists.txt @@ -5,31 +5,31 @@ # MOD_DEPS: (optional) module dependencies # #### -restrict_platforms(Posix) +restrict_platforms(Posix SOCKETS) set(SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/TcpClient.fpp" - "${CMAKE_CURRENT_LIST_DIR}/TcpClientComponentImpl.cpp" + "${CMAKE_CURRENT_LIST_DIR}/TcpClient.fpp" + "${CMAKE_CURRENT_LIST_DIR}/TcpClientComponentImpl.cpp" ) # Necessary shared helpers set(MOD_DEPS - "Fw/Logger" - "Drv/ByteStreamDriverModel" - "Drv/Ip" + "Fw/Logger" + "Drv/ByteStreamDriverModel" + "Drv/Ip" ) register_fprime_module() ### UTs ### set(UT_SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/TcpClient.fpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/TcpClientTestMain.cpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/TcpClientTester.cpp" + "${CMAKE_CURRENT_LIST_DIR}/TcpClient.fpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/TcpClientTestMain.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/TcpClientTester.cpp" ) set(UT_MOD_DEPS - STest - SocketTestHelper + STest + SocketTestHelper ) set(UT_AUTO_HELPERS ON) register_fprime_ut() diff --git a/Drv/TcpServer/CMakeLists.txt b/Drv/TcpServer/CMakeLists.txt index 33cef87f8f..91e284a396 100644 --- a/Drv/TcpServer/CMakeLists.txt +++ b/Drv/TcpServer/CMakeLists.txt @@ -5,31 +5,31 @@ # MOD_DEPS: (optional) module dependencies # #### -restrict_platforms(Posix) +restrict_platforms(Posix SOCKETS) set(SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/TcpServer.fpp" - "${CMAKE_CURRENT_LIST_DIR}/TcpServerComponentImpl.cpp" + "${CMAKE_CURRENT_LIST_DIR}/TcpServer.fpp" + "${CMAKE_CURRENT_LIST_DIR}/TcpServerComponentImpl.cpp" ) # Necessary shared helpers set(MOD_DEPS - "Fw/Logger" - "Drv/ByteStreamDriverModel" - "Drv/Ip" + "Fw/Logger" + "Drv/ByteStreamDriverModel" + "Drv/Ip" ) register_fprime_module() ### UTs ### set(UT_SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/TcpServer.fpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/TcpServerTestMain.cpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/TcpServerTester.cpp" + "${CMAKE_CURRENT_LIST_DIR}/TcpServer.fpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/TcpServerTestMain.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/TcpServerTester.cpp" ) set(UT_MOD_DEPS - STest - SocketTestHelper + STest + SocketTestHelper ) set(UT_AUTO_HELPERS ON) register_fprime_ut() diff --git a/Drv/Udp/CMakeLists.txt b/Drv/Udp/CMakeLists.txt index f0defac2f5..75cf6a56a8 100644 --- a/Drv/Udp/CMakeLists.txt +++ b/Drv/Udp/CMakeLists.txt @@ -5,31 +5,31 @@ # MOD_DEPS: (optional) module dependencies # #### -restrict_platforms(Posix) +restrict_platforms(Posix SOCKETS) set(SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/Udp.fpp" - "${CMAKE_CURRENT_LIST_DIR}/UdpComponentImpl.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Udp.fpp" + "${CMAKE_CURRENT_LIST_DIR}/UdpComponentImpl.cpp" ) # Necessary shared helpers set(MOD_DEPS - "Fw/Logger" - "Drv/ByteStreamDriverModel" - "Drv/Ip" + "Fw/Logger" + "Drv/ByteStreamDriverModel" + "Drv/Ip" ) register_fprime_module() ### UTs ### set(UT_SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/Udp.fpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/UdpTestMain.cpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/UdpTester.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Udp.fpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/UdpTestMain.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/UdpTester.cpp" ) set(UT_MOD_DEPS - STest - SocketTestHelper + STest + SocketTestHelper ) set(UT_AUTO_HELPERS ON) register_fprime_ut() diff --git a/cmake/API.cmake b/cmake/API.cmake index 483efed0f8..fded7bd88f 100644 --- a/cmake/API.cmake +++ b/cmake/API.cmake @@ -33,11 +33,19 @@ endmacro() #### # Macro `restrict_platforms`: # -# Restricts a CMakeLists.txt file to a given list of platforms. This prevents usage on platforms for which the module -# is incapable of being used and replaces the historical pattern of an if-tree detecting unsupported platforms. +# Restricts a CMakeLists.txt file to a given list of supported platforms, toolchains, and features. This prevents +# usage on platforms/toolchains for which the module is incapable of being used and replaces the historical pattern of +# an if-tree detecting unsupported platforms in most circumstances. +# +# Valid inputs include names of platforms (e.g. Linux), names of specific toolchains (e.g. aarch64-linux), and platform +# supported feature sets (e.g. SOCKETS, which inspects the FPRIME_HAS_SOCKETS flag). # # Usage: # restrict_platforms(Linux Darwin) # Restricts to Linux and Darwin platforms +# -or- +# restrict_platforms(Posix) # Restricts to posix systems +# -or- +# restrict_platforms(SOCKETS) # Restricts to platforms where FPRIME_HAS_SOCKETS is TRUE # # Args: # ARGN: list of platforms that are supported @@ -45,6 +53,16 @@ endmacro() macro(restrict_platforms) set(__CHECKER ${ARGN}) + # Determine if any of the restrict-tos maps to a fprime feature flag of the form FPRIME_HAS_XYZ as set in the + # platform support file. If this feature is set and true, then the restriction block may pass. + set(__HAS_SUPPORTED_FEATURE FALSE) + foreach (__RESTRICTION IN LISTS __CHECKER) + string(TOUPPER "${__RESTRICTION}" __RESTRICTION_UPPER) + if (FPRIME_HAS_${__RESTRICTION_UPPER}) + set(__HAS_SUPPORTED_FEATURE TRUE) + break() + endif() + endforeach() # Each of these empty if blocks are the valid-case, that is, the platform is supported. # However, the reason why this is necessary is that this function is a macro and not a function. # Macros copy-paste the code into the calling context. Thus, all these valid cases want to avoid calling return. @@ -53,6 +71,9 @@ macro(restrict_platforms) if (FPRIME_TOOLCHAIN_NAME IN_LIST __CHECKER) elseif(FPRIME_PLATFORM IN_LIST __CHECKER) + # New style FPRIME_HAS_ + elseif(__HAS_SUPPORTED_FEATURE) + # Old style posix FPRIME_USE_POSIX elseif("Posix" IN_LIST __CHECKER AND FPRIME_USE_POSIX) else() get_module_name("${CMAKE_CURRENT_LIST_DIR}") diff --git a/cmake/platform/Darwin.cmake b/cmake/platform/Darwin.cmake index 9ad9cdf6d7..7daa8f6da1 100644 --- a/cmake/platform/Darwin.cmake +++ b/cmake/platform/Darwin.cmake @@ -7,6 +7,7 @@ add_definitions(-DTGT_OS_TYPE_DARWIN) set(FPRIME_USE_POSIX ON) +set(FPRIME_HAS_SOCKETS ON) # Set platform default for stubbed drivers if (NOT DEFINED FPRIME_USE_STUBBED_DRIVERS) set(FPRIME_USE_STUBBED_DRIVERS ON) diff --git a/cmake/platform/Linux.cmake b/cmake/platform/Linux.cmake index f332b988a7..6c23c7e421 100644 --- a/cmake/platform/Linux.cmake +++ b/cmake/platform/Linux.cmake @@ -22,6 +22,7 @@ choose_fprime_implementation(Os/Memory Os/Memory/Linux) # Use common linux setup add_definitions(-DTGT_OS_TYPE_LINUX) set(FPRIME_USE_POSIX ON) +set(FPRIME_HAS_SOCKETS ON) # Add Linux specific headers into the system include_directories(SYSTEM "${CMAKE_CURRENT_LIST_DIR}/types") diff --git a/cmake/platform/rtems5.cmake b/cmake/platform/rtems5.cmake deleted file mode 100644 index 3b16c900bd..0000000000 --- a/cmake/platform/rtems5.cmake +++ /dev/null @@ -1,20 +0,0 @@ -add_definitions(-DTGT_OS_TYPE_RTEMS) - -# Add Linux specific headers into the system -include_directories(SYSTEM "${FPRIME_FRAMEWORK_PATH}/Fw/Types/Linux") -set(FPRIME_USE_POSIX ON) - -include_directories(SYSTEM - ${RTEMS_INCLUDE_DIRS} - ${RTEMS_BSP_INCLUDE_DIRS} - ${RTEMS_SOURCE_DIR}/testsuites/support/include -) - -add_compile_options(${RTEMS_C_FLAGS}) - -add_link_options(${RTEMS_LINK_FLAGS}) - -add_compile_definitions( - __rtems__ - _POSIX_THREADS -) diff --git a/requirements.txt b/requirements.txt index c9aad20196..2b9131fa32 100644 --- a/requirements.txt +++ b/requirements.txt @@ -33,7 +33,7 @@ fprime-fpp-to-dict==2.2.1a1 fprime-fpp-to-json==2.2.1a1 fprime-fpp-to-xml==2.2.1a1 fprime-gds==3.5.0 -fprime-tools==3.5.0 +fprime-tools==3.5.1a2 fprime-visual==1.0.2 gcovr==8.2 idna==3.10