Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code clean up for POSIX. #2700

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions Drv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
2 changes: 2 additions & 0 deletions Drv/Ip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions Drv/TcpClient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions Drv/TcpServer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions Drv/Udp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Os/Posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions Svc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
1 change: 1 addition & 0 deletions Svc/LinuxTimer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# MOD_DEPS: (optional) module dependencies
#
####
restrict_platforms(Linux Darwin)


if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
Expand Down
2 changes: 2 additions & 0 deletions Svc/PosixTime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 11 additions & 1 deletion cmake/API.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
kevin-f-ortega marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down
Loading