Skip to content

Commit 1391417

Browse files
committed
zephyr: Add Zephyr module support code under contrib/zephyr/
This is Zephyr module glue code. We've decided contrib/ to store architecture or OS specific code. Zephyr still doesn't support many drivers and interfaces, yet. For UDP interface, we check HAVE_SYS_SOCKET_H to enable it or not but the current check_include_files() doesn't work with Zephyr build system. Thus, explicitly disabled in contrib/zephyr/CMakeLists.txt. Note that turning HAVE_SYS_SOCKET_H ON doesn't build if_udp. you need to enable CONFIG_POSIX_API=y add tell libcsp about the include directory for POSIX subsystem. target_include_directories(libcsp PRIVATE + $<TARGET_PROPERTY:posix_subsys,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:zephyr_interface,INTERFACE_INCLUDE_DIRECTORIES> ) Signed-off-by: Yasushi SHOJI <[email protected]>
1 parent 630c1e9 commit 1391417

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

contrib/zephyr/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
if(CONFIG_LIBCSP)
2+
set(CMAKE_SYSTEM_NAME "Zephyr")
3+
set(CMAKE_BUILD_TYPE None)
4+
set(CMAKE_C_COMPILE_FEATURES c_std_11)
5+
6+
# check_include_file() doesn't work in Zephyr module
7+
# https://github.com/zephyrproject-rtos/zephyr/issues/31193
8+
# predefine it
9+
set(HAVE_SYS_SOCKET_H OFF)
10+
11+
add_subdirectory(../.. build)
12+
13+
# Zephyr compiler options
14+
target_include_directories(libcsp PRIVATE
15+
$<TARGET_PROPERTY:zephyr_interface,INTERFACE_INCLUDE_DIRECTORIES>
16+
)
17+
18+
target_include_directories(libcsp SYSTEM PRIVATE
19+
$<TARGET_PROPERTY:zephyr_interface,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
20+
)
21+
22+
target_compile_definitions(libcsp PRIVATE
23+
$<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_DEFINITIONS>
24+
)
25+
26+
target_compile_options(libcsp PRIVATE
27+
$<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_OPTIONS>
28+
-fno-builtin -Wno-shadow -Wno-cast-align
29+
)
30+
31+
add_dependencies(libcsp ${SYSCALL_LIST_H_TARGET})
32+
zephyr_append_cmake_library(libcsp)
33+
target_link_libraries(libcsp PUBLIC zephyr_interface)
34+
endif()

contrib/zephyr/Kconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# libcsp Cubesat Space Protocol
2+
3+
# Copyright (c) 2021 Space Cubics, LLC.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
config LIBCSP
7+
bool "Enable Cubesat Space Protocol Support"
8+
select POSIX_CLOCK
9+
help
10+
This option enables the Cubesat Space Protocol (CSP) library.
11+
12+
config LIBCSP_DEBUG
13+
bool "Enable CSP debugging option"
14+
help
15+
This option enables CSP debugging options.
16+
17+
if LIBCSP_DEBUG
18+
19+
module = LIBCSP
20+
module-str = libcsp
21+
source "subsys/logging/Kconfig.template.log_config"
22+
23+
endif # LIBCSP_DEBUG

contrib/zephyr/module.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright (c) 2021 Space Cubics, LLC.
3+
4+
build:
5+
cmake: zephyr
6+
kconfig: zephyr/Kconfig

0 commit comments

Comments
 (0)