Skip to content

Commit 0dcee73

Browse files
pfalcongalak
authored andcommitted
lib: posix: Kconfig: Allow to enable individual components
Allow to enable individual POSIX components, like Pthreads. CONFIG_POSIX_API now just enables all of individual POSIX components, and sets up environment suitable to easily port POSIX applications to Zephyr. Fixes: zephyrproject-rtos#12965 Signed-off-by: Paul Sokolovsky <[email protected]>
1 parent a4c3196 commit 0dcee73

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

lib/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
if(NOT CONFIG_NATIVE_APPLICATION)
44
add_subdirectory(libc)
5+
add_subdirectory(posix)
56
endif()
6-
add_subdirectory_ifdef(CONFIG_POSIX_API posix)
77
add_subdirectory_ifdef(CONFIG_CMSIS_RTOS_V1 cmsis_rtos_v1)
88
add_subdirectory_ifdef(CONFIG_CMSIS_RTOS_V2 cmsis_rtos_v2)
99
add_subdirectory(gui)

lib/posix/CMakeLists.txt

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33

44
zephyr_interface_library_named(posix_subsys)
55

6-
target_include_directories(posix_subsys INTERFACE ${ZEPHYR_BASE}/include/posix)
6+
if(CONFIG_POSIX_API)
7+
target_include_directories(posix_subsys INTERFACE ${ZEPHYR_BASE}/include/posix)
8+
endif()
79

810
zephyr_library()
911
zephyr_library_sources(pthread_common.c)
1012
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_cond.c)
1113
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_mutex.c)
1214
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_barrier.c)
1315
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread.c)
14-
zephyr_library_sources(pthread_sched.c)
15-
zephyr_library_sources(clock.c)
16-
zephyr_library_sources(sleep.c)
17-
zephyr_library_sources(timer.c)
16+
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_sched.c)
17+
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK clock.c)
18+
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK sleep.c)
19+
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK timer.c)
1820
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_rwlock.c)
1921
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC semaphore.c)
2022
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC pthread_key.c)

lib/posix/Kconfig

+12-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ config POSIX_API
1919
Enable mostly-standards-compliant implementations of
2020
various POSIX (IEEE 1003.1) APIs.
2121

22-
if POSIX_API
23-
2422
config PTHREAD_IPC
2523
bool "POSIX pthread IPC API"
24+
default y if POSIX_API
2625
help
2726
This enables a mostly-standards-compliant implementation of
2827
the pthread mutex, condition variable and barrier IPC
@@ -45,6 +44,13 @@ config SEM_VALUE_MAX
4544

4645
endif # PTHREAD_IPC
4746

47+
config POSIX_CLOCK
48+
bool "POSIX clock, timer, and sleep APIs"
49+
default y if POSIX_API
50+
help
51+
This enables POSIX clock\_\*(), timer\_\*(), and \*sleep()
52+
functions.
53+
4854
config MAX_TIMER_COUNT
4955
int "Maximum timer count in POSIX application"
5056
default 5
@@ -54,6 +60,7 @@ config MAX_TIMER_COUNT
5460

5561
config POSIX_MQUEUE
5662
bool "Enable POSIX message queue"
63+
default y if POSIX_API
5764
help
5865
This enabled POSIX message queue related APIs.
5966

@@ -83,6 +90,7 @@ endif
8390
if FILE_SYSTEM
8491
config POSIX_FS
8592
bool "Enable POSIX file system API support"
93+
default y if POSIX_API
8694
help
8795
This enables POSIX style file system related APIs.
8896

@@ -96,6 +104,8 @@ config POSIX_MAX_OPEN_FILES
96104
endif
97105
endif # FILE_SYSTEM
98106

107+
if POSIX_API
108+
99109
# The name of this option is mandated by zephyr_interface_library_named
100110
# cmake directive.
101111
config APP_LINK_WITH_POSIX_SUBSYS

0 commit comments

Comments
 (0)