code clean up for POSIX. (#2700)

* code clean up for POSIX.

* Adding comment to clear up unusual empty if elseif blocks
This commit is contained in:
kevin-f-ortega 2024-04-24 16:56:58 -07:00 committed by GitHub
parent 109e4bd399
commit 8084fa1dd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 29 additions and 15 deletions

View File

@ -15,12 +15,7 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxSpiDriver/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxI2cDriver/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/StreamCrossover/")
# IP Socket is only supported for Linux, Darwin, VxWorks
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR ${CMAKE_SYSTEM_NAME} STREQUAL "VxWorks")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ip/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TcpClient/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TcpServer/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Udp/")
else()
message(STATUS "Cannot use IP sockets with platform ${CMAKE_SYSTEM_NAME}. Skipping.")
endif()
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ip/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TcpClient/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TcpServer/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Udp/")

View File

@ -5,6 +5,8 @@
# MOD_DEPS: (optional) module dependencies
#
####
restrict_platforms(Posix)
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/IpSocket.cpp"
"${CMAKE_CURRENT_LIST_DIR}/TcpClientSocket.cpp"

View File

@ -5,6 +5,8 @@
# MOD_DEPS: (optional) module dependencies
#
####
restrict_platforms(Posix)
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/TcpClient.fpp"
"${CMAKE_CURRENT_LIST_DIR}/TcpClientComponentImpl.cpp"

View File

@ -5,6 +5,8 @@
# MOD_DEPS: (optional) module dependencies
#
####
restrict_platforms(Posix)
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/TcpServer.fpp"
"${CMAKE_CURRENT_LIST_DIR}/TcpServerComponentImpl.cpp"

View File

@ -5,6 +5,8 @@
# MOD_DEPS: (optional) module dependencies
#
####
restrict_platforms(Posix)
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/Udp.fpp"
"${CMAKE_CURRENT_LIST_DIR}/UdpComponentImpl.cpp"

View File

@ -5,7 +5,7 @@
# MOD_DEPS: (optional) module dependencies
#
####
restrict_platforms(Linux Darwin)
restrict_platforms(Posix)
add_custom_target("${FPRIME_CURRENT_MODULE}")
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/File.cpp"

View File

@ -53,7 +53,5 @@ if (FPRIME_ENABLE_TEXT_LOGGERS)
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ActiveTextLogger/")
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PosixTime/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxTimer/")
endif()
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PosixTime/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/LinuxTimer/")

View File

@ -5,6 +5,7 @@
# MOD_DEPS: (optional) module dependencies
#
####
restrict_platforms(Linux Darwin)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")

View File

@ -6,6 +6,8 @@
#
# Note: using PROJECT_NAME as EXECUTABLE_NAME
####
restrict_platforms(Posix)
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/PosixTime.fpp"
"${CMAKE_CURRENT_LIST_DIR}/PosixTime.cpp"

View File

@ -31,7 +31,17 @@ set(FPRIME_AUTOCODER_TARGET_LIST "" CACHE INTERNAL "FPRIME_AUTOCODER_TARGET_LIST
#####
macro(restrict_platforms)
set(__CHECKER ${ARGN})
if (NOT FPRIME_TOOLCHAIN_NAME IN_LIST __CHECKER AND NOT FPRIME_PLATFORM IN_LIST __CHECKER)
# 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.
# The return call in the else block returns from the calling context (i.e. a restricted CMakeList.txt will
# return and not process the component setup). We do not want this return when the platform is allowed.
if (FPRIME_TOOLCHAIN_NAME IN_LIST __CHECKER)
elseif(FPRIME_PLATFORM IN_LIST __CHECKER)
elseif("Posix" IN_LIST __CHECKER AND FPRIME_USE_POSIX)
else()
get_module_name("${CMAKE_CURRENT_LIST_DIR}")
message(STATUS "Neither toolchain ${FPRIME_TOOLCHAIN_NAME} nor platform ${FPRIME_PLATFORM} supported for module ${MODULE_NAME}")
append_list_property("${MODULE_NAME}" GLOBAL PROPERTY RESTRICTED_TARGETS)