Skip to content

Commit

Permalink
cmake: Add zpp target
Browse files Browse the repository at this point in the history
Create a CMake target to build the annotations together with a depfile.

Signed-off-by: Pieter De Gendt <[email protected]>
  • Loading branch information
pdgendt committed Dec 16, 2024
1 parent 50ca751 commit eb9ce84
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ zephyr_include_directories(
${STDINCLUDE}
)

include(${ZEPHYR_BASE}/cmake/zpp.cmake)
include(${ZEPHYR_BASE}/cmake/linker_script/${ARCH}/linker.cmake OPTIONAL)

zephyr_include_directories(${SOC_FULL_DIR})
Expand Down
27 changes: 27 additions & 0 deletions cmake/zpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2024 Basalte bv
#
# SPDX-License-Identifier: Apache-2.0

# Generate compile_commands.json in the output directory
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE CACHE BOOL
"Export CMake compile commands. Used by zpp.py script"
FORCE
)

set(annotations_json "${CMAKE_BINARY_DIR}/zephyr/annotations.json")

add_custom_command(
OUTPUT ${annotations_json}
COMMAND
${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/zpp.py
-j ${CMAKE_BUILD_PARALLEL_LEVEL}
-o ${annotations_json}
-d ${annotations_json}.d
${CMAKE_BINARY_DIR}/compile_commands.json
DEPENDS
${ZEPHYR_BASE}/scripts/zpp.py
${CMAKE_BINARY_DIR}/compile_commands.json
DEPFILE ${annotations_json}.d
)

add_custom_target(zpp DEPENDS ${annotations_json})

0 comments on commit eb9ce84

Please sign in to comment.