Skip to content

Commit bf9584d

Browse files
JordanYatesfabiobaltieri
authored andcommitted
fs: add FILE_SYSTEM_LIB_LINK option
Add an option that links in the underlying file system libraries as usual, but doesn't compile in the Zephyr file system abstraction layer. This can be useful to avoid linking in the entire filesystem implementation through the `fs_file_system_t` API struct if only a subset of the functions are used. Signed-off-by: Jordan Yates <[email protected]>
1 parent b79ffe3 commit bf9584d

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

subsys/fs/CMakeLists.txt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
if(CONFIG_FILE_SYSTEM)
3+
if(CONFIG_FILE_SYSTEM_LIB_LINK)
44
zephyr_interface_library_named(FS)
55

6-
zephyr_library()
7-
zephyr_library_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
8-
zephyr_library_sources(fs.c fs_impl.c)
9-
zephyr_library_sources_ifdef(CONFIG_FAT_FILESYSTEM_ELM fat_fs.c)
10-
zephyr_library_sources_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS littlefs_fs.c)
11-
zephyr_library_sources_ifdef(CONFIG_FILE_SYSTEM_SHELL shell.c)
12-
13-
zephyr_library_compile_definitions_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS
14-
LFS_CONFIG=zephyr_lfs_config.h
15-
)
6+
if(CONFIG_FILE_SYSTEM)
7+
zephyr_library()
8+
zephyr_library_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
9+
zephyr_library_sources(fs.c fs_impl.c)
10+
zephyr_library_sources_ifdef(CONFIG_FAT_FILESYSTEM_ELM fat_fs.c)
11+
zephyr_library_sources_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS littlefs_fs.c)
12+
zephyr_library_sources_ifdef(CONFIG_FILE_SYSTEM_SHELL shell.c)
13+
14+
zephyr_library_compile_definitions_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS
15+
LFS_CONFIG=zephyr_lfs_config.h
16+
)
17+
endif()
1618

1719
add_subdirectory_ifdef(CONFIG_FILE_SYSTEM_EXT2 ext2)
1820

subsys/fs/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@
44

55
menu "File Systems"
66

7+
config FILE_SYSTEM_LIB_LINK
8+
bool "Link file system libraries into build"
9+
help
10+
Link in the underlying file system libraries. This can be
11+
enabled without CONFIG_FILE_SYSTEM to enable applications
12+
to work directly with the underlying file system libraries.
13+
This can be useful to avoid linking in the entire filesystem
14+
implementation via `struct fs_file_system_t` if only a subset
15+
is used.
16+
717
config FILE_SYSTEM
818
bool "File system support"
19+
select FILE_SYSTEM_LIB_LINK
920
help
1021
Enables support for file system.
1122

0 commit comments

Comments
 (0)