cmake: Support passing syscall include directories through CMake

Introduce the CMake variable SYSCALL_INCLUDE_DIRS to support
out-of-tree syscall declarations.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
Sebastian Bøe 2018-04-30 15:59:16 +02:00 committed by Anas Nashif
commit 56f6e35e47
2 changed files with 22 additions and 8 deletions

View file

@ -561,16 +561,21 @@ else()
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${syscalls_subdirs_txt}) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${syscalls_subdirs_txt})
endif() endif()
# SYSCALL_INCLUDE_DIRECTORY will include the directories that needs to be # syscall declarations are searched for in the SYSCALL_INCLUDE_DIRS
# searched for syscall declarations if CONFIG_APPLICATION_DEFINED_SYSCALL is set
if(CONFIG_APPLICATION_DEFINED_SYSCALL) if(CONFIG_APPLICATION_DEFINED_SYSCALL)
set(SYSCALL_INCLUDE_DIRECTORY --include ${APPLICATION_SOURCE_DIR}) list(APPEND SYSCALL_INCLUDE_DIRS ${APPLICATION_SOURCE_DIR})
endif() endif()
if(CONFIG_ZTEST) 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() endif()
foreach(d ${SYSCALL_INCLUDE_DIRS})
list(APPEND parse_syscalls_include_args
--include ${d}
)
endforeach()
add_custom_command( add_custom_command(
OUTPUT OUTPUT
${syscalls_json} ${syscalls_json}
@ -578,8 +583,7 @@ add_custom_command(
${PYTHON_EXECUTABLE} ${PYTHON_EXECUTABLE}
${ZEPHYR_BASE}/scripts/parse_syscalls.py ${ZEPHYR_BASE}/scripts/parse_syscalls.py
--include ${ZEPHYR_BASE}/include # Read files from this dir --include ${ZEPHYR_BASE}/include # Read files from this dir
${SYSCALL_INCLUDE_DIRECTORY} ${parse_syscalls_include_args} # Read files from these dirs also
${SYSCALL_ZTEST_DIRECTORY}
--json-file ${syscalls_json} # Write this file --json-file ${syscalls_json} # Write this file
DEPENDS ${syscalls_subdirs_trigger} ${PARSE_SYSCALLS_HEADER_DEPENDS} DEPENDS ${syscalls_subdirs_trigger} ${PARSE_SYSCALLS_HEADER_DEPENDS}
) )

View file

@ -26,8 +26,9 @@ Components
All system calls have the following components: All system calls have the following components:
* A **C prototype** for the API, declared in some header under ``include/`` and * A **C prototype** prefixed with :c:macro:`__syscall` for the API. It
prefixed with :c:macro:`__syscall`. This prototype is never implemented 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. manually, instead it gets created by the :ref:`gen_syscalls.py` script.
What gets generated is an inline function which either calls the What gets generated is an inline function which either calls the
implementation function directly (if called from supervisor mode) or goes implementation function directly (if called from supervisor mode) or goes
@ -88,6 +89,15 @@ bottom of ``include/sensor.h``:
#include <syscalls/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 Invocation Context
================== ==================