Skip to content

Commit

Permalink
cmake: Support passing syscall include directories through CMake
Browse files Browse the repository at this point in the history
Introduce the CMake variable SYSCALL_INCLUDE_DIRS to support
out-of-tree syscall declarations.

Signed-off-by: Sebastian Bøe <[email protected]>
  • Loading branch information
SebastianBoe authored and nashif committed Jan 22, 2020
1 parent 65ec2d9 commit 56f6e35
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -561,25 +561,29 @@ else()
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${syscalls_subdirs_txt})
endif()

# SYSCALL_INCLUDE_DIRECTORY will include the directories that needs to be
# searched for syscall declarations if CONFIG_APPLICATION_DEFINED_SYSCALL is set
# syscall declarations are searched for in the SYSCALL_INCLUDE_DIRS
if(CONFIG_APPLICATION_DEFINED_SYSCALL)
set(SYSCALL_INCLUDE_DIRECTORY --include ${APPLICATION_SOURCE_DIR})
list(APPEND SYSCALL_INCLUDE_DIRS ${APPLICATION_SOURCE_DIR})
endif()

if(CONFIG_ZTEST)
set(SYSCALL_ZTEST_DIRECTORY --include ${ZEPHYR_BASE}/subsys/testsuite/ztest/include)
list(APPEND SYSCALL_INCLUDE_DIRS ${ZEPHYR_BASE}/subsys/testsuite/ztest/include)
endif()

foreach(d ${SYSCALL_INCLUDE_DIRS})
list(APPEND parse_syscalls_include_args
--include ${d}
)
endforeach()

add_custom_command(
OUTPUT
${syscalls_json}
COMMAND
${PYTHON_EXECUTABLE}
${ZEPHYR_BASE}/scripts/parse_syscalls.py
--include ${ZEPHYR_BASE}/include # Read files from this dir
${SYSCALL_INCLUDE_DIRECTORY}
${SYSCALL_ZTEST_DIRECTORY}
${parse_syscalls_include_args} # Read files from these dirs also
--json-file ${syscalls_json} # Write this file
DEPENDS ${syscalls_subdirs_trigger} ${PARSE_SYSCALLS_HEADER_DEPENDS}
)
Expand Down
14 changes: 12 additions & 2 deletions doc/reference/usermode/syscalls.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ Components

All system calls have the following components:

* A **C prototype** for the API, declared in some header under ``include/`` and
prefixed with :c:macro:`__syscall`. This prototype is never implemented
* A **C prototype** prefixed with :c:macro:`__syscall` for the API. It
will be declared in some header under ``include/`` or in another
``SYSCALL_INCLUDE_DIRS`` directory. This prototype is never implemented
manually, instead it gets created by the :ref:`gen_syscalls.py` script.
What gets generated is an inline function which either calls the
implementation function directly (if called from supervisor mode) or goes
Expand Down Expand Up @@ -88,6 +89,15 @@ bottom of ``include/sensor.h``:
#include <syscalls/sensor.h>
C prototype functions must be declared in one of the directories
listed in the CMake variable ``SYSCALL_INCLUDE_DIRS``. This list
always contains ``${ZEPHYR_BASE}/include``, but will also contain
``APPLICATION_SOURCE_DIR`` when ``CONFIG_APPLICATION_DEFINED_SYSCALL``
is set, or ``${ZEPHYR_BASE}/subsys/testsuite/ztest/include`` when
``CONFIG_ZTEST`` is set. Additional paths can be added to the list
through the CMake command line or in CMake code that is run before
``${ZEPHYR_BASE}/cmake/app/boilerplate.cmake`` is run.

Invocation Context
==================

Expand Down

0 comments on commit 56f6e35

Please sign in to comment.