Skip to content

Commit c780658

Browse files
build: Dependency handling for syscall gen for changed API
Fix issue where changing an existing syscall API does not result in regeneration of syscalls. This causes a build break on incremental builds. The issue comes from an incorrect assumption that file modifications result in updates to folder timestamps on Linux. The fix is to use the same mechanism Windows is using to track file changes, making explicit deps on header files that have syscalls. Signed-off-by: Mark Inderhees <[email protected]>
1 parent dddd738 commit c780658

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

CMakeLists.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -788,12 +788,12 @@ set(struct_tags_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/struct_tags.json
788788
# The syscalls subdirs txt file is constructed by python containing a list of folders to use for
789789
# dependency handling, including empty folders.
790790
# Windows: The list is used to specify DIRECTORY list with CMAKE_CONFIGURE_DEPENDS attribute.
791-
# Other OS: The list will update whenever a file is added/removed/modified and ensure a re-build.
791+
# Other OS: The list file is updated whenever a directory is added or removed.
792792
set(syscalls_subdirs_txt ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls_subdirs.txt)
793793

794-
# As syscalls_subdirs_txt is updated whenever a file is modified, this file can not be used for
795-
# monitoring of added / removed folders. A trigger file is thus used for correct dependency
796-
# handling. The trigger file will update when a folder is added / removed.
794+
# As syscalls_subdirs_txt is updated only on directory add or remove, this file can not be used for
795+
# monitoring of syscall changes. A trigger file is thus used for correct dependency handling. The
796+
# trigger file will update when syscalls change.
797797
set(syscalls_subdirs_trigger ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls_subdirs.trigger)
798798

799799
if(NOT (${CMAKE_HOST_SYSTEM_NAME} STREQUAL Windows))
@@ -812,14 +812,13 @@ execute_process(
812812
)
813813
file(STRINGS ${syscalls_subdirs_txt} PARSE_SYSCALLS_PATHS_DEPENDS ENCODING UTF-8)
814814

815+
# 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)
817+
815818
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Windows)
816819
# On windows only adding/removing files or folders will be reflected in depends.
817820
# Hence adding a file requires CMake to re-run to add this file to the file list.
818821
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PARSE_SYSCALLS_PATHS_DEPENDS})
819-
820-
# Also On Windows each header file must be monitored as file modifications are not reflected
821-
# on directory level.
822-
file(GLOB_RECURSE PARSE_SYSCALLS_HEADER_DEPENDS ${ZEPHYR_BASE}/include/*.h)
823822
else()
824823
# The syscall parsing depends on the folders in order to detect add/removed/modified files.
825824
# When a folder is removed, CMake will try to find a target that creates that dependency.
@@ -850,10 +849,10 @@ else()
850849
file(WRITE ${syscalls_subdirs_txt} "")
851850
endif()
852851

853-
# On other OS'es, modifying a file is reflected on the folder timestamp and hence detected
852+
# On other OS'es, using git checkout is reflected on the folder timestamp and hence detected
854853
# when using depend on directory level.
855854
# Thus CMake only needs to re-run when sub-directories are added / removed, which is indicated
856-
# using a trigger file.
855+
# by syscalls_subdirs_txt being updated.
857856
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${syscalls_subdirs_txt})
858857
endif()
859858

0 commit comments

Comments
 (0)