Skip to content

Commit e9cb4eb

Browse files
build: Track all syscall deps for syscall regen
Currently, for syscall generation, cmake is only tracking source files under ${ZEPHYR_BASE}/include. However, source files are actually used from a number of different paths including those provided by clients. This commit adds dependency tracking for all of those sources. Signed-off-by: Mark Inderhees <[email protected]>
1 parent c780658 commit e9cb4eb

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

CMakeLists.txt

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,33 @@ if(NOT (${CMAKE_HOST_SYSTEM_NAME} STREQUAL Windows))
801801
endif()
802802

803803
# When running CMake it must be ensured that all dependencies are correctly acquired.
804+
# Gather syscall dependencies
805+
list(APPEND SYSCALL_SCAN_DIRS ${ZEPHYR_BASE}/include ${ZEPHYR_BASE}/drivers ${ZEPHYR_BASE}/subsys/net)
806+
807+
if(CONFIG_APPLICATION_DEFINED_SYSCALL)
808+
list(APPEND SYSCALL_INCLUDE_DIRS ${APPLICATION_SOURCE_DIR})
809+
endif()
810+
811+
if(CONFIG_ZTEST)
812+
list(APPEND SYSCALL_INCLUDE_DIRS ${ZEPHYR_BASE}/subsys/testsuite/ztest/include)
813+
814+
if(CONFIG_NO_OPTIMIZATIONS AND CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS)
815+
message(WARNING "Running tests with CONFIG_NO_OPTIMIZATIONS is generally "
816+
"not supported and known to break in many cases due to stack overflow or "
817+
"other problems. Please do not file issues about it unless the test is "
818+
"specifically tuned to run in this configuration. To disable this warning "
819+
"set CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS=n.")
820+
endif()
821+
endif()
822+
823+
get_property(
824+
syscalls_include_list
825+
TARGET syscalls_interface
826+
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
827+
)
828+
list(APPEND SYSCALL_INCLUDE_DIRS ${syscalls_include_list})
829+
830+
# Walk dependencies to find all subfolders
804831
execute_process(
805832
COMMAND
806833
${PYTHON_EXECUTABLE}
@@ -813,7 +840,12 @@ execute_process(
813840
file(STRINGS ${syscalls_subdirs_txt} PARSE_SYSCALLS_PATHS_DEPENDS ENCODING UTF-8)
814841

815842
# Each header file must be monitored as file modifications are not reflected on directory level.
816-
file(GLOB_RECURSE PARSE_SYSCALLS_HEADER_DEPENDS ${ZEPHYR_BASE}/include/*.h)
843+
foreach(d IN LISTS SYSCALL_SCAN_DIRS SYSCALL_INCLUDE_DIRS)
844+
list(APPEND glob_syscalls_headers
845+
${d}/*.h
846+
)
847+
endforeach()
848+
file(GLOB_RECURSE PARSE_SYSCALLS_HEADER_DEPENDS ${glob_syscalls_headers})
817849

818850
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Windows)
819851
# On windows only adding/removing files or folders will be reflected in depends.
@@ -856,30 +888,12 @@ else()
856888
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${syscalls_subdirs_txt})
857889
endif()
858890

859-
# syscall declarations are searched for in the SYSCALL_INCLUDE_DIRS
860-
if(CONFIG_APPLICATION_DEFINED_SYSCALL)
861-
list(APPEND SYSCALL_INCLUDE_DIRS ${APPLICATION_SOURCE_DIR})
862-
endif()
863-
864-
if(CONFIG_ZTEST)
865-
list(APPEND SYSCALL_INCLUDE_DIRS ${ZEPHYR_BASE}/subsys/testsuite/ztest/include)
866-
867-
if(CONFIG_NO_OPTIMIZATIONS AND CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS)
868-
message(WARNING "Running tests with CONFIG_NO_OPTIMIZATIONS is generally "
869-
"not supported and known to break in many cases due to stack overflow or "
870-
"other problems. Please do not file issues about it unless the test is "
871-
"specifically tuned to run in this configuration. To disable this warning "
872-
"set CONFIG_ZTEST_WARN_NO_OPTIMIZATIONS=n.")
873-
endif()
874-
875-
endif()
876-
877-
get_property(
878-
syscalls_include_list
879-
TARGET syscalls_interface
880-
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
881-
)
882-
list(APPEND SYSCALL_INCLUDE_DIRS ${syscalls_include_list})
891+
# syscall declarations are searched for in the SYSCALL_SCAN_DIRS and SYSCALL_INCLUDE_DIRS
892+
foreach(d ${SYSCALL_SCAN_DIRS})
893+
list(APPEND parse_syscalls_scan_args
894+
--scan ${d}
895+
)
896+
endforeach()
883897

884898
foreach(d ${SYSCALL_INCLUDE_DIRS})
885899
list(APPEND parse_syscalls_include_args
@@ -894,9 +908,7 @@ add_custom_command(
894908
COMMAND
895909
${PYTHON_EXECUTABLE}
896910
${ZEPHYR_BASE}/scripts/build/parse_syscalls.py
897-
--scan ${ZEPHYR_BASE}/include # Read files from this dir
898-
--scan ${ZEPHYR_BASE}/drivers # For net sockets
899-
--scan ${ZEPHYR_BASE}/subsys/net # More net sockets
911+
${parse_syscalls_scan_args} # Search for syscall declarations in these dirs
900912
${parse_syscalls_include_args} # Read files from these dirs also
901913
--json-file ${syscalls_json} # Write this file
902914
--tag-struct-file ${struct_tags_json} # Write subsystem list to this file

0 commit comments

Comments
 (0)