1# SPDX-License-Identifier: Apache-2.0
2
3function(gen_kobj gen_dir_out)
4  if (PROJECT_BINARY_DIR)
5    set(gen_dir ${PROJECT_BINARY_DIR}/include/generated)
6  else ()
7    set(gen_dir ${CMAKE_BINARY_DIR}/include/generated)
8  endif ()
9
10  set(KOBJ_TYPES ${gen_dir}/kobj-types-enum.h)
11  set(KOBJ_OTYPE ${gen_dir}/otype-to-str.h)
12  set(KOBJ_SIZE ${gen_dir}/otype-to-size.h)
13
14  file(MAKE_DIRECTORY ${gen_dir})
15
16  add_custom_command(
17    OUTPUT ${KOBJ_TYPES} ${KOBJ_OTYPE} ${KOBJ_SIZE}
18    COMMAND
19    ${PYTHON_EXECUTABLE}
20    ${ZEPHYR_BASE}/scripts/gen_kobject_list.py
21    --kobj-types-output ${KOBJ_TYPES}
22    --kobj-otype-output ${KOBJ_OTYPE}
23    --kobj-size-output ${KOBJ_SIZE}
24    ${gen_kobject_list_include_args}
25    $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
26    DEPENDS
27    ${ZEPHYR_BASE}/scripts/gen_kobject_list.py
28    ${PARSE_SYSCALLS_TARGET}
29    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
30    )
31  add_custom_target(${KOBJ_TYPES_H_TARGET} DEPENDS ${KOBJ_TYPES} ${KOBJ_OTYPE})
32
33  set(${gen_dir_out} ${gen_dir} PARENT_SCOPE)
34
35endfunction ()
36